From 9f2750973771784d11a63433a273147853c10480 Mon Sep 17 00:00:00 2001 From: isaac Date: Fri, 16 Aug 2024 11:21:44 +0930 Subject: [PATCH] Remove retention policy from project group --- octopusdeploy/schema_project_group.go | 101 ------------------ .../datasource_project_groups.go | 1 - .../resource_project_group.go | 9 +- .../schemas/project_group.go | 7 +- 4 files changed, 6 insertions(+), 112 deletions(-) delete mode 100644 octopusdeploy/schema_project_group.go diff --git a/octopusdeploy/schema_project_group.go b/octopusdeploy/schema_project_group.go deleted file mode 100644 index 52fbfe857..000000000 --- a/octopusdeploy/schema_project_group.go +++ /dev/null @@ -1,101 +0,0 @@ -package octopusdeploy - -import ( - "context" - - "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projectgroups" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func expandProjectGroup(d *schema.ResourceData) *projectgroups.ProjectGroup { - name := d.Get("name").(string) - - projectGroup := projectgroups.NewProjectGroup(name) - projectGroup.ID = d.Id() - - if v, ok := d.GetOk("description"); ok { - projectGroup.Description = v.(string) - } - - if v, ok := d.GetOk("retention_policy_id"); ok { - projectGroup.RetentionPolicyID = v.(string) - } - - if v, ok := d.GetOk("space_id"); ok { - projectGroup.SpaceID = v.(string) - } - - return projectGroup -} - -func flattenProjectGroup(projectGroup *projectgroups.ProjectGroup) map[string]interface{} { - if projectGroup == nil { - return nil - } - - return map[string]interface{}{ - "description": projectGroup.Description, - "id": projectGroup.GetID(), - "name": projectGroup.Name, - "retention_policy_id": projectGroup.RetentionPolicyID, - "space_id": projectGroup.SpaceID, - } -} - -func getProjectGroupDataSchema() map[string]*schema.Schema { - dataSchema := getProjectGroupSchema() - setDataSchema(&dataSchema) - - return map[string]*schema.Schema{ - "id": getDataSchemaID(), - "space_id": getQuerySpaceID(), - "ids": getQueryIDs(), - "partial_name": getQueryPartialName(), - "project_groups": { - Computed: true, - Description: "A list of project groups that match the filter(s).", - Elem: &schema.Resource{Schema: dataSchema}, - Optional: true, - Type: schema.TypeList, - }, - "skip": getQuerySkip(), - "take": getQueryTake(), - } -} - -func getProjectGroupSchema() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "description": { - Computed: true, - Description: "The description of this project group.", - Optional: true, - Type: schema.TypeString, - }, - "id": getIDSchema(), - "name": getNameSchema(true), - "retention_policy_id": { - Computed: true, - Description: "The ID of the retention policy associated with this project group.", - Optional: true, - Type: schema.TypeString, - }, - "space_id": { - Computed: true, - Description: "The space ID associated with this project group.", - Optional: true, - Type: schema.TypeString, - }, - } -} - -func setProjectGroup(ctx context.Context, d *schema.ResourceData, projectGroup *projectgroups.ProjectGroup) error { - d.Set("description", projectGroup.Description) - - d.Set("name", projectGroup.Name) - d.Set("retention_policy_id", projectGroup.RetentionPolicyID) - d.Set("space_id", projectGroup.SpaceID) - - d.SetId(projectGroup.GetID()) - - return nil -} diff --git a/octopusdeploy_framework/datasource_project_groups.go b/octopusdeploy_framework/datasource_project_groups.go index bca82cd2a..9ff002e7c 100644 --- a/octopusdeploy_framework/datasource_project_groups.go +++ b/octopusdeploy_framework/datasource_project_groups.go @@ -118,7 +118,6 @@ func (p *projectGroupsDataSource) Read(ctx context.Context, req datasource.ReadR g.ID = types.StringValue(projectGroup.ID) g.SpaceID = types.StringValue(projectGroup.SpaceID) g.Name = types.StringValue(projectGroup.Name) - g.RetentionPolicyID = types.StringValue(projectGroup.RetentionPolicyID) g.Description = types.StringValue(projectGroup.Description) newGroups = append(newGroups, g) } diff --git a/octopusdeploy_framework/resource_project_group.go b/octopusdeploy_framework/resource_project_group.go index 8d7a628de..2411a8d0f 100644 --- a/octopusdeploy_framework/resource_project_group.go +++ b/octopusdeploy_framework/resource_project_group.go @@ -44,10 +44,9 @@ func (r *projectGroupTypeResource) Create(ctx context.Context, req resource.Crea } newGroup := projectgroups.ProjectGroup{ - Name: data.Name.ValueString(), - Description: data.Description.ValueString(), - RetentionPolicyID: data.RetentionPolicyID.ValueString(), - SpaceID: data.SpaceID.ValueString(), + Name: data.Name.ValueString(), + Description: data.Description.ValueString(), + SpaceID: data.SpaceID.ValueString(), } group, err := projectgroups.Add(r.Config.Client, &newGroup) @@ -98,7 +97,6 @@ func (r *projectGroupTypeResource) Update(ctx context.Context, req resource.Upda group.Name = data.Name.ValueString() group.Description = data.Description.ValueString() - group.RetentionPolicyID = data.RetentionPolicyID.ValueString() group.SpaceID = data.SpaceID.ValueString() updatedProjectGroup, err := projectgroups.Update(r.Config.Client, *group) @@ -129,6 +127,5 @@ func updateProjectGroup(data *schemas.ProjectGroupTypeResourceModel, group *proj data.ID = types.StringValue(group.ID) data.Name = types.StringValue(group.Name) data.SpaceID = types.StringValue(group.SpaceID) - data.RetentionPolicyID = types.StringValue(group.RetentionPolicyID) data.Description = types.StringValue(group.Description) } diff --git a/octopusdeploy_framework/schemas/project_group.go b/octopusdeploy_framework/schemas/project_group.go index 27b42acfd..25406e96e 100644 --- a/octopusdeploy_framework/schemas/project_group.go +++ b/octopusdeploy_framework/schemas/project_group.go @@ -43,10 +43,9 @@ func GetProjectGroupResourceSchema() map[string]resourceSchema.Attribute { } type ProjectGroupTypeResourceModel struct { - Name types.String `tfsdk:"name"` - SpaceID types.String `tfsdk:"space_id"` - Description types.String `tfsdk:"description"` - RetentionPolicyID types.String `tfsdk:"retention_policy_id"` + Name types.String `tfsdk:"name"` + SpaceID types.String `tfsdk:"space_id"` + Description types.String `tfsdk:"description"` ResourceModel }