Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Allow to inject custom labels via --label option #91

Merged
merged 7 commits into from
Sep 30, 2019
Merged

Conversation

jakolehm
Copy link
Contributor

@jakolehm jakolehm commented Jan 25, 2019

Labels

It's possible to set global labels for all resources in a shot via options or configuration file.

Labels via options

Use mortar --label foo=bar my-app resource to set label to all resources in a shot.

Labels via configuration file

labels:
  foo: bar
  bar: baz

@jakolehm jakolehm added the enhancement New feature or request label Jan 25, 2019
@jakolehm
Copy link
Contributor Author

@jnummelin should custom labels be also configurable via shot.yml?

@jnummelin
Copy link
Contributor

should custom labels be also configurable via shot.yml?

Definitely yes.

@jakolehm
Copy link
Contributor Author

@jnummelin PTAL

@jakolehm
Copy link
Contributor Author

jakolehm commented May 2, 2019

@kke @jnummelin PTAL

@@ -10,25 +10,46 @@ def self.load(path)
raise ConfigError, "Failed to load config, check config file syntax" unless cfg.is_a? Hash
raise ConfigError, "Failed to load config, overlays needs to be an array" if cfg.key?('overlays') && !cfg['overlays'].is_a?(Array)

new(variables: cfg['variables'] || {}, overlays: cfg['overlays'] || [])
if cfg.key?('labels')
raise ConfigError, "Failed to load config, labels needs to be a hash" if !cfg['labels'].is_a?(Hash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ConfigError, "Failed to load config, labels needs to be a hash" if !cfg['labels'].is_a?(Hash)
raise ConfigError, "Failed to load config, labels needs to be a hash" unless cfg['labels'].is_a?(Hash)

Minor nitpick

new(variables: cfg['variables'] || {}, overlays: cfg['overlays'] || [])
if cfg.key?('labels')
raise ConfigError, "Failed to load config, labels needs to be a hash" if !cfg['labels'].is_a?(Hash)
raise ConfigError, "Failed to load config, label values need to be strings" if cfg['labels'].values.any? { |value| !value.is_a?(String) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ConfigError, "Failed to load config, label values need to be strings" if cfg['labels'].values.any? { |value| !value.is_a?(String) }
raise ConfigError, "Failed to load config, label values need to be strings" unless cfg['labels'].values.all? { |value| value.is_a?(String) }

Minor nitpick

# @param other [Hash]
# @return [RecursiveOpenStruct]
def labels(other = {})
hash = @labels.dup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick:

dup + merge! could just be @labels.merge(other)

@kke kke merged commit 2dbe47f into master Sep 30, 2019
@kke kke deleted the feature/custom-labels branch September 30, 2019 05:15
@kke kke mentioned this pull request Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants