diff --git a/spacelift/internal/structs/stack.go b/spacelift/internal/structs/stack.go index eb4b70de..358787a6 100644 --- a/spacelift/internal/structs/stack.go +++ b/spacelift/internal/structs/stack.go @@ -136,18 +136,21 @@ func (s *Stack) VCSSettings() (string, map[string]interface{}) { switch s.Provider { case VCSProviderAzureDevOps: return "azure_devops", map[string]interface{}{ - "id": s.VCSIntegration.ID, - "project": s.Namespace, + "id": s.VCSIntegration.ID, + "project": s.Namespace, + "is_default": s.VCSIntegration.IsDefault, } case VCSProviderBitbucketCloud: return "bitbucket_cloud", map[string]interface{}{ - "id": s.VCSIntegration.ID, - "namespace": s.Namespace, + "id": s.VCSIntegration.ID, + "namespace": s.Namespace, + "is_default": s.VCSIntegration.IsDefault, } case VCSProviderBitbucketDatacenter: return "bitbucket_datacenter", map[string]interface{}{ - "id": s.VCSIntegration.ID, - "namespace": s.Namespace, + "id": s.VCSIntegration.ID, + "namespace": s.Namespace, + "is_default": s.VCSIntegration.IsDefault, } case VCSProviderGitHubEnterprise: return "github_enterprise", map[string]interface{}{ @@ -157,8 +160,9 @@ func (s *Stack) VCSSettings() (string, map[string]interface{}) { } case VCSProviderGitlab: return "gitlab", map[string]interface{}{ - "id": s.VCSIntegration.ID, - "namespace": s.Namespace, + "id": s.VCSIntegration.ID, + "namespace": s.Namespace, + "is_default": s.VCSIntegration.IsDefault, } case VCSProviderRawGit: return "raw_git", map[string]interface{}{ diff --git a/spacelift/resource_stack.go b/spacelift/resource_stack.go index 0b20a571..9bbce877 100644 --- a/spacelift/resource_stack.go +++ b/spacelift/resource_stack.go @@ -141,6 +141,11 @@ func resourceStack() *schema.Resource { Type: schema.TypeString, Optional: true, Description: "The ID of the Azure Devops integration. If not specified, the default integration will be used.", + DiffSuppressFunc: func(_, _, new string, res *schema.ResourceData) bool { + isDefault := res.Get("azure_devops.0.is_default").(bool) + + return isDefault && new == "" + }, }, "project": { Type: schema.TypeString, @@ -148,6 +153,11 @@ func resourceStack() *schema.Resource { Description: "The name of the Azure DevOps project", ValidateDiagFunc: validations.DisallowEmptyString, }, + "is_default": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether this is the default Azure DevOps integration", + }, }, }, }, @@ -214,6 +224,11 @@ func resourceStack() *schema.Resource { Type: schema.TypeString, Optional: true, Description: "The ID of the Bitbucket Cloud integration. If not specified, the default integration will be used.", + DiffSuppressFunc: func(_, _, new string, res *schema.ResourceData) bool { + isDefault := res.Get("bitbucket_cloud.0.is_default").(bool) + + return isDefault && new == "" + }, }, "namespace": { Type: schema.TypeString, @@ -221,6 +236,11 @@ func resourceStack() *schema.Resource { Description: "The Bitbucket project containing the repository", ValidateDiagFunc: validations.DisallowEmptyString, }, + "is_default": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether this is the default Bitbucket Cloud integration", + }, }, }, }, @@ -236,6 +256,11 @@ func resourceStack() *schema.Resource { Type: schema.TypeString, Optional: true, Description: "The ID of the Bitbucket Datacenter integration. If not specified, the default integration will be used.", + DiffSuppressFunc: func(_, _, new string, res *schema.ResourceData) bool { + isDefault := res.Get("bitbucket_datacenter.0.is_default").(bool) + + return isDefault && new == "" + }, }, "namespace": { Type: schema.TypeString, @@ -243,6 +268,11 @@ func resourceStack() *schema.Resource { Description: "The Bitbucket project containing the repository", ValidateDiagFunc: validations.DisallowEmptyString, }, + "is_default": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether this is the default Bitbucket Datacenter integration", + }, }, }, }, @@ -342,6 +372,11 @@ func resourceStack() *schema.Resource { Type: schema.TypeString, Optional: true, Description: "The ID of the Gitlab integration. If not specified, the default integration will be used.", + DiffSuppressFunc: func(_, _, new string, res *schema.ResourceData) bool { + isDefault := res.Get("gitlab.0.is_default").(bool) + + return isDefault && new == "" + }, }, "namespace": { Type: schema.TypeString, @@ -349,6 +384,11 @@ func resourceStack() *schema.Resource { Description: "The GitLab namespace containing the repository", ValidateDiagFunc: validations.DisallowEmptyString, }, + "is_default": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether this is the default GitLab integration", + }, }, }, },