Skip to content

Introduce common utility method for handling map like options #577

@rhuss

Description

@rhuss

As we have now multiple options which are of map type we should use a common codebase to guarantee that they are all handled the same

The options I have in mind are (but maybe more):

  • --env, --annotations and --label for services
  • --filter for triggers
  • --traffic for services (see comments below why --traffic is special)

The behaviour should be (using --env as an example):

  • --env a1=b1 --env a2=b2 should add both env variables
  • --env a1 should set a1 to empty string
  • --env a1- should remove the environment variable for update and an error for create
  • --env a1=b1 --env a1=b2 should be an error as the same key can not be specified on the same command line

I could imagine to have a function signature like

parseMapOptions(key string, options []string) (map[string]string, error)

and a usage

filters, err := parseMapOptions("filter", f.Filters)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions