From f3991192bb516b68d9d3e8d862d12b59e96eec38 Mon Sep 17 00:00:00 2001 From: Rob E Date: Fri, 19 Jul 2024 16:52:07 +1000 Subject: [PATCH 1/3] Breaking Change - Extract tenant project relationship to its own resource (#676) --- README.md | 5 + docs/data-sources/tenants.md | 9 - docs/resources/tenant.md | 14 +- docs/resources/tenant_project.md | 32 ++++ octopusdeploy/provider.go | 2 + octopusdeploy/resource_tenant project.go | 158 ++++++++++++++++++ octopusdeploy/resource_tenant.go | 9 + octopusdeploy/schema_project_environment.go | 40 ----- octopusdeploy/schema_tenant.go | 29 ---- .../schema_tenant_project_environment.go | 28 ++++ octopusdeploy/schema_tenant_test.go | 1 - templates/resources/tenant.md.tmpl | 14 ++ terraform/24-tenants/tenant.tf | 12 +- terraform/25-certificates/tenant.tf | 11 +- terraform/26-tenant_variables/tenant.tf | 11 +- .../26-tenant_variables/tenant_variables.tf | 2 + .../53-scheduledprojecttrigger/Tenanted.tf | 20 ++- 17 files changed, 282 insertions(+), 115 deletions(-) create mode 100644 docs/resources/tenant_project.md create mode 100644 octopusdeploy/resource_tenant project.go delete mode 100644 octopusdeploy/schema_project_environment.go create mode 100644 octopusdeploy/schema_tenant_project_environment.go create mode 100644 templates/resources/tenant.md.tmpl diff --git a/README.md b/README.md index 26e436923..d00b67106 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,11 @@ Documentation is auto-generated by the [tfplugindocs CLI](https://github.com/has $ make docs ``` +or +```shell +go generate main.go +``` + ## 🤝 Contributions Contributions are welcome! :heart: Please read our [Contributing Guide](CONTRIBUTING.md) for information about how to get involved in this project. diff --git a/docs/data-sources/tenants.md b/docs/data-sources/tenants.md index 46a4cf5aa..28d093d17 100644 --- a/docs/data-sources/tenants.md +++ b/docs/data-sources/tenants.md @@ -42,16 +42,7 @@ Read-Only: - `description` (String) The description of this tenant. - `id` (String) The unique ID for this resource. - `name` (String) The name of this resource. -- `project_environment` (Set of Object) (see [below for nested schema](#nestedatt--tenants--project_environment)) - `space_id` (String) The space ID associated with this resource. - `tenant_tags` (List of String) A list of tenant tags associated with this resource. - -### Nested Schema for `tenants.project_environment` - -Read-Only: - -- `environments` (List of String) -- `project_id` (String) - diff --git a/docs/resources/tenant.md b/docs/resources/tenant.md index 60a2793f8..ba3ce6aa6 100644 --- a/docs/resources/tenant.md +++ b/docs/resources/tenant.md @@ -1,5 +1,4 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "octopusdeploy_tenant Resource - terraform-provider-octopusdeploy" subcategory: "" description: |- @@ -10,8 +9,6 @@ description: |- This resource manages tenants in Octopus Deploy. - - ## Schema @@ -24,16 +21,7 @@ This resource manages tenants in Octopus Deploy. - `cloned_from_tenant_id` (String) The ID of the tenant from which this tenant was cloned. - `description` (String) The description of this tenant. - `id` (String) The unique ID for this resource. -- `project_environment` (Block Set) (see [below for nested schema](#nestedblock--project_environment)) - `space_id` (String) The space ID associated with this resource. - `tenant_tags` (List of String) A list of tenant tags associated with this resource. - -### Nested Schema for `project_environment` - -Required: - -- `environments` (List of String) A list of environment IDs associated with this tenant through a project. -- `project_id` (String) The project ID associated with this tenant. - - +~> **NOTE property `project_environment` deprecated:** The `project_environment` property has been replaced by the `octopusdeploy_tenant_project` resource to allow more advanced provisioning scenarioes. \ No newline at end of file diff --git a/docs/resources/tenant_project.md b/docs/resources/tenant_project.md new file mode 100644 index 000000000..f537e8fcc --- /dev/null +++ b/docs/resources/tenant_project.md @@ -0,0 +1,32 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "octopusdeploy_tenant_project Resource - terraform-provider-octopusdeploy" +subcategory: "" +description: |- + This resource represents the connection between tenants and projects. +--- + +# octopusdeploy_tenant_project (Resource) + +This resource represents the connection between tenants and projects. + + + + +## Schema + +### Required + +- `project_id` (String) The project ID associated with this tenant. +- `tenant_id` (String) The tenant ID associated with this tenant. + +### Optional + +- `environment_ids` (List of String) The environment ID associated with this tenant. +- `space_id` (String) The space ID associated with this resource. + +### Read-Only + +- `id` (String) The ID of this resource. + + diff --git a/octopusdeploy/provider.go b/octopusdeploy/provider.go index 1d5386556..750a21b07 100644 --- a/octopusdeploy/provider.go +++ b/octopusdeploy/provider.go @@ -2,6 +2,7 @@ package octopusdeploy import ( "context" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -94,6 +95,7 @@ func Provider() *schema.Provider { "octopusdeploy_tag_set": resourceTagSet(), "octopusdeploy_team": resourceTeam(), "octopusdeploy_tenant": resourceTenant(), + "octopusdeploy_tenant_project": resourceTenantProject(), "octopusdeploy_tenant_common_variable": resourceTenantCommonVariable(), "octopusdeploy_tenant_project_variable": resourceTenantProjectVariable(), "octopusdeploy_tentacle_certificate": resourceTentacleCertificate(), diff --git a/octopusdeploy/resource_tenant project.go b/octopusdeploy/resource_tenant project.go new file mode 100644 index 000000000..b04d2f6c6 --- /dev/null +++ b/octopusdeploy/resource_tenant project.go @@ -0,0 +1,158 @@ +package octopusdeploy + +import ( + "context" + "log" + "net/http" + "strings" + + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/tenants" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceTenantProject() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceTenantProjectCreate, + DeleteContext: resourceTenantProjectDelete, + Description: "This resource represents the connection between tenants and projects.", + Importer: getImporter(), + ReadContext: resourceTenantProjectRead, + UpdateContext: resourceTenantProjectUpdate, + Schema: getTenantProjectSchema(), + } +} + +func resourceTenantProjectUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + mutex.Lock() + defer mutex.Unlock() + + client := m.(*client.Client) + k := extractRelationship(d, client) + + log.Printf("[INFO] updating tenant (%#v) connection to project (%#v)", k.tenantID, k.projectID) + + tenant, err := tenants.GetByID(client, k.spaceID, k.tenantID) + if err != nil { + return diag.FromErr(err) + } + + tenant.ProjectEnvironments[k.projectID] = k.environmentIDs + + _, err = tenants.Update(client, tenant) + if err != nil { + return diag.FromErr(err) + } + + log.Printf("[INFO] updated tenant (%s) connection to project (%#v)", k.tenantID, k.projectID) + return nil +} + +func resourceTenantProjectCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + mutex.Lock() + defer mutex.Unlock() + + client := m.(*client.Client) + k := extractRelationship(d, client) + + log.Printf("[INFO] connecting tenant (%#v) to project (%#v)", k.tenantID, k.projectID) + + tenant, err := tenants.GetByID(client, k.spaceID, k.tenantID) + if err != nil { + return diag.FromErr(err) + } + + tenant.ProjectEnvironments[k.projectID] = k.environmentIDs + + _, err = tenants.Update(client, tenant) + if err != nil { + return diag.FromErr(err) + } + + id := k.spaceID + ":" + k.tenantID + ":" + k.projectID + d.SetId(id) + + log.Printf("[INFO] tenant (%s) connected to project (%#v)", k.tenantID, k.projectID) + return nil +} + +func resourceTenantProjectDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + mutex.Lock() + defer mutex.Unlock() + + client := m.(*client.Client) + k := extractRelationship(d, client) + + log.Printf("[INFO] removing tenant (%#v) from project (%#v)", k.tenantID, k.projectID) + + tenant, err := tenants.GetByID(client, k.spaceID, k.tenantID) + if err != nil { + apiError := err.(*core.APIError) + if apiError.StatusCode == http.StatusNotFound { + log.Printf("[INFO] tenant (%#v) no longer exists", k.tenantID) + d.SetId("") + return nil + } + + return diag.FromErr(err) + } + + delete(tenant.ProjectEnvironments, k.projectID) + + _, err = tenants.Update(client, tenant) + if err != nil { + return diag.FromErr(err) + } + + log.Printf("[INFO] tenant (%#v) disconnected from project (%#v)", k.tenantID, k.projectID) + d.SetId("") + return nil +} + +func resourceTenantProjectRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + client := m.(*client.Client) + + bits := strings.Split(d.Id(), ":") + spaceID := bits[0] + tenantID := bits[1] + projectID := bits[2] + + tenant, err := tenants.GetByID(client, spaceID, tenantID) + if err != nil { + apiError := err.(*core.APIError) + if apiError.StatusCode != http.StatusNotFound { + return diag.FromErr(err) + } + } + + d.Set("environment_ids", tenant.ProjectEnvironments[projectID]) + + return nil +} + +func extractRelationship(d *schema.ResourceData, client *client.Client) person { + tenantID := d.Get("tenant_id").(string) + projectID := d.Get("project_id").(string) + + environmentIDs := []string{} + if attr, ok := d.GetOk("environment_ids"); ok { + environmentIDs = getSliceFromTerraformTypeList(attr) + } + + spaceID := client.GetSpaceID() + if v, ok := d.GetOk("space_id"); ok { + spaceID = v.(string) + } + + n := person{tenantID: tenantID, projectID: projectID, environmentIDs: environmentIDs, spaceID: spaceID} + return n +} + +type person struct { + tenantID string + projectID string + environmentIDs []string + spaceID string +} diff --git a/octopusdeploy/resource_tenant.go b/octopusdeploy/resource_tenant.go index c4792434d..49ae9808f 100644 --- a/octopusdeploy/resource_tenant.go +++ b/octopusdeploy/resource_tenant.go @@ -24,6 +24,9 @@ func resourceTenant() *schema.Resource { } func resourceTenantCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + mutex.Lock() + defer mutex.Unlock() + tenant := expandTenant(d) log.Printf("[INFO] creating tenant: %#v", tenant) @@ -45,6 +48,9 @@ func resourceTenantCreate(ctx context.Context, d *schema.ResourceData, m interfa } func resourceTenantDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + mutex.Lock() + defer mutex.Unlock() + log.Printf("[INFO] deleting tenant (%s)", d.Id()) client := m.(*client.Client) @@ -75,6 +81,9 @@ func resourceTenantRead(ctx context.Context, d *schema.ResourceData, m interface } func resourceTenantUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + mutex.Lock() + defer mutex.Unlock() + log.Printf("[INFO] updating tenant (%s)", d.Id()) tenant := expandTenant(d) diff --git a/octopusdeploy/schema_project_environment.go b/octopusdeploy/schema_project_environment.go deleted file mode 100644 index 2995b486b..000000000 --- a/octopusdeploy/schema_project_environment.go +++ /dev/null @@ -1,40 +0,0 @@ -package octopusdeploy - -import ( - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func expandProjectEnvironments(value interface{}) map[string][]string { - expandedProjectEnvironments := map[string][]string{} - - set := value.(*schema.Set) - for _, item := range set.List() { - projectEnvironment := item.(map[string]interface{}) - projectID := projectEnvironment["project_id"].(string) - environments := []string{} - for _, e := range projectEnvironment["environments"].([]interface{}) { - environments = append(environments, e.(string)) - } - - expandedProjectEnvironments[projectID] = environments - } - - return expandedProjectEnvironments -} - -func flattenProjectEnvironments(projectEnvironments map[string][]string) []interface{} { - if projectEnvironments == nil { - return nil - } - - flattenedProjectEnvironments := []interface{}{} - for projectID, enviroments := range projectEnvironments { - rawProjectEnvironment := map[string]interface{}{ - "project_id": projectID, - "environments": enviroments, - } - flattenedProjectEnvironments = append(flattenedProjectEnvironments, rawProjectEnvironment) - } - - return flattenedProjectEnvironments -} diff --git a/octopusdeploy/schema_tenant.go b/octopusdeploy/schema_tenant.go index a72a4af63..6045f5981 100644 --- a/octopusdeploy/schema_tenant.go +++ b/octopusdeploy/schema_tenant.go @@ -22,10 +22,6 @@ func expandTenant(d *schema.ResourceData) *tenants.Tenant { tenant.Description = v.(string) } - if v, ok := d.GetOk("project_environment"); ok { - tenant.ProjectEnvironments = expandProjectEnvironments(v) - } - if v, ok := d.GetOk("space_id"); ok { tenant.SpaceID = v.(string) } @@ -47,7 +43,6 @@ func flattenTenant(tenant *tenants.Tenant) map[string]interface{} { "description": tenant.Description, "id": tenant.GetID(), "name": tenant.Name, - "project_environment": flattenProjectEnvironments(tenant.ProjectEnvironments), "space_id": tenant.SpaceID, "tenant_tags": tenant.TenantTags, } @@ -89,25 +84,6 @@ func getTenantSchema() map[string]*schema.Schema { "description": getDescriptionSchema("tenant"), "id": getIDSchema(), "name": getNameSchema(true), - "project_environment": { - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "environments": { - Description: "A list of environment IDs associated with this tenant through a project.", - Elem: &schema.Schema{Type: schema.TypeString}, - Required: true, - Type: schema.TypeList, - }, - "project_id": { - Description: "The project ID associated with this tenant.", - Required: true, - Type: schema.TypeString, - }, - }, - }, - Type: schema.TypeSet, - }, "space_id": getSpaceIDSchema(), "tenant_tags": getTenantTagsSchema(), } @@ -118,11 +94,6 @@ func setTenant(ctx context.Context, d *schema.ResourceData, tenant *tenants.Tena d.Set("description", tenant.Description) d.Set("id", tenant.GetID()) d.Set("name", tenant.Name) - - if err := d.Set("project_environment", flattenProjectEnvironments(tenant.ProjectEnvironments)); err != nil { - return fmt.Errorf("error setting project_environment: %s", err) - } - d.Set("space_id", tenant.SpaceID) if err := d.Set("tenant_tags", tenant.TenantTags); err != nil { diff --git a/octopusdeploy/schema_tenant_project_environment.go b/octopusdeploy/schema_tenant_project_environment.go new file mode 100644 index 000000000..0cab0481f --- /dev/null +++ b/octopusdeploy/schema_tenant_project_environment.go @@ -0,0 +1,28 @@ +package octopusdeploy + +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + +func getTenantProjectSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "tenant_id": { + Description: "The tenant ID associated with this tenant.", + Required: true, + Type: schema.TypeString, + ForceNew: true, + }, + "project_id": { + Description: "The project ID associated with this tenant.", + Required: true, + Type: schema.TypeString, + ForceNew: true, + }, + "environment_ids": { + Description: "The environment ID associated with this tenant.", + Elem: &schema.Schema{Type: schema.TypeString}, + Optional: true, + Type: schema.TypeList, + Required: false, + }, + "space_id": getSpaceIDSchema(), + } +} diff --git a/octopusdeploy/schema_tenant_test.go b/octopusdeploy/schema_tenant_test.go index 76016001e..0a1d00d18 100644 --- a/octopusdeploy/schema_tenant_test.go +++ b/octopusdeploy/schema_tenant_test.go @@ -31,7 +31,6 @@ func TestFlattenTenant(t *testing.T) { "description": description, "id": id, "name": name, - "project_environment": flattenProjectEnvironments(projectEnvironments), "space_id": spaceID, "tenant_tags": tenantTags, } diff --git a/templates/resources/tenant.md.tmpl b/templates/resources/tenant.md.tmpl new file mode 100644 index 000000000..d144e1f7c --- /dev/null +++ b/templates/resources/tenant.md.tmpl @@ -0,0 +1,14 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +{{ .SchemaMarkdown | trimspace }} + +~> **NOTE property `project_environment` deprecated:** The `project_environment` property has been replaced by the `octopusdeploy_tenant_project` resource to allow more advanced provisioning scenarioes. \ No newline at end of file diff --git a/terraform/24-tenants/tenant.tf b/terraform/24-tenants/tenant.tf index 5637e1def..609dcca2d 100644 --- a/terraform/24-tenants/tenant.tf +++ b/terraform/24-tenants/tenant.tf @@ -3,9 +3,11 @@ resource "octopusdeploy_tenant" "tenant_team_a" { description = "Test tenant" tenant_tags = ["tag1/a", "tag1/b"] depends_on = [octopusdeploy_tag.tag_a, octopusdeploy_tag.tag_b] - - project_environment { - environments = [octopusdeploy_environment.test_environment.id, octopusdeploy_environment.development_environment.id, octopusdeploy_environment.production_environment.id] - project_id = octopusdeploy_project.deploy_frontend_project.id - } } + + +resource "octopusdeploy_tenant_project" "team_a_frontend" { + tenant_id = octopusdeploy_tenant.tenant_team_a.id + project_id = octopusdeploy_project.deploy_frontend_project.id + environment_ids = [octopusdeploy_environment.test_environment.id, octopusdeploy_environment.development_environment.id, octopusdeploy_environment.production_environment.id] +} \ No newline at end of file diff --git a/terraform/25-certificates/tenant.tf b/terraform/25-certificates/tenant.tf index 5637e1def..e88cc53e4 100644 --- a/terraform/25-certificates/tenant.tf +++ b/terraform/25-certificates/tenant.tf @@ -3,9 +3,10 @@ resource "octopusdeploy_tenant" "tenant_team_a" { description = "Test tenant" tenant_tags = ["tag1/a", "tag1/b"] depends_on = [octopusdeploy_tag.tag_a, octopusdeploy_tag.tag_b] - - project_environment { - environments = [octopusdeploy_environment.test_environment.id, octopusdeploy_environment.development_environment.id, octopusdeploy_environment.production_environment.id] - project_id = octopusdeploy_project.deploy_frontend_project.id - } } + +resource "octopusdeploy_tenant_project" "team_a_frontend" { + tenant_id = octopusdeploy_tenant.tenant_team_a.id + project_id = octopusdeploy_project.deploy_frontend_project.id + environment_ids = [octopusdeploy_environment.test_environment.id, octopusdeploy_environment.development_environment.id, octopusdeploy_environment.production_environment.id] +} \ No newline at end of file diff --git a/terraform/26-tenant_variables/tenant.tf b/terraform/26-tenant_variables/tenant.tf index 610f519df..14dde35ec 100644 --- a/terraform/26-tenant_variables/tenant.tf +++ b/terraform/26-tenant_variables/tenant.tf @@ -1,9 +1,10 @@ resource "octopusdeploy_tenant" "tenant_team_a" { name = "Team A" description = "Test tenant" - - project_environment { - environments = [octopusdeploy_environment.test_environment.id, octopusdeploy_environment.development_environment.id, octopusdeploy_environment.production_environment.id] - project_id = octopusdeploy_project.deploy_frontend_project.id - } } + +resource "octopusdeploy_tenant_project" "team_a_frontend" { + tenant_id = octopusdeploy_tenant.tenant_team_a.id + project_id = octopusdeploy_project.deploy_frontend_project.id + environment_ids = [octopusdeploy_environment.test_environment.id, octopusdeploy_environment.development_environment.id, octopusdeploy_environment.production_environment.id] +} \ No newline at end of file diff --git a/terraform/26-tenant_variables/tenant_variables.tf b/terraform/26-tenant_variables/tenant_variables.tf index 28dcd1106..060b4e235 100644 --- a/terraform/26-tenant_variables/tenant_variables.tf +++ b/terraform/26-tenant_variables/tenant_variables.tf @@ -4,6 +4,7 @@ resource "octopusdeploy_tenant_project_variable" "tenantprojectvariable6_team_a" template_id = "${octopusdeploy_project.deploy_frontend_project.template[0].id}" tenant_id = "${octopusdeploy_tenant.tenant_team_a.id}" value = "my value" + depends_on = [ octopusdeploy_tenant_project.team_a_frontend ] } resource "octopusdeploy_tenant_common_variable" "tenantcommonvariable1_team_a" { @@ -11,4 +12,5 @@ resource "octopusdeploy_tenant_common_variable" "tenantcommonvariable1_team_a" { template_id = "${octopusdeploy_library_variable_set.library_variable_set_octopus_variables.template[0].id}" tenant_id = "${octopusdeploy_tenant.tenant_team_a.id}" value = "my value" + depends_on = [ octopusdeploy_tenant_project.team_a_frontend ] } diff --git a/terraform/53-scheduledprojecttrigger/Tenanted.tf b/terraform/53-scheduledprojecttrigger/Tenanted.tf index 601353db9..34bc8b512 100644 --- a/terraform/53-scheduledprojecttrigger/Tenanted.tf +++ b/terraform/53-scheduledprojecttrigger/Tenanted.tf @@ -119,11 +119,13 @@ resource "octopusdeploy_tenant" "tenant_team_a" { space_id = var.octopus_space_id depends_on = [octopusdeploy_tag.tag_a, octopusdeploy_tag.tag_b] +} - project_environment { - environments = [octopusdeploy_environment.env_1.id, octopusdeploy_environment.env_2.id] - project_id = octopusdeploy_project.tenanted.id - } +resource "octopusdeploy_tenant_project" "team_a_tenanted" { + tenant_id = octopusdeploy_tenant.tenant_team_a.id + project_id = octopusdeploy_project.tenanted.id + environment_ids = [octopusdeploy_environment.env_1.id, octopusdeploy_environment.env_2.id] + space_id = var.octopus_space_id } resource "octopusdeploy_tenant" "tenant_team_b" { @@ -132,11 +134,13 @@ resource "octopusdeploy_tenant" "tenant_team_b" { tenant_tags = ["tag1/a", "tag1/b"] space_id = var.octopus_space_id depends_on = [octopusdeploy_tag.tag_a, octopusdeploy_tag.tag_b] +} - project_environment { - environments = [octopusdeploy_environment.env_1.id, octopusdeploy_environment.env_2.id] - project_id = octopusdeploy_project.tenanted.id - } +resource "octopusdeploy_tenant_project" "team_b_tenanted" { + tenant_id = octopusdeploy_tenant.tenant_team_b.id + project_id = octopusdeploy_project.tenanted.id + environment_ids = [octopusdeploy_environment.env_1.id, octopusdeploy_environment.env_2.id] + space_id = var.octopus_space_id } resource "octopusdeploy_project_scheduled_trigger" "tenanted_trigger" { From 4427886a957353666f264228142548b4c97e369c Mon Sep 17 00:00:00 2001 From: Isaac Calligeros <101079287+IsaacCalligeros95@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:09:10 +0930 Subject: [PATCH 2/3] Fixing mssql test issue (#692) --- go.mod | 18 ++++++++++-------- go.sum | 46 ++++++++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/go.mod b/go.mod index 816537f2c..f9bdcfde4 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( github.com/OctopusDeploy/go-octopusdeploy/v2 v2.43.0 - github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240622231527-24df7b6eaa48 + github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240725054341-2848f54d101e github.com/google/uuid v1.6.0 github.com/gruntwork-io/terratest v0.41.11 github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637 @@ -29,8 +29,8 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.0 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/Microsoft/hcsshim v0.11.4 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/Microsoft/hcsshim v0.11.5 // indirect github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect @@ -43,13 +43,14 @@ require ( github.com/buger/jsonparser v1.1.1 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect - github.com/containerd/containerd v1.7.15 // indirect + github.com/containerd/containerd v1.7.18 // indirect + github.com/containerd/errdefs v0.1.0 // indirect github.com/containerd/log v0.1.0 // indirect github.com/cpuguy83/dockercfg v0.3.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dghubble/sling v1.4.1 // indirect - github.com/distribution/reference v0.5.0 // indirect - github.com/docker/docker v25.0.5+incompatible // indirect + github.com/distribution/reference v0.6.0 // indirect + github.com/docker/docker v27.0.3+incompatible // indirect github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/fatih/color v1.16.0 // indirect @@ -91,7 +92,7 @@ require ( github.com/imdario/mergo v0.3.15 // indirect github.com/jinzhu/copier v0.3.5 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/compress v1.17.4 // indirect github.com/leodido/go-urn v1.2.2 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -106,6 +107,7 @@ require ( github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/patternmatcher v0.6.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect github.com/moby/sys/user v0.1.0 // indirect @@ -125,7 +127,7 @@ require ( github.com/shopspring/decimal v1.3.1 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/cast v1.5.0 // indirect - github.com/testcontainers/testcontainers-go v0.31.0 // indirect + github.com/testcontainers/testcontainers-go v0.32.0 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/tmccombs/hcl2json v0.3.6 // indirect diff --git a/go.sum b/go.sum index 795d2a3cf..d50b01763 100644 --- a/go.sum +++ b/go.sum @@ -34,16 +34,14 @@ github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYr github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= -github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/Microsoft/hcsshim v0.11.5 h1:haEcLNpj9Ka1gd3B3tAEs9CpE0c+1IhoL59w/exYU38= +github.com/Microsoft/hcsshim v0.11.5/go.mod h1:MV8xMfmECjl5HdO7U/3/hFVnkmSBjAjmA09d4bExKcU= github.com/OctopusDeploy/go-octopusdeploy/v2 v2.43.0 h1:fYwGBqG88xy3qHp5j1ySCztdqfw2NLfg2yp0N3XcBYg= github.com/OctopusDeploy/go-octopusdeploy/v2 v2.43.0/go.mod h1:GZmFu6LmN8Yg0tEoZx3ytk9FnaH+84cWm7u5TdWZC6E= -github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240502041300-f71244db277d h1:E0Rm52/XBlVzdkHET/+Js1FVVgf5/0oRk1tNkI4jcyk= -github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240502041300-f71244db277d/go.mod h1:Nyg+7cyTrSQ/lMIy5YY1UdJekRuoMWf4uHIPfaGmgTM= -github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240622231527-24df7b6eaa48 h1:lxcmT+JUYCe2pA7owBK47/z0jY3va03yl1sQA3n0/Xo= -github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240622231527-24df7b6eaa48/go.mod h1:/QwYrEWP690YoKAR9lUVEv2y1Ta0HY08OaWb4LMZCAw= +github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240725054341-2848f54d101e h1:FIvWa8wNg8IBG5uVhqkKvcBhaxx4TgN7T8/5Ed4VQUE= +github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20240725054341-2848f54d101e/go.mod h1:Oq9KbiRNDBB5jFmrwnrgLX0urIqR/1ptY18TzkqXm7M= github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg= github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= @@ -83,10 +81,10 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ= github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM= -github.com/containerd/containerd v1.7.12 h1:+KQsnv4VnzyxWcfO9mlxxELaoztsDEjOuCMPAuPqgU0= -github.com/containerd/containerd v1.7.12/go.mod h1:/5OMpE1p0ylxtEUGY8kuCYkDRzJm9NO1TFMWjUpdevk= -github.com/containerd/containerd v1.7.15 h1:afEHXdil9iAm03BmhjzKyXnnEBtjaLJefdU7DV0IFes= -github.com/containerd/containerd v1.7.15/go.mod h1:ISzRRTMF8EXNpJlTzyr2XMhN+j9K302C21/+cr3kUnY= +github.com/containerd/containerd v1.7.18 h1:jqjZTQNfXGoEaZdW1WwPU0RqSn1Bm2Ay/KJPUuO8nao= +github.com/containerd/containerd v1.7.18/go.mod h1:IYEk9/IO6wAPUz2bCMVUbsfXjzw5UNP5fLz4PsUygQ4= +github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= +github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= @@ -101,10 +99,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dghubble/sling v1.4.1 h1:AxjTubpVyozMvbBCtXcsWEyGGgUZutC5YGrfxPNVOcQ= github.com/dghubble/sling v1.4.1/go.mod h1:QoMB1KL3GAo+7HsD8Itd6S+6tW91who8BGZzuLvpOyc= -github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= -github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE= -github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/docker v27.0.3+incompatible h1:aBGI9TeQ4MPlhquTQKq9XbK79rKFVwXNUAYz9aXyEBE= +github.com/docker/docker v27.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -294,8 +292,8 @@ github.com/kinbiko/jsonassert v1.1.1/go.mod h1:NO4lzrogohtIdNUNzx8sdzB55M4R4Q1bs github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= +github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -348,6 +346,8 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= @@ -421,10 +421,8 @@ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/testcontainers/testcontainers-go v0.30.0 h1:jmn/XS22q4YRrcMwWg0pAwlClzs/abopbsBzrepyc4E= -github.com/testcontainers/testcontainers-go v0.30.0/go.mod h1:K+kHNGiM5zjklKjgTtcrEetF3uhWbMUyqAQoyoh8Pf0= -github.com/testcontainers/testcontainers-go v0.31.0 h1:W0VwIhcEVhRflwL9as3dhY6jXjVCA27AkmbnZ+UTh3U= -github.com/testcontainers/testcontainers-go v0.31.0/go.mod h1:D2lAoA0zUFiSY+eAflqK5mcUx/A5hrrORaEQrd0SefI= +github.com/testcontainers/testcontainers-go v0.32.0 h1:ug1aK08L3gCHdhknlTTwWjPHPS+/alvLJU/DRxTD/ME= +github.com/testcontainers/testcontainers-go v0.32.0/go.mod h1:CRHrzHLQhlXUsa5gXjTOfqIEJcrK5+xMDmBr/WMI88E= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= @@ -684,8 +682,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= -gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= +gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= +gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From a861ac5db0561825cec0f071fdefe97fb1288b1f Mon Sep 17 00:00:00 2001 From: Ben Pearce Date: Mon, 29 Jul 2024 13:48:39 +1000 Subject: [PATCH 3/3] chore!: align config in both providers (#694) * aligned provider config * prefer utility over custom for typename --- octopusdeploy/provider.go | 4 ++-- octopusdeploy_framework/datasource_environments.go | 2 +- octopusdeploy_framework/datasource_feeds.go | 2 +- octopusdeploy_framework/datasource_project_groups.go | 2 +- octopusdeploy_framework/framework_provider.go | 5 +---- octopusdeploy_framework/resource_artifactory_generic_feed.go | 3 ++- .../resource_aws_elastic_container_registry.go | 3 ++- octopusdeploy_framework/resource_environment.go | 2 +- octopusdeploy_framework/resource_github_repository_feed.go | 3 ++- octopusdeploy_framework/resource_helm_feed.go | 3 ++- octopusdeploy_framework/resource_maven_feed.go | 3 ++- octopusdeploy_framework/resource_nuget_feed.go | 3 ++- octopusdeploy_framework/resource_project_group.go | 3 ++- 13 files changed, 21 insertions(+), 17 deletions(-) diff --git a/octopusdeploy/provider.go b/octopusdeploy/provider.go index 3778a0d45..a6946b383 100644 --- a/octopusdeploy/provider.go +++ b/octopusdeploy/provider.go @@ -90,13 +90,13 @@ func Provider() *schema.Provider { "address": { DefaultFunc: schema.EnvDefaultFunc("OCTOPUS_URL", nil), Description: "The endpoint of the Octopus REST API", - Required: true, + Optional: true, Type: schema.TypeString, }, "api_key": { DefaultFunc: schema.EnvDefaultFunc("OCTOPUS_APIKEY", nil), Description: "The API key to use with the Octopus REST API", - Required: true, + Optional: true, Type: schema.TypeString, }, "space_id": { diff --git a/octopusdeploy_framework/datasource_environments.go b/octopusdeploy_framework/datasource_environments.go index f86545c62..b788107d5 100644 --- a/octopusdeploy_framework/datasource_environments.go +++ b/octopusdeploy_framework/datasource_environments.go @@ -36,7 +36,7 @@ func NewEnvironmentsDataSource() datasource.DataSource { } func (*environmentDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_environments" + resp.TypeName = util.GetTypeName("environments") } func (*environmentDataSource) Schema(_ context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { diff --git a/octopusdeploy_framework/datasource_feeds.go b/octopusdeploy_framework/datasource_feeds.go index ddc7be138..d8c19a863 100644 --- a/octopusdeploy_framework/datasource_feeds.go +++ b/octopusdeploy_framework/datasource_feeds.go @@ -23,7 +23,7 @@ func NewFeedsDataSource() datasource.DataSource { } func (*feedsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_feeds" + resp.TypeName = util.GetTypeName("feeds") } func (e *feedsDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { diff --git a/octopusdeploy_framework/datasource_project_groups.go b/octopusdeploy_framework/datasource_project_groups.go index be54058b6..01713abbc 100644 --- a/octopusdeploy_framework/datasource_project_groups.go +++ b/octopusdeploy_framework/datasource_project_groups.go @@ -42,7 +42,7 @@ func getNestedGroupAttributes() map[string]attr.Type { } func (p *projectGroupsDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_project_groups" + resp.TypeName = util.GetTypeName("project_groups") } func (p *projectGroupsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { diff --git a/octopusdeploy_framework/framework_provider.go b/octopusdeploy_framework/framework_provider.go index 473a44889..8618d7d89 100644 --- a/octopusdeploy_framework/framework_provider.go +++ b/octopusdeploy_framework/framework_provider.go @@ -21,7 +21,6 @@ type octopusDeployFrameworkProvider struct { var _ provider.Provider = (*octopusDeployFrameworkProvider)(nil) var _ provider.ProviderWithMetaSchema = (*octopusDeployFrameworkProvider)(nil) var _ provider.ProviderWithFunctions -var ProviderTypeName = "octopusdeploy" func NewOctopusDeployFrameworkProvider() *octopusDeployFrameworkProvider { return &octopusDeployFrameworkProvider{} @@ -87,16 +86,14 @@ func (p *octopusDeployFrameworkProvider) Resources(ctx context.Context) []func() } } -func (p *octopusDeployFrameworkProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { +func (p *octopusDeployFrameworkProvider) Schema(_ context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ Attributes: map[string]schema.Attribute{ "address": schema.StringAttribute{ - //Required: true, Optional: true, Description: "The endpoint of the Octopus REST API", }, "api_key": schema.StringAttribute{ - //Required: true, Optional: true, Description: "The API key to use with the Octopus REST API", }, diff --git a/octopusdeploy_framework/resource_artifactory_generic_feed.go b/octopusdeploy_framework/resource_artifactory_generic_feed.go index 24074bd5c..e70900061 100644 --- a/octopusdeploy_framework/resource_artifactory_generic_feed.go +++ b/octopusdeploy_framework/resource_artifactory_generic_feed.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas" + "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -23,7 +24,7 @@ func NewArtifactoryGenericFeedResource() resource.Resource { } func (r *artifactoryGenericFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_artifactory_generic_feed" + resp.TypeName = util.GetTypeName("artifactory_generic_feed") } func (r *artifactoryGenericFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/octopusdeploy_framework/resource_aws_elastic_container_registry.go b/octopusdeploy_framework/resource_aws_elastic_container_registry.go index 6c3f602a4..96f089a83 100644 --- a/octopusdeploy_framework/resource_aws_elastic_container_registry.go +++ b/octopusdeploy_framework/resource_aws_elastic_container_registry.go @@ -6,6 +6,7 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas" + "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -22,7 +23,7 @@ func NewAwsElasticContainerRegistryFeedResource() resource.Resource { } func (r *awsElasticContainerRegistryFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_aws_elastic_container_registry" + resp.TypeName = util.GetTypeName("aws_elastic_container_registry") } func (r *awsElasticContainerRegistryFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/octopusdeploy_framework/resource_environment.go b/octopusdeploy_framework/resource_environment.go index 87451ece3..a393279ad 100644 --- a/octopusdeploy_framework/resource_environment.go +++ b/octopusdeploy_framework/resource_environment.go @@ -20,7 +20,7 @@ func NewEnvironmentResource() resource.Resource { } func (r *environmentTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_environment" + resp.TypeName = util.GetTypeName("environment") } func (r *environmentTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/octopusdeploy_framework/resource_github_repository_feed.go b/octopusdeploy_framework/resource_github_repository_feed.go index 13fefa853..7a198daaa 100644 --- a/octopusdeploy_framework/resource_github_repository_feed.go +++ b/octopusdeploy_framework/resource_github_repository_feed.go @@ -6,6 +6,7 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas" + "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -22,7 +23,7 @@ func NewGitHubRepositoryFeedResource() resource.Resource { } func (r *githubRepositoryFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_github_repository_feed" + resp.TypeName = util.GetTypeName("github_repository_feed") } func (r *githubRepositoryFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/octopusdeploy_framework/resource_helm_feed.go b/octopusdeploy_framework/resource_helm_feed.go index ced350894..4fc1c9d3c 100644 --- a/octopusdeploy_framework/resource_helm_feed.go +++ b/octopusdeploy_framework/resource_helm_feed.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas" + "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -23,7 +24,7 @@ func NewHelmFeedResource() resource.Resource { } func (r *helmFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_helm_feed" + resp.TypeName = util.GetTypeName("helm_feed") } func (r *helmFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/octopusdeploy_framework/resource_maven_feed.go b/octopusdeploy_framework/resource_maven_feed.go index c7a1394c8..c6f6ddd19 100644 --- a/octopusdeploy_framework/resource_maven_feed.go +++ b/octopusdeploy_framework/resource_maven_feed.go @@ -6,6 +6,7 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas" + "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -22,7 +23,7 @@ func NewMavenFeedResource() resource.Resource { } func (r *mavenFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_maven_feed" + resp.TypeName = util.GetTypeName("maven_feed") } func (r *mavenFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/octopusdeploy_framework/resource_nuget_feed.go b/octopusdeploy_framework/resource_nuget_feed.go index dc1e304d6..306e16f14 100644 --- a/octopusdeploy_framework/resource_nuget_feed.go +++ b/octopusdeploy_framework/resource_nuget_feed.go @@ -6,6 +6,7 @@ import ( "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/feeds" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas" + "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -22,7 +23,7 @@ func NewNugetFeedResource() resource.Resource { } func (r *nugetFeedTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_nuget_feed" + resp.TypeName = util.GetTypeName("nuget_feed") } func (r *nugetFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/octopusdeploy_framework/resource_project_group.go b/octopusdeploy_framework/resource_project_group.go index 994b38702..e78f49cef 100644 --- a/octopusdeploy_framework/resource_project_group.go +++ b/octopusdeploy_framework/resource_project_group.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projectgroups" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/schemas" + "github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -20,7 +21,7 @@ func NewProjectGroupResource() resource.Resource { } func (r *projectGroupTypeResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = ProviderTypeName + "_project_group" + resp.TypeName = util.GetTypeName("project_group") } func (r *projectGroupTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {