Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: spaceID support environment #551

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion octopusdeploy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"net/http"
"net/url"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"

Check failure on line 7 in octopusdeploy/config.go

View workflow job for this annotation

GitHub Actions / build

github.com/OctopusDeploy/go-octopusdeploy/[email protected]: replacement directory ../go-octopusdeploy/ does not exist
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
)

Expand All @@ -23,7 +23,7 @@
}

// 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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this change and keep it local for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, I forgot!

domenicsim1 marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -5,7 +5,7 @@
"time"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments"

Check failure on line 8 in octopusdeploy/data_source_environments.go

View workflow job for this annotation

GitHub Actions / build

github.com/OctopusDeploy/go-octopusdeploy/[email protected]: replacement directory ../go-octopusdeploy/ does not exist
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand All @@ -28,7 +28,7 @@
}

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
Loading