-
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
Support structured config #516
Conversation
PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting. |
/run-acceptance-tests |
Please view the PR build - https://github.com/pulumi/pulumi-kubernetes-operator/actions/runs/6802683612 |
Any updates? it would help us if this feature will be implemented. |
Hi friends, any news about it? |
pkg/controller/stack/stack_config.go
Outdated
return nil, err | ||
} | ||
|
||
configValues := make([]ConfigKeyValue, 0) |
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: I since we're already using make()
, let's provide a capacity, eg. make([]ConfigKeyValue, 0, len(flatten))
test/stale_state_test.go
Outdated
"password": randString(), | ||
"port": rabbitPort, | ||
"secretName": credsSecretName, | ||
setupStack.Spec.Config = map[string]v1.JSON{ |
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.
It would be nice to see some tests that exercise a structured config as well.
@@ -45,7 +45,7 @@ type StackSpec struct { | |||
Stack string `json:"stack"` | |||
// (optional) Config is the configuration for this stack, which can be optionally specified inline. If this | |||
// is omitted, configuration is assumed to be checked in and taken from the source repository. | |||
Config map[string]string `json:"config,omitempty"` | |||
Config map[string]apiextensionsv1.JSON `json:"config,omitempty"` |
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.
I'm somewhat apprehensive of switching this type even though existing strings should be compatible with this. Is it possible to maintain the map[string]string
type, and do custom parsing/marshaling ourselves instead? I understand that this might make it slightly more difficult in terms of defining the structured config as it now has to be a scalar/string literal json representation rather than a yaml object I believe. WDYT?
@ljtfreitas I apologize for the delay in reviewing this. Unfortunately, it fell off my radar and got lost in my GitHub notifications. I've provided some feedback, and overall, I believe this is a promising direction that we should push to completion soon to resolve a crucial user journey. My main concern lies with the type change and its potential downstream implications. As a user of this feature, what are your thoughts on keeping the type as a string? The structured config could still be represented as a string literal of the desired JSON configuration. While this may introduce some additional friction, I am inclined to maintain consistency with our CRD spec. WDYT? |
Hi @rquitales , don't worry. About the question, yes, moving from Maybe the approach using a new field, which I've suggested as apiVersion: pulumi.com/v1
kind: Stack
metadata:
name: my-stack
spec:
configRefs:
aws:
type: structured
value:
region: us-east-1
assumeRole:
roleArn: my-role-arn
sessionName: my-assumed-session-name
my-key:
type: literal
value: my-value
my-list:
type: structured
value: [a, b, c] The current implementation of this pull request would generate these config values:
(actually I need to write a test to be sure about it 😅. but it's the idea). Looking now the WDYT? Maybe introducing a new field could be a better path? |
Regarding the API changes, I believe we need to ensure that we're following the rules of CRD schemas (ref). In particular, the list of configuration properties should be expressed as a list (with a merge key), not as a map. |
Sorry, not sure if I understood @EronWright . I don't get how passing config as a map would violate CRD rules. Anyway, sounds better to create a new field for structured config in order to don't break the current API. I can keep working on that (my second suggestion is about it) and refining the implementation, if you folks agree. |
PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting. |
c78472f
to
d637e40
Compare
PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting. |
PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting. |
1 similar comment
PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting. |
a25d8d6
to
689af8d
Compare
PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting. |
689af8d
to
483bec5
Compare
PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting. |
Hi @rquitales @EronWright , sorry for the delay. I rethink some things about the concerns and opened a new pull request: #575 |
Context
Currently structured configs are not supported properly by Pulumi k8s operator.
As Pulumi programs can be configured using yaml files, it looks fair to be able to configure a structured, complex config using the Stack CRD as well.
Proposed changes
This PR proposes two approaches to support structured config:
makes the
config
field support a JSON as valueIt could be useful to keep compatibility with older versions. Declaring the
config
field as amap[string]apiextensionsv1.JSON
, existing support to inline fields keeps working (asaws:region: whatever
) and expanding the config to a more complex object also works.To make this work with Pulumi Automation API, in case the value is a json, the same rules used by Pulumi CLI to handle structured configs are applied. The implementation flattens all object keys to generate Pulumi-CLI compatible key names. For example:
it will generate these config keys/values:
and all those keys are send through Automation API as
Path: true
adds a new field
configRefs
adds to CRD a new field called
configRefs
, that works in a similar way thatEnvRefs
orSecretRefs
, adding two new possible values:configmap
andstructured
configmap
adds support to read a K8s ConfigMap and get a specific key to use as a config valuestructured
is a JSON value that can be used to pass a structured configuration, following the same previous pattern from theconfig
field.integration tests
I was not able to make the tests pass in my local environment but right now it's just an initial implementation proposal. I can keep working on that if you people think is worth it.
Related issues (optional)
#258