From a145ba0384bb4f3adf32fd5bc9d9f56694637ac6 Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Wed, 13 Nov 2024 09:43:51 +1300 Subject: [PATCH 01/11] feat: Add listeninig tentacle worker --- docs/resources/listening_tentacle_worker.md | 62 +++++++ .../import.sh | 1 + .../resource.tf | 17 ++ go.mod | 2 + octopusdeploy_framework/framework_provider.go | 1 + .../resource_listening_tentacle_worker.go | 174 ++++++++++++++++++ ...resource_listening_tentacle_worker_test.go | 150 +++++++++++++++ .../schemas/listening_tentacle_worker.go | 54 ++++++ 8 files changed, 461 insertions(+) create mode 100644 docs/resources/listening_tentacle_worker.md create mode 100644 examples/resources/octopusdeploy_listening_tentacle_worker/import.sh create mode 100644 examples/resources/octopusdeploy_listening_tentacle_worker/resource.tf create mode 100644 octopusdeploy_framework/resource_listening_tentacle_worker.go create mode 100644 octopusdeploy_framework/resource_listening_tentacle_worker_test.go create mode 100644 octopusdeploy_framework/schemas/listening_tentacle_worker.go diff --git a/docs/resources/listening_tentacle_worker.md b/docs/resources/listening_tentacle_worker.md new file mode 100644 index 00000000..78c46b61 --- /dev/null +++ b/docs/resources/listening_tentacle_worker.md @@ -0,0 +1,62 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "octopusdeploy_listening_tentacle_worker Resource - terraform-provider-octopusdeploy" +subcategory: "" +description: |- + This resource manages a listening tentacle worker in Octopus Deploy. +--- + +# octopusdeploy_listening_tentacle_worker (Resource) + +This resource manages a listening tentacle worker in Octopus Deploy. + +## Example Usage + +```terraform +resource "octopusdeploy_listening_tentacle_worker" "minimum" { + name = "listening_worker" + machine_policy_id = "machine-policy-1" + worker_pools = ["worker-pools-1", "worker-pools-2"] + thumbprint = "96203ED84246201C26A2F4360D7CBC36AC1D232D" + uri = "https://tentacle.listening/" +} + +resource "octopusdeploy_listening_tentacle_worker" "optionals" { + name = "optional_worker" + machine_policy_id = "machine-policy-1" + worker_pools = ["worker-pools-1"] + thumbprint = "96203ED84246201C26A2F4360D7CBC36AC1D232D" + uri = "https://tentacle.listening/" + proxy_id = "proxys-1" + is_disabled = true +} +``` + + +## Schema + +### Required + +- `machine_policy_id` (String) Select the machine policy +- `name` (String) The name of this resource. +- `thumbprint` (String) The X509 certificate thumbprint that securely identifies the Tentacle +- `uri` (String) The network address at which the Tentacle can be reached +- `worker_pool_ids` (List of String) Select at least one worker pool for the worker + +### Optional + +- `is_disabled` (Boolean) When disabled, worker will not be included in any deployments +- `proxy_id` (String) Specify the connection type for the Tentacle: direct(when not set) or via a proxy server. +- `space_id` (String) The space ID associated with this Listening tentacle worker. + +### Read-Only + +- `id` (String) The unique ID for this resource. + +## Import + +Import is supported using the following syntax: + +```shell +terraform import [options] octopusdeploy_listening_tentacle_worker. +``` diff --git a/examples/resources/octopusdeploy_listening_tentacle_worker/import.sh b/examples/resources/octopusdeploy_listening_tentacle_worker/import.sh new file mode 100644 index 00000000..90d6c7c9 --- /dev/null +++ b/examples/resources/octopusdeploy_listening_tentacle_worker/import.sh @@ -0,0 +1 @@ +terraform import [options] octopusdeploy_listening_tentacle_worker. \ No newline at end of file diff --git a/examples/resources/octopusdeploy_listening_tentacle_worker/resource.tf b/examples/resources/octopusdeploy_listening_tentacle_worker/resource.tf new file mode 100644 index 00000000..5cc29945 --- /dev/null +++ b/examples/resources/octopusdeploy_listening_tentacle_worker/resource.tf @@ -0,0 +1,17 @@ +resource "octopusdeploy_listening_tentacle_worker" "minimum" { + name = "listening_worker" + machine_policy_id = "machine-policy-1" + worker_pools = ["worker-pools-1", "worker-pools-2"] + thumbprint = "96203ED84246201C26A2F4360D7CBC36AC1D232D" + uri = "https://tentacle.listening/" +} + +resource "octopusdeploy_listening_tentacle_worker" "optionals" { + name = "optional_worker" + machine_policy_id = "machine-policy-1" + worker_pools = ["worker-pools-1"] + thumbprint = "96203ED84246201C26A2F4360D7CBC36AC1D232D" + uri = "https://tentacle.listening/" + proxy_id = "proxys-1" + is_disabled = true +} diff --git a/go.mod b/go.mod index 8dcc68c2..aac36869 100644 --- a/go.mod +++ b/go.mod @@ -142,3 +142,5 @@ require ( google.golang.org/protobuf v1.34.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + + diff --git a/octopusdeploy_framework/framework_provider.go b/octopusdeploy_framework/framework_provider.go index 650596b5..1daab7df 100644 --- a/octopusdeploy_framework/framework_provider.go +++ b/octopusdeploy_framework/framework_provider.go @@ -119,6 +119,7 @@ func (p *octopusDeployFrameworkProvider) Resources(ctx context.Context) []func() NewRunbookResource, NewTenantResource, NewTentacleCertificateResource, + NewListeningTentacleWorkerResource, NewScriptModuleResource, NewUserResource, } diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker.go b/octopusdeploy_framework/resource_listening_tentacle_worker.go new file mode 100644 index 00000000..fefd2db5 --- /dev/null +++ b/octopusdeploy_framework/resource_listening_tentacle_worker.go @@ -0,0 +1,174 @@ +package octopusdeploy_framework + +import ( + "context" + "fmt" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/machines" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workers" + "github.com/hashicorp/terraform-plugin-framework/path" + "net/url" + + "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" + "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/types" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +type listeningTentacleWorkerResource struct { + *Config +} + +func NewListeningTentacleWorkerResource() resource.Resource { + return &listeningTentacleWorkerResource{} +} + +var _ resource.ResourceWithImportState = &listeningTentacleWorkerResource{} + +func (r *listeningTentacleWorkerResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = util.GetTypeName("listening_tentacle_worker") +} + +func (r *listeningTentacleWorkerResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schemas.ListeningTentacleWorkerSchema{}.GetResourceSchema() +} + +func (r *listeningTentacleWorkerResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + r.Config = ResourceConfiguration(req, resp) +} + +func (r *listeningTentacleWorkerResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var data *schemas.ListeningTentacleWorkerResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + worker := createListeningTentacleWorkerResource(ctx, data) + + tflog.Info(ctx, fmt.Sprintf("creating listening tentacle worker: %s", data.Name.ValueString())) + + client := r.Config.Client + createdWorker, err := workers.Add(client, worker) + if err != nil { + resp.Diagnostics.AddError("unable to create listening tentacle worker", err.Error()) + return + } + + updateDataFromListeningTentacleWorker(ctx, data, data.SpaceID.ValueString(), createdWorker) + + tflog.Info(ctx, fmt.Sprintf("listening tentacle worker created (%s)", data.ID)) + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (r *listeningTentacleWorkerResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var data *schemas.ListeningTentacleWorkerResourceModel + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Info(ctx, fmt.Sprintf("reading listening tentacle worker (%s)", data.ID)) + + client := r.Config.Client + worker, err := workers.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) + if err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "listening tentacle worker"); err != nil { + resp.Diagnostics.AddError("unable to load listening tentacle worker", err.Error()) + } + return + } + + if worker.Endpoint.GetCommunicationStyle() != "TentaclePassive" { + resp.Diagnostics.AddError("unable to load listening tentacle worker", "found resource is not listening tentacle worker") + return + } + + updateDataFromListeningTentacleWorker(ctx, data, data.SpaceID.ValueString(), worker) + + tflog.Info(ctx, fmt.Sprintf("listening tentacle worker read (%s)", worker.GetID())) + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (r *listeningTentacleWorkerResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var data, state *schemas.ListeningTentacleWorkerResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("updating listening tentacle worker '%s'", data.ID.ValueString())) + + worker := createListeningTentacleWorkerResource(ctx, data) + worker.ID = state.ID.ValueString() + + tflog.Info(ctx, fmt.Sprintf("updating listening tentacle worker (%s)", data.ID)) + + client := r.Config.Client + updatedWorker, err := workers.Update(client, worker) + if err != nil { + resp.Diagnostics.AddError("unable to update listening tentacle worker", err.Error()) + return + } + + updateDataFromListeningTentacleWorker(ctx, data, state.SpaceID.ValueString(), updatedWorker) + + tflog.Info(ctx, fmt.Sprintf("listening tentacle worker updated (%s)", data.ID)) + + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func (r *listeningTentacleWorkerResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var data schemas.ListeningTentacleWorkerResourceModel + + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + if err := workers.DeleteByID(r.Config.Client, data.SpaceID.ValueString(), data.ID.ValueString()); err != nil { + resp.Diagnostics.AddError("unable to delete listening tentacle worker", err.Error()) + return + } +} + +func createListeningTentacleWorkerResource(ctx context.Context, data *schemas.ListeningTentacleWorkerResourceModel) *machines.Worker { + uri, _ := url.Parse(data.Uri.ValueString()) + endpoint := machines.NewListeningTentacleEndpoint(uri, data.Thumbprint.ValueString()) + endpoint.ProxyID = data.ProxyID.ValueString() + + worker := machines.NewWorker(data.Name.ValueString(), endpoint) + worker.SpaceID = data.SpaceID.ValueString() + worker.IsDisabled = data.IsDisabled.ValueBool() + worker.MachinePolicyID = data.MachinePolicyID.ValueString() + + if !data.WorkerPoolIDs.IsNull() { + var workerPools []string + data.WorkerPoolIDs.ElementsAs(ctx, &workerPools, false) + worker.WorkerPoolIDs = workerPools + } + + return worker +} + +func updateDataFromListeningTentacleWorker(ctx context.Context, data *schemas.ListeningTentacleWorkerResourceModel, spaceId string, worker *machines.Worker) { + data.ID = types.StringValue(worker.ID) + data.SpaceID = types.StringValue(spaceId) + data.Name = types.StringValue(worker.Name) + data.IsDisabled = types.BoolValue(worker.IsDisabled) + data.MachinePolicyID = types.StringValue(worker.MachinePolicyID) + data.WorkerPoolIDs, _ = types.ListValueFrom(ctx, types.StringType, worker.WorkerPoolIDs) + + endpoint := worker.Endpoint.(*machines.ListeningTentacleEndpoint) + data.Uri = types.StringValue(endpoint.URI.String()) + data.Thumbprint = types.StringValue(endpoint.Thumbprint) + if endpoint.ProxyID != "" { + data.ProxyID = types.StringValue(endpoint.ProxyID) + } +} + +func (*listeningTentacleWorkerResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go new file mode 100644 index 00000000..108fc287 --- /dev/null +++ b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go @@ -0,0 +1,150 @@ +package octopusdeploy_framework + +import ( + "fmt" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workers" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "strconv" + "strings" + "testing" +) + +type listeningTentacleWorkerTestData struct { + name string + spaceID string + isDisabled bool + workerPoolIDs []string + machinePolicyID string + uri string + thumbprint string + proxyID string +} + +func TestAccOctopusDeployListeningTentacleWorker(t *testing.T) { + localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) + prefix := "octopusdeploy_listening_tentacle_worker." + localName + createData := listeningTentacleWorkerTestData{ + name: acctest.RandStringFromCharSet(20, acctest.CharSetAlpha), + workerPoolIDs: []string{acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)}, + machinePolicyID: acctest.RandStringFromCharSet(8, acctest.CharSetAlpha), + uri: "https://listening.test", + thumbprint: strconv.FormatInt(int64(acctest.RandIntRange(0, 1024)), 16), + } + updateData := listeningTentacleWorkerTestData{ + name: createData.name + "-updated", + workerPoolIDs: append(createData.workerPoolIDs, acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)), + machinePolicyID: acctest.RandStringFromCharSet(8, acctest.CharSetAlpha), + uri: "https://listening.test.updated", + thumbprint: strconv.FormatInt(int64(acctest.RandIntRange(0, 1024)), 16), + isDisabled: true, + proxyID: acctest.RandStringFromCharSet(8, acctest.CharSetAlpha), + } + + resource.Test(t, resource.TestCase{ + CheckDestroy: func(s *terraform.State) error { return testListeningTentacleWorkerCheckDestroy(s) }, + PreCheck: func() { TestAccPreCheck(t) }, + ProtoV6ProviderFactories: ProtoV6ProviderFactories(), + Steps: []resource.TestStep{ + { + Config: testListeningTentacleWorkerMandatory(createData, localName), + Check: testAssertListeningTentacleWorkerMandatoryAttributes(createData, prefix), + }, + { + Config: testListeningTentacleWorkerAll(updateData, localName), + Check: testAssertListeningTentacleWorkerAllAttributes(updateData, prefix), + }, + }, + }) +} + +func testListeningTentacleWorkerMandatory(data listeningTentacleWorkerTestData, localName string) string { + return fmt.Sprintf(` + resource "octopusdeploy_listening_tentacle_worker" "%s" { + name = "%s" + machine_policy_id = "%s" + worker_pool_ids = "%s" + uri = "%s" + thumbprint = "%s" + } + `, + localName, + data.name, + data.machinePolicyID, + testSerializeWorkerPoolIdsForResource(data.workerPoolIDs), + data.uri, + data.thumbprint, + ) +} + +func testListeningTentacleWorkerAll(data listeningTentacleWorkerTestData, localName string) string { + return fmt.Sprintf(` + resource "octopusdeploy_listening_tentacle_worker" "%s" { + name = "%s" + machine_policy_id = "%s" + worker_pool_ids = "%s" + uri = "%s" + thumbprint = "%s" + proxy_id = "%s" + is_disabled = "%v" + } + `, + localName, + data.name, + data.machinePolicyID, + testSerializeWorkerPoolIdsForResource(data.workerPoolIDs), + data.uri, + data.thumbprint, + data.proxyID, + data.isDisabled, + ) +} + +func testAssertListeningTentacleWorkerMandatoryAttributes(expected listeningTentacleWorkerTestData, prefix string) resource.TestCheckFunc { + return resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(prefix, "name", expected.name), + resource.TestCheckResourceAttr(prefix, "machine_policy_id", expected.machinePolicyID), + resource.TestCheckResourceAttr(prefix, "worker_pool_ids", testSerializeWorkerPoolIdsForResource(expected.workerPoolIDs)), + resource.TestCheckResourceAttr(prefix, "uri", expected.uri), + resource.TestCheckResourceAttr(prefix, "thumbprint", expected.thumbprint), + resource.TestCheckNoResourceAttr(prefix, "proxy_id"), + resource.TestCheckNoResourceAttr(prefix, "is_disabled"), + ) +} + +func testAssertListeningTentacleWorkerAllAttributes(expected listeningTentacleWorkerTestData, prefix string) resource.TestCheckFunc { + return resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(prefix, "name", expected.name), + resource.TestCheckResourceAttr(prefix, "machine_policy_id", expected.machinePolicyID), + resource.TestCheckResourceAttr(prefix, "worker_pool_ids", testSerializeWorkerPoolIdsForResource(expected.workerPoolIDs)), + resource.TestCheckResourceAttr(prefix, "uri", expected.uri), + resource.TestCheckResourceAttr(prefix, "thumbprint", expected.thumbprint), + resource.TestCheckResourceAttr(prefix, "proxy_id", expected.proxyID), + resource.TestCheckResourceAttr(prefix, "is_disabled", strconv.FormatBool(expected.isDisabled)), + ) +} + +func testListeningTentacleWorkerCheckDestroy(s *terraform.State) error { + for _, rs := range s.RootModule().Resources { + if rs.Type != "octopusdeploy_listening_tentacle_worker" { + continue + } + + feed, err := workers.GetByID(octoClient, octoClient.GetSpaceID(), rs.Primary.ID) + if err == nil && feed != nil { + return fmt.Errorf("listening tentacle worker (%s) still exists", rs.Primary.ID) + } + } + + return nil +} + +func testSerializeWorkerPoolIdsForResource(poolIds []string) string { + quotedPoolIds := make([]string, len(poolIds)) + for i, poolId := range poolIds { + quotedPoolIds[i] = fmt.Sprintf(`"%s"`, poolId) + } + + return "[" + strings.Join(quotedPoolIds, ",") + "]" +} diff --git a/octopusdeploy_framework/schemas/listening_tentacle_worker.go b/octopusdeploy_framework/schemas/listening_tentacle_worker.go new file mode 100644 index 00000000..7f01fb9d --- /dev/null +++ b/octopusdeploy_framework/schemas/listening_tentacle_worker.go @@ -0,0 +1,54 @@ +package schemas + +import ( + "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" + datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +type ListeningTentacleWorkerSchema struct{} + +func (m ListeningTentacleWorkerSchema) GetResourceSchema() resourceSchema.Schema { + return resourceSchema.Schema{ + Description: "This resource manages a listening tentacle worker in Octopus Deploy.", + Attributes: map[string]resourceSchema.Attribute{ + "id": GetIdResourceSchema(), + "name": GetNameResourceSchema(true), + "space_id": GetSpaceIdResourceSchema("Listening tentacle worker"), + "is_disabled": GetOptionalBooleanResourceAttribute("When disabled, worker will not be included in any deployments", false), + "machine_policy_id": GetRequiredStringResourceSchema("Select the machine policy"), + "uri": GetRequiredStringResourceSchema("The network address at which the Tentacle can be reached"), + "thumbprint": GetRequiredStringResourceSchema("The X509 certificate thumbprint that securely identifies the Tentacle"), + "proxy_id": GetOptionalStringResourceSchema("Specify the connection type for the Tentacle: direct(when not set) or via a proxy server."), + "worker_pool_ids": resourceSchema.ListAttribute{ + ElementType: types.StringType, + Description: "Select at least one worker pool for the worker", + Required: true, + Validators: []validator.List{ + listvalidator.SizeAtLeast(1), + }, + }, + }, + } +} + +func (m ListeningTentacleWorkerSchema) GetDatasourceSchema() datasourceSchema.Schema { + return datasourceSchema.Schema{} +} + +var _ EntitySchema = ListeningTentacleWorkerSchema{} + +type ListeningTentacleWorkerResourceModel struct { + Name types.String `tfsdk:"name"` + SpaceID types.String `tfsdk:"space_id"` + IsDisabled types.Bool `tfsdk:"is_disabled"` + WorkerPoolIDs types.List `tfsdk:"worker_pool_ids"` + MachinePolicyID types.String `tfsdk:"machine_policy_id"` + Uri types.String `tfsdk:"uri"` + Thumbprint types.String `tfsdk:"thumbprint"` + ProxyID types.String `tfsdk:"proxy_id"` + + ResourceModel +} From 5686c7fe6beb18919a337d55543113c8cd86269e Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Wed, 13 Nov 2024 10:19:27 +1300 Subject: [PATCH 02/11] Remove quotes around array attribute --- .../resource_listening_tentacle_worker_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go index 108fc287..f1446abd 100644 --- a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go +++ b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go @@ -64,7 +64,7 @@ func testListeningTentacleWorkerMandatory(data listeningTentacleWorkerTestData, resource "octopusdeploy_listening_tentacle_worker" "%s" { name = "%s" machine_policy_id = "%s" - worker_pool_ids = "%s" + worker_pool_ids = %s uri = "%s" thumbprint = "%s" } @@ -83,7 +83,7 @@ func testListeningTentacleWorkerAll(data listeningTentacleWorkerTestData, localN resource "octopusdeploy_listening_tentacle_worker" "%s" { name = "%s" machine_policy_id = "%s" - worker_pool_ids = "%s" + worker_pool_ids = %s uri = "%s" thumbprint = "%s" proxy_id = "%s" From 62b07630846c0272150ee4d17953d0277cdc64f7 Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Wed, 13 Nov 2024 13:03:54 +1300 Subject: [PATCH 03/11] Create resources required for listening worker test --- ...resource_listening_tentacle_worker_test.go | 184 ++++++++++++------ 1 file changed, 127 insertions(+), 57 deletions(-) diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go index f1446abd..81f1ed67 100644 --- a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go +++ b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go @@ -12,34 +12,33 @@ import ( ) type listeningTentacleWorkerTestData struct { - name string - spaceID string - isDisabled bool - workerPoolIDs []string - machinePolicyID string - uri string - thumbprint string - proxyID string + name string + spaceID string + isDisabled bool + uri string + thumbprint string +} + +type listeningTentacleWorkerTestDependenciesData struct { + policy string + pool1 string + pool2 string + proxy string } func TestAccOctopusDeployListeningTentacleWorker(t *testing.T) { localName := acctest.RandStringFromCharSet(20, acctest.CharSetAlpha) prefix := "octopusdeploy_listening_tentacle_worker." + localName createData := listeningTentacleWorkerTestData{ - name: acctest.RandStringFromCharSet(20, acctest.CharSetAlpha), - workerPoolIDs: []string{acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)}, - machinePolicyID: acctest.RandStringFromCharSet(8, acctest.CharSetAlpha), - uri: "https://listening.test", - thumbprint: strconv.FormatInt(int64(acctest.RandIntRange(0, 1024)), 16), + name: acctest.RandStringFromCharSet(20, acctest.CharSetAlpha), + uri: "https://listening.test", + thumbprint: strconv.FormatInt(int64(acctest.RandIntRange(0, 1024)), 16), } updateData := listeningTentacleWorkerTestData{ - name: createData.name + "-updated", - workerPoolIDs: append(createData.workerPoolIDs, acctest.RandStringFromCharSet(10, acctest.CharSetAlpha)), - machinePolicyID: acctest.RandStringFromCharSet(8, acctest.CharSetAlpha), - uri: "https://listening.test.updated", - thumbprint: strconv.FormatInt(int64(acctest.RandIntRange(0, 1024)), 16), - isDisabled: true, - proxyID: acctest.RandStringFromCharSet(8, acctest.CharSetAlpha), + name: createData.name + "-updated", + uri: "https://listening.test.updated", + thumbprint: strconv.FormatInt(int64(acctest.RandIntRange(0, 1024)), 16), + isDisabled: true, } resource.Test(t, resource.TestCase{ @@ -48,81 +47,161 @@ func TestAccOctopusDeployListeningTentacleWorker(t *testing.T) { ProtoV6ProviderFactories: ProtoV6ProviderFactories(), Steps: []resource.TestStep{ { - Config: testListeningTentacleWorkerMandatory(createData, localName), - Check: testAssertListeningTentacleWorkerMandatoryAttributes(createData, prefix), + Config: testListeningTentacleWorkerCreate(createData, localName), + Check: testAssertListeningTentacleWorkerCreate(createData, prefix), }, { - Config: testListeningTentacleWorkerAll(updateData, localName), - Check: testAssertListeningTentacleWorkerAllAttributes(updateData, prefix), + Config: testListeningTentacleWorkerUpdate(updateData, localName), + Check: testAssertListeningTentacleWorkerUpdate(updateData, prefix), }, }, }) } -func testListeningTentacleWorkerMandatory(data listeningTentacleWorkerTestData, localName string) string { +func testListeningTentacleWorkerCreate(data listeningTentacleWorkerTestData, localName string) string { + source, references := testListeningTentacleWorkerDependencies(localName) + return fmt.Sprintf(` + %s resource "octopusdeploy_listening_tentacle_worker" "%s" { name = "%s" machine_policy_id = "%s" - worker_pool_ids = %s + worker_pool_ids = [%s] uri = "%s" thumbprint = "%s" } `, + source, localName, data.name, - data.machinePolicyID, - testSerializeWorkerPoolIdsForResource(data.workerPoolIDs), + references.policy, + references.pool1, data.uri, data.thumbprint, ) } -func testListeningTentacleWorkerAll(data listeningTentacleWorkerTestData, localName string) string { +func testAssertListeningTentacleWorkerCreate(expected listeningTentacleWorkerTestData, prefix string) resource.TestCheckFunc { + return resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(prefix, "name", expected.name), + resource.TestCheckResourceAttrWith(prefix, "machine_policy_id", func(value string) error { + if len(value) > 0 { + return nil + } + return fmt.Errorf("machine policy should be set") + }), + resource.TestCheckResourceAttrWith(prefix, "worker_pool_ids", func(value string) error { + if strings.HasPrefix(value, "[") && strings.HasSuffix(value, "]") { + return nil + } + return fmt.Errorf("worker pools should be set") + }), + resource.TestCheckResourceAttr(prefix, "uri", expected.uri), + resource.TestCheckResourceAttr(prefix, "thumbprint", expected.thumbprint), + resource.TestCheckNoResourceAttr(prefix, "proxy_id"), + resource.TestCheckNoResourceAttr(prefix, "is_disabled"), + ) +} + +func testListeningTentacleWorkerUpdate(data listeningTentacleWorkerTestData, localName string) string { + source, references := testListeningTentacleWorkerDependencies(localName) + return fmt.Sprintf(` + %s resource "octopusdeploy_listening_tentacle_worker" "%s" { name = "%s" machine_policy_id = "%s" - worker_pool_ids = %s + worker_pool_ids = [%s, %s] uri = "%s" thumbprint = "%s" - proxy_id = "%s" + proxy_id = %s is_disabled = "%v" } `, + source, localName, data.name, - data.machinePolicyID, - testSerializeWorkerPoolIdsForResource(data.workerPoolIDs), + references.policy, + references.pool1, + references.pool2, data.uri, data.thumbprint, - data.proxyID, + references.proxy, data.isDisabled, ) } -func testAssertListeningTentacleWorkerMandatoryAttributes(expected listeningTentacleWorkerTestData, prefix string) resource.TestCheckFunc { +func testAssertListeningTentacleWorkerUpdate(expected listeningTentacleWorkerTestData, prefix string) resource.TestCheckFunc { return resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(prefix, "name", expected.name), - resource.TestCheckResourceAttr(prefix, "machine_policy_id", expected.machinePolicyID), - resource.TestCheckResourceAttr(prefix, "worker_pool_ids", testSerializeWorkerPoolIdsForResource(expected.workerPoolIDs)), + resource.TestCheckResourceAttrWith(prefix, "machine_policy_id", func(value string) error { + if len(value) > 0 { + return nil + } + return fmt.Errorf("machine policy should be set") + }), + resource.TestCheckResourceAttrWith(prefix, "worker_pool_ids", func(value string) error { + if strings.HasPrefix(value, "[") && strings.HasSuffix(value, "]") { + return nil + } + return fmt.Errorf("worker pools should be set") + }), resource.TestCheckResourceAttr(prefix, "uri", expected.uri), resource.TestCheckResourceAttr(prefix, "thumbprint", expected.thumbprint), - resource.TestCheckNoResourceAttr(prefix, "proxy_id"), - resource.TestCheckNoResourceAttr(prefix, "is_disabled"), + resource.TestCheckResourceAttrWith(prefix, "proxy_id", func(value string) error { + if len(value) > 0 { + return nil + } + return fmt.Errorf("machine proxy should be set") + }), + resource.TestCheckResourceAttr(prefix, "is_disabled", strconv.FormatBool(expected.isDisabled)), ) } -func testAssertListeningTentacleWorkerAllAttributes(expected listeningTentacleWorkerTestData, prefix string) resource.TestCheckFunc { - return resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(prefix, "name", expected.name), - resource.TestCheckResourceAttr(prefix, "machine_policy_id", expected.machinePolicyID), - resource.TestCheckResourceAttr(prefix, "worker_pool_ids", testSerializeWorkerPoolIdsForResource(expected.workerPoolIDs)), - resource.TestCheckResourceAttr(prefix, "uri", expected.uri), - resource.TestCheckResourceAttr(prefix, "thumbprint", expected.thumbprint), - resource.TestCheckResourceAttr(prefix, "proxy_id", expected.proxyID), - resource.TestCheckResourceAttr(prefix, "is_disabled", strconv.FormatBool(expected.isDisabled)), +func testListeningTentacleWorkerDependencies(localName string) (string, listeningTentacleWorkerTestDependenciesData) { + policy := fmt.Sprintf("policy_%s", localName) + pool1 := fmt.Sprintf("pool_1_%s", localName) + pool2 := fmt.Sprintf("pool_2_%s", localName) + proxy := fmt.Sprintf("proxy_%s", localName) + source := fmt.Sprintf(` + resource "octopusdeploy_machine_policy" "%s" { + name = "Listening policy" + } + + resource "octopusdeploy_static_worker_pool" "%s" { + name = "Listening poll 1" + description = "First pool of listening workers" + sort_order = 42 + } + + resource "octopusdeploy_static_worker_pool" "%s" { + name = "Listening poll 2" + description = "Second pool of listening workers" + sort_order = 43 + } + + resource "octopusdeploy_machine_proxy" "%s" { + name = "Listening proxy" + host = "localhost" + port = 20034 + username = "user_proxy" + password = "secret_proxy" + } + `, + policy, + pool1, + pool2, + proxy, ) + + dependencies := listeningTentacleWorkerTestDependenciesData{ + policy: fmt.Sprintf("octopusdeploy_machine_policy.%s.id", policy), + pool1: fmt.Sprintf("octopusdeploy_static_worker_pool.%s.id", pool1), + pool2: fmt.Sprintf("octopusdeploy_static_worker_pool.%s.id", pool2), + proxy: fmt.Sprintf("octopusdeploy_machine_proxy.%s.id", proxy), + } + + return source, dependencies } func testListeningTentacleWorkerCheckDestroy(s *terraform.State) error { @@ -139,12 +218,3 @@ func testListeningTentacleWorkerCheckDestroy(s *terraform.State) error { return nil } - -func testSerializeWorkerPoolIdsForResource(poolIds []string) string { - quotedPoolIds := make([]string, len(poolIds)) - for i, poolId := range poolIds { - quotedPoolIds[i] = fmt.Sprintf(`"%s"`, poolId) - } - - return "[" + strings.Join(quotedPoolIds, ",") + "]" -} From 4e10388ca9a6585ec83a4c82b93309367ce59097 Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Wed, 13 Nov 2024 13:58:03 +1300 Subject: [PATCH 04/11] Remove quotes around referenced identifier --- .../resource_listening_tentacle_worker_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go index 81f1ed67..e3c73057 100644 --- a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go +++ b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go @@ -65,7 +65,7 @@ func testListeningTentacleWorkerCreate(data listeningTentacleWorkerTestData, loc %s resource "octopusdeploy_listening_tentacle_worker" "%s" { name = "%s" - machine_policy_id = "%s" + machine_policy_id = %s worker_pool_ids = [%s] uri = "%s" thumbprint = "%s" @@ -110,12 +110,12 @@ func testListeningTentacleWorkerUpdate(data listeningTentacleWorkerTestData, loc %s resource "octopusdeploy_listening_tentacle_worker" "%s" { name = "%s" - machine_policy_id = "%s" + machine_policy_id = %s worker_pool_ids = [%s, %s] uri = "%s" thumbprint = "%s" proxy_id = %s - is_disabled = "%v" + is_disabled = %v } `, source, From 8b31da8397f5b067b95ed5f36b34c63c075bae36 Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Wed, 13 Nov 2024 15:23:02 +1300 Subject: [PATCH 05/11] Use trailing '/' in uri for worker resource --- .../resource_listening_tentacle_worker_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go index e3c73057..54769f4a 100644 --- a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go +++ b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go @@ -31,12 +31,12 @@ func TestAccOctopusDeployListeningTentacleWorker(t *testing.T) { prefix := "octopusdeploy_listening_tentacle_worker." + localName createData := listeningTentacleWorkerTestData{ name: acctest.RandStringFromCharSet(20, acctest.CharSetAlpha), - uri: "https://listening.test", + uri: "https://listening.test/", thumbprint: strconv.FormatInt(int64(acctest.RandIntRange(0, 1024)), 16), } updateData := listeningTentacleWorkerTestData{ name: createData.name + "-updated", - uri: "https://listening.test.updated", + uri: "https://listening.test.updated/", thumbprint: strconv.FormatInt(int64(acctest.RandIntRange(0, 1024)), 16), isDisabled: true, } From 1a0bd7916ec0cb2f0ae86d6530836bc6565bdfea Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Wed, 13 Nov 2024 16:03:36 +1300 Subject: [PATCH 06/11] Test that attributes of referenced resources are set. --- ...resource_listening_tentacle_worker_test.go | 36 +++---------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go index 54769f4a..562b988c 100644 --- a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go +++ b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "strconv" - "strings" "testing" ) @@ -84,18 +83,8 @@ func testListeningTentacleWorkerCreate(data listeningTentacleWorkerTestData, loc func testAssertListeningTentacleWorkerCreate(expected listeningTentacleWorkerTestData, prefix string) resource.TestCheckFunc { return resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(prefix, "name", expected.name), - resource.TestCheckResourceAttrWith(prefix, "machine_policy_id", func(value string) error { - if len(value) > 0 { - return nil - } - return fmt.Errorf("machine policy should be set") - }), - resource.TestCheckResourceAttrWith(prefix, "worker_pool_ids", func(value string) error { - if strings.HasPrefix(value, "[") && strings.HasSuffix(value, "]") { - return nil - } - return fmt.Errorf("worker pools should be set") - }), + resource.TestCheckResourceAttrSet(prefix, "machine_policy_id"), + resource.TestCheckResourceAttrSet(prefix, "worker_pool_ids"), resource.TestCheckResourceAttr(prefix, "uri", expected.uri), resource.TestCheckResourceAttr(prefix, "thumbprint", expected.thumbprint), resource.TestCheckNoResourceAttr(prefix, "proxy_id"), @@ -134,26 +123,11 @@ func testListeningTentacleWorkerUpdate(data listeningTentacleWorkerTestData, loc func testAssertListeningTentacleWorkerUpdate(expected listeningTentacleWorkerTestData, prefix string) resource.TestCheckFunc { return resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(prefix, "name", expected.name), - resource.TestCheckResourceAttrWith(prefix, "machine_policy_id", func(value string) error { - if len(value) > 0 { - return nil - } - return fmt.Errorf("machine policy should be set") - }), - resource.TestCheckResourceAttrWith(prefix, "worker_pool_ids", func(value string) error { - if strings.HasPrefix(value, "[") && strings.HasSuffix(value, "]") { - return nil - } - return fmt.Errorf("worker pools should be set") - }), + resource.TestCheckResourceAttrSet(prefix, "machine_policy_id"), + resource.TestCheckResourceAttrSet(prefix, "worker_pool_ids"), resource.TestCheckResourceAttr(prefix, "uri", expected.uri), resource.TestCheckResourceAttr(prefix, "thumbprint", expected.thumbprint), - resource.TestCheckResourceAttrWith(prefix, "proxy_id", func(value string) error { - if len(value) > 0 { - return nil - } - return fmt.Errorf("machine proxy should be set") - }), + resource.TestCheckResourceAttrSet(prefix, "proxy_id"), resource.TestCheckResourceAttr(prefix, "is_disabled", strconv.FormatBool(expected.isDisabled)), ) } From 6f7ad66bd7c90b1376c6b33b39320837e56e661c Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Thu, 14 Nov 2024 08:50:03 +1300 Subject: [PATCH 07/11] Assert amount of worker pools in the resource --- .../resource_listening_tentacle_worker_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go index 562b988c..151cf59b 100644 --- a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go +++ b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go @@ -84,7 +84,7 @@ func testAssertListeningTentacleWorkerCreate(expected listeningTentacleWorkerTes return resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(prefix, "name", expected.name), resource.TestCheckResourceAttrSet(prefix, "machine_policy_id"), - resource.TestCheckResourceAttrSet(prefix, "worker_pool_ids"), + resource.TestCheckResourceAttr(prefix, "worker_pool_ids.#", "1"), resource.TestCheckResourceAttr(prefix, "uri", expected.uri), resource.TestCheckResourceAttr(prefix, "thumbprint", expected.thumbprint), resource.TestCheckNoResourceAttr(prefix, "proxy_id"), @@ -124,7 +124,7 @@ func testAssertListeningTentacleWorkerUpdate(expected listeningTentacleWorkerTes return resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(prefix, "name", expected.name), resource.TestCheckResourceAttrSet(prefix, "machine_policy_id"), - resource.TestCheckResourceAttrSet(prefix, "worker_pool_ids"), + resource.TestCheckResourceAttr(prefix, "worker_pool_ids.#", "2"), resource.TestCheckResourceAttr(prefix, "uri", expected.uri), resource.TestCheckResourceAttr(prefix, "thumbprint", expected.thumbprint), resource.TestCheckResourceAttrSet(prefix, "proxy_id"), From 869cff05923939d6cd6a8dad1bc49db770bea8a0 Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Thu, 14 Nov 2024 09:17:42 +1300 Subject: [PATCH 08/11] Expect is_disabled to be false by default --- .../resource_listening_tentacle_worker_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go index 151cf59b..e42fc3f0 100644 --- a/octopusdeploy_framework/resource_listening_tentacle_worker_test.go +++ b/octopusdeploy_framework/resource_listening_tentacle_worker_test.go @@ -88,7 +88,7 @@ func testAssertListeningTentacleWorkerCreate(expected listeningTentacleWorkerTes resource.TestCheckResourceAttr(prefix, "uri", expected.uri), resource.TestCheckResourceAttr(prefix, "thumbprint", expected.thumbprint), resource.TestCheckNoResourceAttr(prefix, "proxy_id"), - resource.TestCheckNoResourceAttr(prefix, "is_disabled"), + resource.TestCheckResourceAttr(prefix, "is_disabled", "false"), ) } From 32c8e91f58789bde4ba54166acc60cc9efb250e3 Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Thu, 14 Nov 2024 11:11:32 +1300 Subject: [PATCH 09/11] Use Set type instead of List type to avoid issues with inconsistent ordering --- .../schemas/listening_tentacle_worker.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/octopusdeploy_framework/schemas/listening_tentacle_worker.go b/octopusdeploy_framework/schemas/listening_tentacle_worker.go index 7f01fb9d..c8e032dc 100644 --- a/octopusdeploy_framework/schemas/listening_tentacle_worker.go +++ b/octopusdeploy_framework/schemas/listening_tentacle_worker.go @@ -1,7 +1,7 @@ package schemas import ( - "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -22,12 +22,12 @@ func (m ListeningTentacleWorkerSchema) GetResourceSchema() resourceSchema.Schema "uri": GetRequiredStringResourceSchema("The network address at which the Tentacle can be reached"), "thumbprint": GetRequiredStringResourceSchema("The X509 certificate thumbprint that securely identifies the Tentacle"), "proxy_id": GetOptionalStringResourceSchema("Specify the connection type for the Tentacle: direct(when not set) or via a proxy server."), - "worker_pool_ids": resourceSchema.ListAttribute{ + "worker_pool_ids": resourceSchema.SetAttribute{ ElementType: types.StringType, Description: "Select at least one worker pool for the worker", Required: true, - Validators: []validator.List{ - listvalidator.SizeAtLeast(1), + Validators: []validator.Set{ + setvalidator.SizeAtLeast(1), }, }, }, @@ -44,7 +44,7 @@ type ListeningTentacleWorkerResourceModel struct { Name types.String `tfsdk:"name"` SpaceID types.String `tfsdk:"space_id"` IsDisabled types.Bool `tfsdk:"is_disabled"` - WorkerPoolIDs types.List `tfsdk:"worker_pool_ids"` + WorkerPoolIDs types.Set `tfsdk:"worker_pool_ids"` MachinePolicyID types.String `tfsdk:"machine_policy_id"` Uri types.String `tfsdk:"uri"` Thumbprint types.String `tfsdk:"thumbprint"` From 5c0a90629efecbef781e4dc1aa6d03d7fb1b3000 Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Thu, 14 Nov 2024 11:12:11 +1300 Subject: [PATCH 10/11] Use dedicated Azure schema for azure feed resource --- octopusdeploy_framework/resource_azure_container_registry.go | 4 ++-- octopusdeploy_framework/resource_listening_tentacle_worker.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/octopusdeploy_framework/resource_azure_container_registry.go b/octopusdeploy_framework/resource_azure_container_registry.go index ae563802..0430a10a 100644 --- a/octopusdeploy_framework/resource_azure_container_registry.go +++ b/octopusdeploy_framework/resource_azure_container_registry.go @@ -30,7 +30,7 @@ func (r *azureContainerRegistryFeedTypeResource) Metadata(ctx context.Context, r } func (r *azureContainerRegistryFeedTypeResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schemas.GoogleContainerRegistryFeedSchema{}.GetResourceSchema() + resp.Schema = schemas.AzureContainerRegistryFeedSchema{}.GetResourceSchema() } func (r *azureContainerRegistryFeedTypeResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { @@ -117,7 +117,7 @@ func (r *azureContainerRegistryFeedTypeResource) Update(ctx context.Context, req updateAzureDataFromDockerContainerRegistryFeed(data, state.SpaceID.ValueString(), updatedFeed.(*feeds.DockerContainerRegistry)) - tflog.Info(ctx, fmt.Sprintf("Google Container Registry feed updated (%s)", data.ID)) + tflog.Info(ctx, fmt.Sprintf("Azure Container Registry feed updated (%s)", data.ID)) resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker.go b/octopusdeploy_framework/resource_listening_tentacle_worker.go index fefd2db5..0663656a 100644 --- a/octopusdeploy_framework/resource_listening_tentacle_worker.go +++ b/octopusdeploy_framework/resource_listening_tentacle_worker.go @@ -159,7 +159,7 @@ func updateDataFromListeningTentacleWorker(ctx context.Context, data *schemas.Li data.Name = types.StringValue(worker.Name) data.IsDisabled = types.BoolValue(worker.IsDisabled) data.MachinePolicyID = types.StringValue(worker.MachinePolicyID) - data.WorkerPoolIDs, _ = types.ListValueFrom(ctx, types.StringType, worker.WorkerPoolIDs) + data.WorkerPoolIDs, _ = types.SetValueFrom(ctx, types.StringType, worker.WorkerPoolIDs) endpoint := worker.Endpoint.(*machines.ListeningTentacleEndpoint) data.Uri = types.StringValue(endpoint.URI.String()) From ef036367aed46bb1ca48c8b0c83d0d725da157ca Mon Sep 17 00:00:00 2001 From: "denys.kostynchuk" Date: Thu, 14 Nov 2024 11:46:52 +1300 Subject: [PATCH 11/11] Update docs fro azure container registry --- docs/resources/azure_container_registry.md | 6 +++--- docs/resources/listening_tentacle_worker.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/resources/azure_container_registry.md b/docs/resources/azure_container_registry.md index 1c863c38..93dc192e 100644 --- a/docs/resources/azure_container_registry.md +++ b/docs/resources/azure_container_registry.md @@ -3,12 +3,12 @@ page_title: "octopusdeploy_azure_container_registry Resource - terraform-provider-octopusdeploy" subcategory: "" description: |- - This resource manages a Google Container Registry feed in Octopus Deploy (alias of Docker Container Registry feed) + This resource manages Azure Container Registry feed in Octopus Deploy (alias of Docker Container Registry feed) --- # octopusdeploy_azure_container_registry (Resource) -This resource manages a Google Container Registry feed in Octopus Deploy (alias of Docker Container Registry feed) +This resource manages Azure Container Registry feed in Octopus Deploy (alias of Docker Container Registry feed) ## Example Usage @@ -34,7 +34,7 @@ resource "octopusdeploy_azure_container_registry" "example" { - `api_version` (String) - `password` (String, Sensitive) The password associated with this resource. - `registry_path` (String) -- `space_id` (String) The space ID associated with this Google container registry feed. +- `space_id` (String) The space ID associated with this Azure container registry feed. - `username` (String, Sensitive) The username associated with this resource. ### Read-Only diff --git a/docs/resources/listening_tentacle_worker.md b/docs/resources/listening_tentacle_worker.md index 78c46b61..5a468a6e 100644 --- a/docs/resources/listening_tentacle_worker.md +++ b/docs/resources/listening_tentacle_worker.md @@ -41,7 +41,7 @@ resource "octopusdeploy_listening_tentacle_worker" "optionals" { - `name` (String) The name of this resource. - `thumbprint` (String) The X509 certificate thumbprint that securely identifies the Tentacle - `uri` (String) The network address at which the Tentacle can be reached -- `worker_pool_ids` (List of String) Select at least one worker pool for the worker +- `worker_pool_ids` (Set of String) Select at least one worker pool for the worker ### Optional