Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Overrides via command line parameters #42

Merged
merged 2 commits into from
Jun 12, 2023
Merged

Overrides via command line parameters #42

merged 2 commits into from
Jun 12, 2023

Conversation

ghen
Copy link
Contributor

@ghen ghen commented Jun 8, 2023

Overrides via command line parameters

Description
Allows users to override individual properties via command line arguments.

For example:

# Overrides the image for a container
score-humanitec run -f example-score.yaml -p containers.hello.image=hello:1.1

# Removes the property completely
score-humanitec run -f example-score.yaml -p metadata.some-property=

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • New chore (expected functionality to be implemented)

Checklist:

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I've signed off with an email address that matches the commit author.

Signed-off-by: Eugene Yarshevich <yarshevich@gmail.com>
@ghen ghen linked an issue Jun 8, 2023 that may be closed by this pull request
// "false" -> string
// abc -> string
// "abc" -> string
func TryParseJsonValue(str string) interface{} {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be better to just use a YAML parser here? There are some other ways strings can be created. For example using '. This is handy to allow for shell quotes. You would also get the ability to add objects etc which could also be useful.
We are outputting a YAML file so YAML input makes sense. Also: YAML is a superset of JSON, so JSON objects work as YAML objects too.

Parse float is also probably not sufficient as YAML supports man ways of expressing numbers: https://yaml.org/spec/1.2.2/#24-tags

Also this does not check for invalid strings:

  • "hello
    Also would break some valid strings:
  • `"this string has a trailing escaped quote ""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to yaml.Decode(..)

Signed-off-by: Eugene Yarshevich <yarshevich@gmail.com>
@ghen ghen requested a review from chrishumanitec June 9, 2023 12:43
Copy link
Contributor

@chrishumanitec chrishumanitec left a comment

Choose a reason for hiding this comment

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

LGTM

@ghen ghen merged commit 9b232c0 into main Jun 12, 2023
@ghen ghen deleted the feature/overrides branch June 12, 2023 13:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for a Score overrides flags
2 participants