-
Notifications
You must be signed in to change notification settings - Fork 56
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
Make environment variable population more generic #125
Conversation
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.
Looks great. One question naming.
"aws:region": "us-east-2", | ||
}, | ||
Stack: stackName, | ||
ProjectRepo: "https://github.com/metral/test-s3-op-project", // TODO: relocate to some other repo |
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.
This is a reminder - we should probably open an issue to track migrating these test cases to a Pulumi repo.
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.
Agreed. Cut #126 to track this.
deploy/crds/pulumi.com_stacks.yaml
Outdated
@@ -57,6 +57,11 @@ spec: | |||
items: | |||
type: string | |||
type: array | |||
envSecretsFromPath: |
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.
These are strictly secrets, are they? In the sense that the other uses of these he word Secret
here are about K8s Secret
objects.
Are there other precedents for naming for things like this in other operators we could model after? Not sure if this pattern has common terminology associated with it?
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.
Fair point. I was positioning this as an alternative to envSecrets
. It can just be called envFromPath
instead.
I was also wondering if it makes sense to take a slightly different tack on this by modeling things as a reference instead. For instance for #97 I can foresee us wanting to support literal, secret reference, environment variable or a file as well and could reuse the same model. As a result I am proposing adding a ResourceRef
type. Other operators seem to take a similar approach.
Update - I have switched to this model so the result is a bit more generic and reusable.
deploy/crds/pulumi.com_stacks.yaml
Outdated
type: string | ||
required: | ||
- name | ||
- namespace |
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.
Seems like namespace
could be optional.
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.
Fixed.
|
||
// ResourceRef identifies a resource from which information can be loaded. | ||
type ResourceRef struct { | ||
// SelectorType is required and signifies the type of selector. Should be one of: |
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.
// SelectorType is required and signifies the type of selector. Should be one of: | |
// SelectorType is required and signifies the type of selector. Must be one of: |
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.
Fixed.
@lukehoban @lblackstone sorry for the noise. Could you take another look? I went ahead with the approach I proposed in #125 (comment) |
} else { | ||
return errors.Errorf("Mising secret reference in ResourceRef for '%s'", envVar) | ||
} | ||
} |
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.
Should add a default case that returns error just to be safe.
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.
Agreed, updated.
envVarVal := os.Getenv(ref.Env.Name) | ||
w.SetEnvVar(envVar, envVarVal) | ||
} else { | ||
return errors.Errorf("Missing env reference in ResourceRef for '%s'", envVar) |
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.
nit: This syntax is slightly cleaner
return errors.Errorf("Missing env reference in ResourceRef for '%s'", envVar) | |
return errors.Errorf("Missing env reference in ResourceRef for %q", envVar) |
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.
Fixed.
test/stack_controller_test.go
Outdated
return fetched.Status.LastUpdate.LastSuccessfulCommit == stack.Spec.Commit && | ||
fetched.Status.LastUpdate.LastAttemptedCommit == stack.Spec.Commit && | ||
fetched.Status.LastUpdate.State == pulumiv1alpha1.SucceededStackStateMessage |
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.
If this is done commonly, it would be good to expose as a function. Fine for this test, if not.
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.
Done.
Fixes #122