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

Feat: add support for variable set assignment resource #870

Merged
merged 6 commits into from
Jun 4, 2024

Conversation

TomerHeber
Copy link
Collaborator

@TomerHeber TomerHeber commented Jun 3, 2024

Issue & Steps to Reproduce / Feature Request

Part of #829

Solution

  1. Added the assignment resource.
  2. Added an API call.
  3. Added unit tests.
  4. Added acceptance tests.
  5. Added integration tests.
  6. Updated examples.

@sagilaufer1992
Copy link
Contributor

there are usages of both variable and configuration sets. can we make use of a single term? preferably the one used for single variables

Copy link
Contributor

@sagilaufer1992 sagilaufer1992 left a comment

Choose a reason for hiding this comment

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

looks great, left some comments

Schema: map[string]*schema.Schema{
"scope": {
Type: schema.TypeString,
Description: "the resource(scope) type to assign to. Valid values: 'template', 'environment', 'workflow', 'organization', 'project'",
Copy link
Contributor

Choose a reason for hiding this comment

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

the allowed values are: organization, project, template, module, environment, deployment
https://docs.env0.com/reference/configuration-find-set-assignments-by-scope see what the assignmentScope is allowed to be.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thank you. will fix.


newSchemaSetIds := []string{}

// To avoid drifts keep the schema order as much as possible.
Copy link
Contributor

Choose a reason for hiding this comment

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

if that functionality prevents drift, can we add a test that drifts won't occur?
something like:

  • set some assignments in the state
  • mock that all return from api in addition to new ones
  • see the order is kept as expected

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes. This PR is still work in progress. I will definitely add such a test.

@TomerHeber
Copy link
Collaborator Author

there are usages of both variable and configuration sets. can we make use of a single term? preferably the one used for single variables

yeah for the printing of messages. Sure thing.

@TomerHeber
Copy link
Collaborator Author

looks great, left some comments

@sagilaufer1992 - thanks!
This is still work in progress. I will add the rest today.

Copy link
Contributor

@sagilaufer1992 sagilaufer1992 left a comment

Choose a reason for hiding this comment

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

LGTM
requested to update the integration test to make sure the expected outcome is achieved, not just alter the resource

resource "env0_variable_set_assignment" "assignment" {
scope = "project"
scope_id = env0_project.project.id
set_ids = var.second_run ? [env0_variable_set.org_scope.id] : [env0_variable_set.project_scope.id]
Copy link
Contributor

Choose a reason for hiding this comment

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

the test seems a bit missing... can we check the outcome of that? using output or some other method, to see that the assignment doesn't exist on the org after the second run, and exists where it should after on each run?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is tested in the acceptance tests.
The integration tests are limited in their functionality and are more of a sanity just to make sure things really work...
I don't think there's an easy way to test what you're asking with the current integration tests... /:

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright. As long as there is a test for it

@github-actions github-actions bot added ready to merge PR approved - can be merged once the PR owner is ready and removed pending final review labels Jun 4, 2024
@TomerHeber TomerHeber merged commit c9b6370 into main Jun 4, 2024
4 checks passed
@TomerHeber TomerHeber deleted the feat-variable-set-assignment-#829 branch June 4, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants