Skip to content

Commit

Permalink
Check is_default when calculating id diff for stack vcs setting
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMacies committed Feb 6, 2024
1 parent fa45049 commit 69dee53
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 5 additions & 3 deletions spacelift/internal/structs/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ type Stack struct {
Space string `graphql:"space"`
TerraformVersion *string `graphql:"terraformVersion"`
VCSIntegration *struct {
ID string `graphql:"id"`
ID string `graphql:"id"`
IsDefault bool `graphql:"isDefault"`
} `graphql:"vcsIntegration"`
VendorConfig struct {
Typename string `graphql:"__typename"`
Expand Down Expand Up @@ -150,8 +151,9 @@ func (s *Stack) VCSSettings() (string, map[string]interface{}) {
}
case VCSProviderGitHubEnterprise:
return "github_enterprise", map[string]interface{}{
"id": s.VCSIntegration.ID,
"namespace": s.Namespace,
"id": s.VCSIntegration.ID,
"namespace": s.Namespace,
"is_default": s.VCSIntegration.IsDefault,
}
case VCSProviderGitlab:
return "gitlab", map[string]interface{}{
Expand Down
10 changes: 10 additions & 0 deletions spacelift/resource_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ func resourceStack() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Description: "The ID of the GitHub Enterprise integration. If not specified, the default integration will be used.",
DiffSuppressFunc: func(_, _, new string, res *schema.ResourceData) bool {
isDefault := res.Get("github_enterprise.0.is_default").(bool)

return isDefault && new == ""
},
},
"is_default": {
Type: schema.TypeBool,
Computed: true,
Description: "Indicates whether this is the default GitHub Enterprise integration",
},
},
},
Expand Down

0 comments on commit 69dee53

Please sign in to comment.