-
Notifications
You must be signed in to change notification settings - Fork 32
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
[go] parse environment variables #505
Conversation
// Marshal back here just so we can populate the env vars without any yaml comments present | ||
data, _ = yaml.Marshal(courseFile) | ||
data, err = parseEnv(data) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to parse env variables: %v", err) | ||
} | ||
err = yaml.Unmarshal(data, courseFile) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to unmarshal file after parsing env vars: %s", err.Error()) | ||
} | ||
|
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.
The reason we are doing this unmarshal -> marshal -> unmarshal again is because if we parsed environment variables before the first unmarshal, it would also error out on any YAML comments that mention an environment variable. When we do the first unmarshal, all comments are stripped so we can marshal back to bytes, populate all the env vars and then unmarshal into our struct again.
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.
That's actually really cool. That was fairly annoying in the python version at one point.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Also changed in this PR:
reckoner convert
command no longer calls the ConvertV1toV2 function and instead simply uses OpenV2 function.