Skip to content

Commit

Permalink
SUP-1996: Fix infinite drift with Team Description (#531)
Browse files Browse the repository at this point in the history
* fix: remove pointer markup for Team description so it can be computed as a String and match GraphQL response when attribute not set

* fix: change Team description data type to String, to match GraphQL responses

* fix: update functions for Team description as now a String data type

* feat/fix: set default Team Description value to an empty string, matching GraphQL response values when not configured

* fix: change Team description data type to String, to match GraphQL responses
  • Loading branch information
tomowatt authored May 28, 2024
1 parent d6da400 commit ac21eb0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions buildkite/data_source_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func updateTeamDatasourceStateFromSlug(state *teamDatasourceModel, data GetTeamF
state.Slug = types.StringValue(data.Team.TeamFields.Slug)
state.Name = types.StringValue(data.Team.TeamFields.Name)
state.Privacy = types.StringValue(data.Team.TeamFields.Privacy)
state.Description = types.StringPointerValue(data.Team.TeamFields.Description)
state.Description = types.StringValue(data.Team.TeamFields.Description)
state.IsDefaultTeam = types.BoolValue(data.Team.TeamFields.IsDefaultTeam)
state.DefaultMemberRole = types.StringValue(data.Team.TeamFields.DefaultMemberRole)
state.MembersCanCreatePipelines = types.BoolValue(data.Team.TeamFields.MembersCanCreatePipelines)
Expand All @@ -160,7 +160,7 @@ func updateTeamDatasourceState(state *teamDatasourceModel, data getNodeNodeTeam)
state.Slug = types.StringValue(data.Slug)
state.Name = types.StringValue(data.Name)
state.Privacy = types.StringValue(string(data.GetPrivacy()))
state.Description = types.StringPointerValue(data.Description)
state.Description = types.StringValue(data.Description)
state.IsDefaultTeam = types.BoolValue(data.IsDefaultTeam)
state.DefaultMemberRole = types.StringValue(string(data.GetDefaultMemberRole()))
state.MembersCanCreatePipelines = types.BoolValue(data.MembersCanCreatePipelines)
Expand Down
56 changes: 28 additions & 28 deletions buildkite/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions buildkite/graphql/team.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ fragment TeamFields on Team {
id
uuid
name
# @genqlient(pointer: true)
description
slug
privacy
Expand All @@ -20,7 +19,6 @@ query GetTeamFromSlug($slug: ID!){
mutation teamCreate(
$organizationID: ID!
$name: String!
# @genqlient(pointer: true)
$description: String
$privacy: TeamPrivacy!
$isDefaultTeam: Boolean!
Expand Down Expand Up @@ -49,7 +47,6 @@ mutation teamCreate(
mutation teamUpdate(
$id: ID!
$name: String!
# @genqlient(pointer: true)
$description: String
$privacy: TeamPrivacy!
$isDefaultTeam: Boolean!
Expand Down
9 changes: 6 additions & 3 deletions buildkite/resource_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
resource_schema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -87,6 +88,8 @@ func (t *teamResource) Schema(ctx context.Context, req resource.SchemaRequest, r
Required: true,
},
"description": resource_schema.StringAttribute{
Computed: true,
Default: stringdefault.StaticString(""),
Optional: true,
MarkdownDescription: "A description for the team. This is displayed in the Buildkite UI.",
},
Expand Down Expand Up @@ -154,7 +157,7 @@ func (t *teamResource) Create(ctx context.Context, req resource.CreateRequest, r
t.client.genqlient,
*org,
state.Name.ValueString(),
state.Description.ValueStringPointer(),
state.Description.ValueString(),
state.Privacy.ValueString(),
state.IsDefaultTeam.ValueBool(),
state.DefaultMemberRole.ValueString(),
Expand Down Expand Up @@ -259,7 +262,7 @@ func (t *teamResource) Update(ctx context.Context, req resource.UpdateRequest, r
t.client.genqlient,
state.ID.ValueString(),
plan.Name.ValueString(),
plan.Description.ValueStringPointer(),
plan.Description.ValueString(),
plan.Privacy.ValueString(),
plan.IsDefaultTeam.ValueBool(),
plan.DefaultMemberRole.ValueString(),
Expand Down Expand Up @@ -322,7 +325,7 @@ func updateTeamResourceState(state *teamResourceModel, res getNodeNodeTeam) {
state.Slug = types.StringValue(res.Slug)
state.Name = types.StringValue(res.Name)
state.Privacy = types.StringValue(string(res.GetPrivacy()))
state.Description = types.StringPointerValue(res.Description)
state.Description = types.StringValue(res.Description)
state.IsDefaultTeam = types.BoolValue(res.IsDefaultTeam)
state.DefaultMemberRole = types.StringValue(string(res.GetDefaultMemberRole()))
state.MembersCanCreatePipelines = types.BoolValue(res.MembersCanCreatePipelines)
Expand Down

0 comments on commit ac21eb0

Please sign in to comment.