mirror of
https://github.com/apricote/hcloud-upload-image.git
synced 2026-01-13 21:31:03 +00:00
feat: documentation and cleanup command
This commit is contained in:
parent
27d4e3240e
commit
c9ab40b539
16 changed files with 394 additions and 148 deletions
30
hcloudimages/internal/labelutil/labels.go
Normal file
30
hcloudimages/internal/labelutil/labels.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package labelutil
|
||||
|
||||
import "fmt"
|
||||
|
||||
func Merge(a, b map[string]string) map[string]string {
|
||||
result := make(map[string]string, len(a)+len(b))
|
||||
|
||||
for k, v := range a {
|
||||
result[k] = v
|
||||
}
|
||||
for k, v := range b {
|
||||
result[k] = v
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func Selector(labels map[string]string) string {
|
||||
selector := make([]byte, 0, 64)
|
||||
separator := ""
|
||||
|
||||
for k, v := range labels {
|
||||
selector = fmt.Appendf(selector, "%s%s=%s", separator, k, v)
|
||||
|
||||
// Do not print separator on first element
|
||||
separator = ","
|
||||
}
|
||||
|
||||
return string(selector)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue