Skip to content

Commit

Permalink
feat: spaceID support environment
Browse files Browse the repository at this point in the history
  • Loading branch information
tothegills committed Oct 16, 2023
1 parent 4124c4c commit 49e1b33
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion octopusdeploy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/data_source_environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
9 changes: 5 additions & 4 deletions octopusdeploy/resource_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
Expand All @@ -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)
}

Expand All @@ -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")
}
Expand All @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions octopusdeploy/schema_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func getEnvironmentDataSchema() map[string]*schema.Schema {
"partial_name": getQueryPartialName(),
"skip": getQuerySkip(),
"take": getQueryTake(),
"space_id": getSpaceIDSchema(),
}
}

Expand Down

0 comments on commit 49e1b33

Please sign in to comment.