Skip to content

Commit

Permalink
Remove unneccessary VCS properties (#487)
Browse files Browse the repository at this point in the history
Signed-off-by: peterdeme <[email protected]>
  • Loading branch information
peterdeme committed Dec 13, 2023
1 parent b9d7d62 commit c196750
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 272 deletions.
78 changes: 0 additions & 78 deletions spacelift/data_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,6 @@ func dataModule() *schema.Resource {
Description: "ID of the Azure Devops integration",
Computed: true,
},
"name": {
Type: schema.TypeString,
Description: "Name of the Azure Devops integration",
Computed: true,
},
"description": {
Type: schema.TypeString,
Description: "Description of the Azure Devops integration",
Computed: true,
},
"is_default": {
Type: schema.TypeBool,
Description: "Indicates whether this is the default Azure Devops integration",
Computed: true,
},
"labels": {
Type: schema.TypeSet,
Description: "Labels of the Azure Devops integration",
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"space_id": {
Type: schema.TypeString,
Description: "ID (slug) of the space the Azure Devops integration is in",
Computed: true,
},
"project": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -129,32 +103,6 @@ func dataModule() *schema.Resource {
Description: "ID of the GitHub Enterprise application",
Computed: true,
},
"name": {
Type: schema.TypeString,
Description: "Name of the GitHub Enterprise application",
Computed: true,
},
"description": {
Type: schema.TypeString,
Description: "Description of the GitHub Enterprise application",
Computed: true,
},
"is_default": {
Type: schema.TypeBool,
Description: "Indicates whether this is the default GitHub Enterprise application",
Computed: true,
},
"labels": {
Type: schema.TypeSet,
Description: "Labels of the GitHub Enterprise application",
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"space_id": {
Type: schema.TypeString,
Description: "ID (slug) of the space the GitHub Enterprise application is in",
Computed: true,
},
},
},
},
Expand All @@ -168,32 +116,6 @@ func dataModule() *schema.Resource {
Description: "ID of the Gitlab integration",
Computed: true,
},
"name": {
Type: schema.TypeString,
Description: "Name of the Gitlab integration",
Computed: true,
},
"description": {
Type: schema.TypeString,
Description: "Description of the Gitlab integration",
Computed: true,
},
"is_default": {
Type: schema.TypeBool,
Description: "Indicates whether this is the default Gitlab integration",
Computed: true,
},
"labels": {
Type: schema.TypeSet,
Description: "Labels of the Gitlab integration",
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"space_id": {
Type: schema.TypeString,
Description: "ID (slug) of the space the Gitlab integration is in",
Computed: true,
},
"namespace": {
Type: schema.TypeString,
Description: "GitLab namespace of the repository",
Expand Down
78 changes: 0 additions & 78 deletions spacelift/data_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,32 +108,6 @@ func dataStack() *schema.Resource {
Description: "ID of the Azure Devops project",
Computed: true,
},
"name": {
Type: schema.TypeString,
Description: "Name of the Azure Devops project",
Computed: true,
},
"description": {
Type: schema.TypeString,
Description: "Description of the Azure Devops project",
Computed: true,
},
"is_default": {
Type: schema.TypeBool,
Description: "Indicates whether this is the default Azure Devops project",
Computed: true,
},
"labels": {
Type: schema.TypeSet,
Description: "Labels of the Azure Devops project",
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"space_id": {
Type: schema.TypeString,
Description: "ID (slug) of the space the Azure Devops project is in",
Computed: true,
},
"project": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -255,32 +229,6 @@ func dataStack() *schema.Resource {
Description: "ID of the GitHub Enterprise application",
Computed: true,
},
"name": {
Type: schema.TypeString,
Description: "Name of the GitHub Enterprise application",
Computed: true,
},
"description": {
Type: schema.TypeString,
Description: "Description of the GitHub Enterprise application",
Computed: true,
},
"is_default": {
Type: schema.TypeBool,
Description: "Indicates whether this is the default GitHub Enterprise application",
Computed: true,
},
"labels": {
Type: schema.TypeSet,
Description: "Labels of the GitHub Enterprise application",
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"space_id": {
Type: schema.TypeString,
Description: "ID (slug) of the space the GitHub Enterprise application is in",
Computed: true,
},
"namespace": {
Type: schema.TypeString,
Description: "GitHub Enterprise namespace of the stack's repository",
Expand All @@ -300,32 +248,6 @@ func dataStack() *schema.Resource {
Description: "ID of the Gitlab integration",
Computed: true,
},
"name": {
Type: schema.TypeString,
Description: "Name of the Gitlab integration",
Computed: true,
},
"description": {
Type: schema.TypeString,
Description: "Description of the Gitlab integration",
Computed: true,
},
"is_default": {
Type: schema.TypeBool,
Description: "Indicates whether this is the default Gitlab integration",
Computed: true,
},
"labels": {
Type: schema.TypeSet,
Description: "Labels of the Gitlab integration",
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"space_id": {
Type: schema.TypeString,
Description: "ID (slug) of the space the Gitlab integration is in",
Computed: true,
},
"namespace": {
Type: schema.TypeString,
Description: "GitLab namespace of the stack's repository",
Expand Down
35 changes: 1 addition & 34 deletions spacelift/internal/structs/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ type Module struct {
Space string `graphql:"space"`
TerraformProvider string `graphql:"terraformProvider"`
VCSIntegration *struct {
ID string `graphql:"id"`
Description string `graphql:"description"`
IsDefault bool `graphql:"isDefault"`
Labels []string `graphql:"labels"`
Name string `graphql:"name"`
Provider string `graphql:"provider"`
Space struct {
ID string `graphql:"id"`
} `graphql:"space"`
ID string `graphql:"id"`
} `graphql:"vcsIntegration"`
WorkerPool *struct {
ID string `graphql:"id"`
Expand All @@ -48,11 +40,6 @@ func (m *Module) ExportVCSSettings(d *schema.ResourceData) error {
switch m.Provider {
case VCSProviderAzureDevOps:
vcsSettings["id"] = m.VCSIntegration.ID
vcsSettings["name"] = m.VCSIntegration.Name
vcsSettings["description"] = m.VCSIntegration.Description
vcsSettings["is_default"] = m.VCSIntegration.IsDefault
vcsSettings["labels"] = populateLabels(m.VCSIntegration.Labels)
vcsSettings["space_id"] = m.VCSIntegration.Space.ID
vcsSettings["project"] = m.Namespace
fieldName = "azure_devops"
case VCSProviderBitbucketCloud:
Expand All @@ -63,20 +50,10 @@ func (m *Module) ExportVCSSettings(d *schema.ResourceData) error {
fieldName = "bitbucket_datacenter"
case VCSProviderGitHubEnterprise:
vcsSettings["id"] = m.VCSIntegration.ID
vcsSettings["name"] = m.VCSIntegration.Name
vcsSettings["description"] = m.VCSIntegration.Description
vcsSettings["is_default"] = m.VCSIntegration.IsDefault
vcsSettings["labels"] = populateLabels(m.VCSIntegration.Labels)
vcsSettings["space_id"] = m.VCSIntegration.Space.ID
vcsSettings["namespace"] = m.Namespace
fieldName = "github_enterprise"
case VCSProviderGitlab:
vcsSettings["id"] = m.VCSIntegration.ID
vcsSettings["name"] = m.VCSIntegration.Name
vcsSettings["description"] = m.VCSIntegration.Description
vcsSettings["is_default"] = m.VCSIntegration.IsDefault
vcsSettings["labels"] = populateLabels(m.VCSIntegration.Labels)
vcsSettings["space_id"] = m.VCSIntegration.Space.ID
vcsSettings["namespace"] = m.Namespace
fieldName = "gitlab"
}
Expand All @@ -89,13 +66,3 @@ func (m *Module) ExportVCSSettings(d *schema.ResourceData) error {

return nil
}

func populateLabels(labels []string) *schema.Set {
retVal := schema.NewSet(schema.HashString, []interface{}{})

for _, label := range labels {
retVal.Add(label)
}

return retVal
}
37 changes: 7 additions & 30 deletions spacelift/internal/structs/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,7 @@ type Stack struct {
Space string `graphql:"space"`
TerraformVersion *string `graphql:"terraformVersion"`
VCSIntegration *struct {
ID string `graphql:"id"`
Description string `graphql:"description"`
IsDefault bool `graphql:"isDefault"`
Labels []string `graphql:"labels"`
Name string `graphql:"name"`
Provider string `graphql:"provider"`
Space struct {
ID string `graphql:"id"`
} `graphql:"space"`
ID string `graphql:"id"`
} `graphql:"vcsIntegration"`
VendorConfig struct {
Typename string `graphql:"__typename"`
Expand Down Expand Up @@ -143,37 +135,22 @@ func (s *Stack) VCSSettings() (string, map[string]interface{}) {
switch s.Provider {
case VCSProviderAzureDevOps:
return "azure_devops", map[string]interface{}{
"id": s.VCSIntegration.ID,
"name": s.VCSIntegration.Name,
"description": s.VCSIntegration.Description,
"is_default": s.VCSIntegration.IsDefault,
"labels": s.VCSIntegration.Labels,
"space_id": s.VCSIntegration.Space.ID,
"project": s.Namespace,
"id": s.VCSIntegration.ID,
"project": s.Namespace,
}
case VCSProviderBitbucketCloud:
return "bitbucket_cloud", singleKeyMap("namespace", s.Namespace)
case VCSProviderBitbucketDatacenter:
return "bitbucket_datacenter", singleKeyMap("namespace", s.Namespace)
case VCSProviderGitHubEnterprise:
return "github_enterprise", map[string]interface{}{
"id": s.VCSIntegration.ID,
"name": s.VCSIntegration.Name,
"namespace": s.Namespace,
"description": s.VCSIntegration.Description,
"is_default": s.VCSIntegration.IsDefault,
"labels": s.VCSIntegration.Labels,
"space_id": s.VCSIntegration.Space.ID,
"id": s.VCSIntegration.ID,
"namespace": s.Namespace,
}
case VCSProviderGitlab:
return "gitlab", map[string]interface{}{
"id": s.VCSIntegration.ID,
"name": s.VCSIntegration.Name,
"namespace": s.Namespace,
"description": s.VCSIntegration.Description,
"is_default": s.VCSIntegration.IsDefault,
"labels": s.VCSIntegration.Labels,
"space_id": s.VCSIntegration.Space.ID,
"id": s.VCSIntegration.ID,
"namespace": s.Namespace,
}
case VCSProviderRawGit:
return "raw_git", map[string]interface{}{
Expand Down
52 changes: 0 additions & 52 deletions spacelift/resource_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,6 @@ func resourceModule() *schema.Resource {
Description: "ID of the Azure Devops integration. If not specified, the default integration will be used.",
Optional: true,
},
"name": {
Type: schema.TypeString,
Description: "Name of the Azure Devops integration",
Computed: true,
},
"description": {
Type: schema.TypeString,
Description: "Description of the Azure Devops integration",
Computed: true,
},
"is_default": {
Type: schema.TypeBool,
Description: "Indicates whether this is the default Azure Devops integration",
Computed: true,
},
"labels": {
Type: schema.TypeSet,
Description: "Labels of the Azure Devops integration",
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"space_id": {
Type: schema.TypeString,
Description: "ID (slug) of the space the Azure Devops integration is in",
Computed: true,
},
"project": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -174,32 +148,6 @@ func resourceModule() *schema.Resource {
Description: "ID of the Gitlab integration. If not specified, the default integration will be used.",
Optional: true,
},
"name": {
Type: schema.TypeString,
Description: "Name of the Gitlab integration",
Computed: true,
},
"description": {
Type: schema.TypeString,
Description: "Description of the Gitlab integration",
Computed: true,
},
"is_default": {
Type: schema.TypeBool,
Description: "Indicates whether this is the default Gitlab integration",
Computed: true,
},
"labels": {
Type: schema.TypeSet,
Description: "Labels of the Gitlab integration",
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"space_id": {
Type: schema.TypeString,
Description: "ID (slug) of the space the Gitlab integration is in",
Computed: true,
},
"namespace": {
Type: schema.TypeString,
Required: true,
Expand Down

0 comments on commit c196750

Please sign in to comment.