-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
@jnummelin should custom labels be also configurable via shot.yml? |
Definitely yes. |
@jnummelin PTAL |
@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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
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)
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