Skip to content
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

Simplify configuration #149

Merged
merged 11 commits into from Apr 21, 2022
Merged

Simplify configuration #149

merged 11 commits into from Apr 21, 2022

Conversation

iwahbe
Copy link
Member

@iwahbe iwahbe commented Apr 15, 2022

Implement the simplified configuration as described in #143 with the following caveat:
To ensure we call the right config.Try* function, type information needs to be available for config values.
Type information can be derived from the default value, if available, but if no default value is supplied then the type field is required.

If/When we add program level type checking, we can relax the required for type to be supplied.

Fixes #143

Depends on pulumi/pulumi#9407.

  • Make sure to use the ENV variable to correctly call pulumi.ToSecret on config items marked secret.
  • Add back the Secret option

@iwahbe iwahbe requested a review from AaronFriel April 15, 2022 14:46
@iwahbe iwahbe self-assigned this Apr 15, 2022
@iwahbe iwahbe added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Apr 15, 2022
@AaronFriel
Copy link
Member

Interesting - acceptance test failures.

Copy link
Member

@AaronFriel AaronFriel left a comment

Choose a reason for hiding this comment

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

Test failures on running the integration tests. Looks like something happened with asset conversion?

@iwahbe
Copy link
Member Author

iwahbe commented Apr 19, 2022

The test failures are from updating the version of pulumi/pulumi being pointed to. This includes an update to programgen. I'll have an updated test suite soon.

@iwahbe iwahbe requested a review from AaronFriel April 19, 2022 12:54
This means:
- Retrieve a type as secret when it is secret in the config
- Mark a type secret when it is marked as secret in configuration
permissions="r",
canonicalized_resource=pulumi.Output.all(sa.name, container.name).apply(lambda saName, containerName: f"/blob/{sa_name}/{container_name}"),
canonicalized_resource=f"/blob/{sa_name1}/{container_name}",
Copy link
Member

Choose a reason for hiding this comment

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

This variable name isn't declared/assigned to, looks like a regression.

Funnily enough, the diff highlights that this didn't work before, either. It just also doesn't work after.

ConfigString configType = "String"
ConfigNumber configType = "Number"
ConfigListNumber configType = "List<Number>"
ConfigListString configType = "List<String>"
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we should do this validation at all. If we evaluate config as an expression and not a string to be parsed, it can be anything, string, number, bool, array, object.

func (ctx *evalContext) registerConfig(intm configNode) (interface{}, bool) {
k, c := intm.Key.Value, intm.Value

// If we implement global type checking, the type of configuration variables
// can be inferred and this requirement relaxed.
Copy link
Member

Choose a reason for hiding this comment

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

Ah

Copy link
Member

@AaronFriel AaronFriel left a comment

Choose a reason for hiding this comment

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

Looks good to me. Can you create an issue to track the nested interpolate expression in pulumi/pulumi.

The blocker for inferring configuration types in toto is the lack of global type checking and tracking types, yeah?

@iwahbe
Copy link
Member Author

iwahbe commented Apr 21, 2022

Looks good to me. Can you create an issue to track the nested interpolate expression in pulumi/pulumi.

The blocker for inferring configuration types in toto is the lack of global type checking and tracking types, yeah?

Issue created: pulumi/pulumi#9445

I see two problems that lead to a non-ideal configuration experience. Both related to typing. Config values must be typed, so we know what config.Try* function to call.

  1. Because of the lack of global type analysis, we can't infer what type a config value should be. This requires a type field to allow the user to specify the type. Such a field would not be necessary if would could infer the type of the config value from where the value is used. I added local type analysis on the default value, so if a default value is supplied then we can infer the type of the configuration value. To obviate the need for the type field where a default value is not desired would require global type checking and unification.
  2. We don't have a sufficiently expressive language to describe types. In an ideal world, our users would be able to specify
configuration:
  persons:
    type:
      Map:
        key: String
        value: 
          Object:
            name: String
            age: Number

We could then infer that { "person1": { "name": "me", "age": 42 } } is valid for persons but [ { "name": "me", "age": 42 } ] is not.

I hope that (2) can be implemented as an extension of our hierarchical config work.

@iwahbe iwahbe merged commit e6f014e into main Apr 21, 2022
@iwahbe iwahbe deleted the iwahbe/143/simplify-configuration branch April 21, 2022 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/no-changelog-required This issue doesn't require a CHANGELOG update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify configuration key
2 participants