From 49e1b33cee2e0091634f226cf2000377e368ecbb Mon Sep 17 00:00:00 2001 From: Shane Gill Date: Mon, 16 Oct 2023 10:38:41 +1000 Subject: [PATCH] feat: spaceID support environment --- octopusdeploy/config.go | 2 +- octopusdeploy/data_source_environments.go | 2 +- octopusdeploy/resource_environment.go | 9 +++++---- octopusdeploy/schema_environment.go | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/octopusdeploy/config.go b/octopusdeploy/config.go index c0e1a5ca9..296ac3e02 100644 --- a/octopusdeploy/config.go +++ b/octopusdeploy/config.go @@ -23,7 +23,7 @@ func (c *Config) Client() (*client.Client, diag.Diagnostics) { } // This is intentional on the feature branch - Todo: remove when merging to main branch - proxyStr := "http://127.0.0.1:8866" + proxyStr := "http://172.21.224.1:8866" proxyURL, err := url.Parse(proxyStr) if err != nil { return nil, nil diff --git a/octopusdeploy/data_source_environments.go b/octopusdeploy/data_source_environments.go index 4300fd927..460474c83 100644 --- a/octopusdeploy/data_source_environments.go +++ b/octopusdeploy/data_source_environments.go @@ -28,7 +28,7 @@ func dataSourceEnvironmentsRead(ctx context.Context, d *schema.ResourceData, m i } client := m.(*client.Client) - existingEnvironments, err := client.Environments.Get(query) + existingEnvironments, err := environments.Get(client, d.Get("space_id").(string), query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/resource_environment.go b/octopusdeploy/resource_environment.go index c5e8f5a77..66559a19d 100644 --- a/octopusdeploy/resource_environment.go +++ b/octopusdeploy/resource_environment.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments" "github.com/OctopusDeploy/terraform-provider-octopusdeploy/internal/errors" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -28,7 +29,7 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, m in log.Printf("[INFO] creating environment: %#v", environment) client := m.(*client.Client) - createdEnvironment, err := client.Environments.Add(environment) + createdEnvironment, err := environments.Add(client, environment) if err != nil { return diag.FromErr(err) } @@ -47,7 +48,7 @@ func resourceEnvironmentDelete(ctx context.Context, d *schema.ResourceData, m in log.Printf("[INFO] deleting environment (%s)", d.Id()) client := m.(*client.Client) - if err := client.Environments.DeleteByID(d.Id()); err != nil { + if err := environments.DeleteByID(client, d.Get("space_id").(string), d.Id()); err != nil { return diag.FromErr(err) } @@ -60,7 +61,7 @@ func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, m inte log.Printf("[INFO] reading environment (%s)", d.Id()) client := m.(*client.Client) - environment, err := client.Environments.GetByID(d.Id()) + environment, err := environments.GetByID(client, d.Get("space_id").(string), d.Id()) if err != nil { return errors.ProcessApiError(ctx, d, err, "environment") } @@ -78,7 +79,7 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, m in environment := expandEnvironment(d) client := m.(*client.Client) - updatedEnvironment, err := client.Environments.Update(environment) + updatedEnvironment, err := environments.Update(client, d.Get("space_id").(string), environment) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/schema_environment.go b/octopusdeploy/schema_environment.go index 8458888e5..babb495ab 100644 --- a/octopusdeploy/schema_environment.go +++ b/octopusdeploy/schema_environment.go @@ -112,6 +112,7 @@ func getEnvironmentDataSchema() map[string]*schema.Schema { "partial_name": getQueryPartialName(), "skip": getQuerySkip(), "take": getQueryTake(), + "space_id": getSpaceIDSchema(), } }