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

SUP-1307 Implement Pipeline Team Resource #351

Merged
merged 74 commits into from
Aug 21, 2023

Conversation

lizrabuya
Copy link
Contributor

@lizrabuya lizrabuya commented Aug 8, 2023

PR checklist:

Tests to fix (currently skipped)

  • TestAccPipelineTeam_update

@lizrabuya lizrabuya marked this pull request as draft August 13, 2023 23:29
@jradtilbrook
Copy link
Member

I think what we need to apply to this PR now is:

  • update the team block on pipeline resource to ignore unknown teams returned from the API. This will allow people to make use of pipeline_team without it interfering with pipeline.team
  • if any existing teams in the pipeline.team block have changed or been removed, update terraform state to match
  • deprecate the team block on pipeline, referring to the pipeline_team resource instead

This means that terraform will no longer do anything about new teams it finds but that is a defacto standard for other providers and how this will work in the future once the team block is removed in favour of the separate resource

@lizrabuya lizrabuya marked this pull request as ready for review August 15, 2023 03:28
Copy link
Member

@jradtilbrook jradtilbrook left a comment

Choose a reason for hiding this comment

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

I think most tests have ExpectNonEmptyPlan: true but shouldn't have that. Terraform should create the resources and then have no plan afterwards

CHANGELOG.md Outdated Show resolved Hide resolved
buildkite/resource_pipeline_team.go Outdated Show resolved Hide resolved
tpState.AccessLevel = types.StringValue(string(tpNode.PipelineAccessLevel))
}

func findTeamInPipelineNode(client *graphql.Client, tpState *pipelineTeamResourceModel) bool {
Copy link
Member

Choose a reason for hiding this comment

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

This looks unused now. Can it be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as the issue in line 74 comment, the unused function got reverted in this commit Fix: Missing } on setPipelineModel and removed unused function blocks. I will make sure it got reverted to that.

Steps: []resource.TestStep{
{
Config: testAccPipelineTeamConfigBasic(teamName, "READ_ONLY"),
ExpectNonEmptyPlan: true,
Copy link
Member

Choose a reason for hiding this comment

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

Why does this test expect a non-empty plan? I would expect this test case to create the 3 resources and then not have any other changes to make after that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After running the tests, a terraform refresh is run, and this generates a non empty plan because the pipeline resource gets updated with the team block

Copy link
Member

Choose a reason for hiding this comment

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

Yeah thats right, but thats not what we want. We want the pipeline.team block to ignore the appearance of new teams

Steps: []resource.TestStep{
{
Config: testAccPipelineTeamConfigBasic(teamName, "BUILD_AND_READ"),
ExpectNonEmptyPlan: true,
Copy link
Member

Choose a reason for hiding this comment

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

Same with this. I'd expect an empty plan here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above reason for adding the ExpectNonEmptyPlan

},
})
}

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be good to have a test where terraform creates the pipeline_team but then its removed on the API side. To ensure that it removes it from state and plans to recreate it

@@ -581,9 +581,11 @@ func TestAccPipeline_remove_team(t *testing.T) {
// Quick check to confirm the local state is correct before we update it
resource.TestCheckResourceAttr("buildkite_pipeline.foobar", "name", "Test Pipeline foo"),
),
ImportStateVerifyIgnore: []string{"slug"},
Copy link
Member

Choose a reason for hiding this comment

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

Is this what you were talking about at the standup?

What was the error showing up? I'm wondering if there is something else going wrong here and adding this is masking it

Copy link
Contributor Author

@lizrabuya lizrabuya Aug 16, 2023

Choose a reason for hiding this comment

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

Yes, this is what we discussed during standup yesterday. Interestingly, the test no longer fails locally if I remove ImportStateVerifyIgnore. Let me revert that change.

@jradtilbrook jradtilbrook merged commit 24cf147 into main Aug 21, 2023
1 check passed
@jradtilbrook jradtilbrook deleted the SUP-1307-pipeline_team_resource branch August 21, 2023 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants