Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Enabling support for multiple labels and annotations through event.check.output #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ type Config struct {

// EntitySubscriptions is a partial Entity definition for use with the
// PATCH /entities API
// type Deregistration struct {
// Handler string `json:"handler"`
// }
//
// type Deregistration struct {
// Handler string `json:"handler"`
// }
type ObjectMeta struct {
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Expand Down Expand Up @@ -254,7 +255,7 @@ func indexOf(s []string, k string) int {
// NOTE: this is a potentially destructive method (values may be overwritten)
func mergeMapStringStrings(a map[string]string, b map[string]string) map[string]string {
if a == nil {
fmt.Printf("Error: no entity labels; %v", a)
a = make(map[string]string)
}
for k, v := range b {
a[k] = v
Expand Down Expand Up @@ -304,11 +305,11 @@ func addSubscriptions(subs []string) {
}

func addLabels(labels []string) {
plugin.Labels = parseKvStringSlice(labels)
plugin.Labels = mergeMapStringStrings(plugin.Labels, parseKvStringSlice(labels))
}

func addAnnotations(annotations []string) {
plugin.Annotations = parseKvStringSlice(annotations)
plugin.Annotations = mergeMapStringStrings(plugin.Annotations, parseKvStringSlice(annotations))
}

func patchEntity(event *types.Event) *EntityPatch {
Expand Down