diff --git a/go.mod b/go.mod index 109b957ed..c2b26e082 100644 --- a/go.mod +++ b/go.mod @@ -142,3 +142,5 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/gotestsum v1.10.0 // indirect ) + +replace github.com/OctopusDeploy/go-octopusdeploy/v2 => ../go-octopusdeploy/ \ No newline at end of file diff --git a/octopusdeploy/config.go b/octopusdeploy/config.go index 3eaa4e3d4..c0e1a5ca9 100644 --- a/octopusdeploy/config.go +++ b/octopusdeploy/config.go @@ -1,6 +1,7 @@ package octopusdeploy import ( + "net/http" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" @@ -21,7 +22,19 @@ func (c *Config) Client() (*client.Client, diag.Diagnostics) { return nil, diag.FromErr(err) } - octopus, err := client.NewClient(nil, apiURL, c.APIKey, "") + // This is intentional on the feature branch - Todo: remove when merging to main branch + proxyStr := "http://127.0.0.1:8866" + proxyURL, err := url.Parse(proxyStr) + if err != nil { + return nil, nil + } + + tr := &http.Transport{ + Proxy: http.ProxyURL(proxyURL), + } + httpClient := http.Client{Transport: tr} + + octopus, err := client.NewClient(&httpClient, apiURL, c.APIKey, "") if err != nil { return nil, diag.FromErr(err) } @@ -32,7 +45,7 @@ func (c *Config) Client() (*client.Client, diag.Diagnostics) { return nil, diag.FromErr(err) } - octopus, err = client.NewClient(nil, apiURL, c.APIKey, space.GetID()) + octopus, err = client.NewClient(&httpClient, apiURL, c.APIKey, space.GetID()) if err != nil { return nil, diag.FromErr(err) } diff --git a/octopusdeploy/provider.go b/octopusdeploy/provider.go index 34e93ac41..fcf2b2ae9 100644 --- a/octopusdeploy/provider.go +++ b/octopusdeploy/provider.go @@ -110,7 +110,7 @@ func Provider() *schema.Provider { }, "space_id": { Description: "The space ID to target", - Optional: true, + Required: true, Type: schema.TypeString, }, }, @@ -123,10 +123,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{} config := Config{ Address: d.Get("address").(string), APIKey: d.Get("api_key").(string), - } - - if spaceID, ok := d.GetOk("space_id"); ok { - config.SpaceID = spaceID.(string) + SpaceID: d.Get("space_id").(string), } return config.Client() diff --git a/octopusdeploy/resource_library_variable_set.go b/octopusdeploy/resource_library_variable_set.go index 7e8999b93..a23ae54ed 100644 --- a/octopusdeploy/resource_library_variable_set.go +++ b/octopusdeploy/resource_library_variable_set.go @@ -5,6 +5,7 @@ import ( "log" "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client" + "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/libraryvariableset" "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,8 @@ func resourceLibraryVariableSetCreate(ctx context.Context, d *schema.ResourceDat log.Printf("[INFO] creating library variable set: %#v", libraryVariableSet) client := m.(*client.Client) - createdLibraryVariableSet, err := client.LibraryVariableSets.Add(libraryVariableSet) + + createdLibraryVariableSet, err := libraryvariableset.Add(client, libraryVariableSet) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/schema_library_variable_set.go b/octopusdeploy/schema_library_variable_set.go index a6cc108c9..db2628d19 100644 --- a/octopusdeploy/schema_library_variable_set.go +++ b/octopusdeploy/schema_library_variable_set.go @@ -18,6 +18,10 @@ func expandLibraryVariableSet(d *schema.ResourceData) *variables.LibraryVariable libraryVariableSet.Description = v.(string) } + if v, ok := d.GetOk("space_id"); ok { + libraryVariableSet.SpaceID = v.(string) + } + if attr, ok := d.GetOk("template"); ok { tfTemplates := attr.([]interface{})