diff --git a/main.go b/main.go index 31b6fc29..63a681dc 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,8 @@ func main() { flag.Parse() opts := &plugin.ServeOpts{ - ProviderFunc: octopusdeploy.Provider} + ProviderFunc: octopusdeploy.Provider, + } if debugMode { opts.Debug = true diff --git a/octopusdeploy/data_source_accounts.go b/octopusdeploy/data_source_accounts.go index 778a42ef..52acb1ab 100644 --- a/octopusdeploy/data_source_accounts.go +++ b/octopusdeploy/data_source_accounts.go @@ -27,9 +27,10 @@ func dataSourceAccountsRead(ctx context.Context, d *schema.ResourceData, m inter Skip: d.Get("skip").(int), Take: d.Get("take").(int), } + spaceID := d.Get("space_id").(string) client := m.(*client.Client) - existingAccounts, err := client.Accounts.Get(query) + existingAccounts, err := accounts.Get(client, spaceID, &query) if err != nil { return diag.FromErr(err) } diff --git a/octopusdeploy/provider.go b/octopusdeploy/provider.go index fcf2b2ae..4299ce5e 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", - Required: true, + Optional: true, Type: schema.TypeString, }, }, @@ -123,7 +123,9 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{} config := Config{ Address: d.Get("address").(string), APIKey: d.Get("api_key").(string), - SpaceID: d.Get("space_id").(string), + } + if spaceID, ok := d.GetOk("space_id"); ok { + config.SpaceID = spaceID.(string) } return config.Client() diff --git a/octopusdeploy/schema_account_resource.go b/octopusdeploy/schema_account_resource.go index 44e5432e..5dbee936 100644 --- a/octopusdeploy/schema_account_resource.go +++ b/octopusdeploy/schema_account_resource.go @@ -52,6 +52,7 @@ func getAccountResourceDataSchema() map[string]*schema.Schema { Type: schema.TypeList, }, "id": getDataSchemaID(), + "space_id": getQuerySpaceID(), "ids": getQueryIDs(), "partial_name": getQueryPartialName(), "skip": getQuerySkip(), diff --git a/octopusdeploy/schema_queries.go b/octopusdeploy/schema_queries.go index 8fe0a21a..66ac87de 100644 --- a/octopusdeploy/schema_queries.go +++ b/octopusdeploy/schema_queries.go @@ -147,6 +147,14 @@ func getQueryHealthStatuses() *schema.Schema { } } +func getQuerySpaceID() *schema.Schema { + return &schema.Schema{ + Description: "A Space ID to filter by. Will revert what is specified on the provider if not set.", + Optional: true, + Type: schema.TypeString, + } +} + func getDataSchemaID() *schema.Schema { return &schema.Schema{ Computed: true, diff --git a/octopusdeploy/schema_utilities.go b/octopusdeploy/schema_utilities.go index e37469de..69b47ce3 100644 --- a/octopusdeploy/schema_utilities.go +++ b/octopusdeploy/schema_utilities.go @@ -289,6 +289,7 @@ func getSpaceIDSchema() *schema.Schema { Description: "The space ID associated with this resource.", Optional: true, Type: schema.TypeString, + ForceNew: true, } }