-
Notifications
You must be signed in to change notification settings - Fork 0
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
Ability to use ESC environments with tests #116
Comments
This would be great to flesh out with some example use-cases, perhaps with some ideal example code. Currently, I'd assume that any cloud configuration would be set up external to the test execution rather than depending on access to a specific environment within the test itself. For example you might run the pulumitest via the command: esc run myorg/myproject/test go test ... |
Tested @danielrbradley's solution and it worked great. Feel free to close, I can't add the labels that pulumi-bot wants. |
I’ve reopened this because I think this should be two easy pieces to use together. The behaviour we’d like to achieve is:
This would enable the use cases of:
A dumb version of the code that could be written in a test helper to do this could look like: // Prefer local env, but fallback to pulumi env if accessible.
azureDevopsToken, found := os.LookupEnv("AZDO_PERSONAL_ACCESS_TOKEN")
if !found {
t.Log("AZDO_PERSONAL_ACCESS_TOKEN not found, attempting to load from pulumi env")
client := esc.NewClient() // Use the default config like the CLI - using any available credentials.
if client.IsAuthenticated() {
env, _, err := client.GetEnvironment(context.Background(), "pulumi", "providers", "azuredevops")
require.NoError(t, err)
values := env.GetValues()
if values.EnvironmentVariables != nil {
pulumiEnv := *env.GetValues().EnvironmentVariables
azureDevopsToken = pulumiEnv["AZDO_PERSONAL_ACCESS_TOKEN"]
}
}
} Things that are missing for this right now:
There’s definitely parts of this that should be done in the main SDK - like having sensible defaults for loading credentials. But I think it’s possibly doable within or adjacent to the pulumitest library. Something like this perhaps where the first argument is the project/env-name followed by the required variables for this provider: pt := pulumitest.NewPulumiTest(t, path.Join("test-programs", "my-test"),
opttest.RequireEnv("providers/azuredevops", "AZDO_PERSONAL_ACCESS_TOKEN", "AZDO_ORG_SERVICE_URL")) |
Hello!
Issue details
I would love the ability to use esc environments with pulumitest. This would allow me to use the current environments I have for AWS/Azure/Google and not manage env-vars.
Affected area/feature
The text was updated successfully, but these errors were encountered: