diff --git a/README.md b/README.md index 882e170..f49f038 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ resource "zenml_service_connector" "gcp" { name = "gcp-connector" type = "gcp" auth_method = "service-account" + # workspace defaults to "default" if not specified resource_types = [ "artifact-store", @@ -95,6 +96,7 @@ resource "zenml_stack_component" "artifact_store" { name = "gcs-store" type = "artifact_store" flavor = "gcp" + # workspace defaults to "default" if not specified configuration = { path = "gs://my-bucket/artifacts" @@ -110,6 +112,7 @@ resource "zenml_stack_component" "artifact_store" { # Create a stack using the components resource "zenml_stack" "ml_stack" { name = "production-stack" + # workspace defaults to "default" if not specified components = { artifact_store = zenml_stack_component.artifact_store.id @@ -121,6 +124,8 @@ resource "zenml_stack" "ml_stack" { } ``` +> **Note:** All resources support an optional `workspace` parameter that defaults to "default" if not specified. You can override this by setting `workspace = "your-workspace-name"` in any resource. + See the [examples](./examples/) directory for more complete examples. ## Development diff --git a/docs/guides/getting-started.md b/docs/guides/getting-started.md index f7cc7de..9e927a6 100644 --- a/docs/guides/getting-started.md +++ b/docs/guides/getting-started.md @@ -49,7 +49,6 @@ Here's a simple example creating a stack with a component: ```hcl # Create a stack component resource "zenml_stack_component" "artifact_store" { - workspace = "default" name = "my-artifact-store" type = "artifact_store" flavor = "local" diff --git a/docs/resources/service_connector.md b/docs/resources/service_connector.md index 1282854..5821922 100644 --- a/docs/resources/service_connector.md +++ b/docs/resources/service_connector.md @@ -55,7 +55,7 @@ resource "zenml_service_connector" "gcp_connector" { * Azure: `service-principal`, `managed-identity` * Kubernetes: `kubeconfig`, `service-account` * `user` - (Required, Forces new resource) The ID of the user who owns this connector. -* `workspace` - (Required, Forces new resource) The ID of the workspace this connector belongs to. +* `workspace` - (Optional) The workspace this connector belongs to. Defaults to "default". Forces new resource if changed. * `resource_types` - (Optional) A list of resource types this connector can be used for (e.g., `artifact-store`, `container-registry`, `orchestrator`). * `configuration` - (Required, Sensitive) A map of configuration key-value pairs for the connector. * `secrets` - (Optional, Sensitive) A map of secret key-value pairs for the connector. diff --git a/docs/resources/stack.md b/docs/resources/stack.md index 6a644ab..af08283 100644 --- a/docs/resources/stack.md +++ b/docs/resources/stack.md @@ -68,8 +68,9 @@ resource "zenml_stack" "my_stack" { * `feature_store` * `image_builder` * `labels` - (Optional) A map of labels to associate with the stack. +* `workspace` - (Optional) The workspace to create the stack in. Defaults to "default". Forces new resource if changed. --> **Note** The stack will be created in the default workspace. Future versions may allow workspace configuration. +-> **Note** If no workspace is specified, the stack will be created in the "default" workspace. ## Attributes Reference diff --git a/internal/provider/data_source_service_connector.go b/internal/provider/data_source_service_connector.go index 7e83ca2..f8bbf6d 100644 --- a/internal/provider/data_source_service_connector.go +++ b/internal/provider/data_source_service_connector.go @@ -13,9 +13,10 @@ func dataSourceServiceConnector() *schema.Resource { ReadContext: dataSourceServiceConnectorRead, Schema: map[string]*schema.Schema{ "workspace": { - Description: "Name of the workspace", + Description: "Name of the workspace (defaults to 'default')", Type: schema.TypeString, - Required: true, + Optional: true, + Default: "default", }, "name": { Description: "Name of the service connector", diff --git a/internal/provider/data_source_stack.go b/internal/provider/data_source_stack.go index 6268b28..8c998e8 100644 --- a/internal/provider/data_source_stack.go +++ b/internal/provider/data_source_stack.go @@ -14,9 +14,10 @@ func dataSourceStack() *schema.Resource { ReadContext: dataSourceStackRead, Schema: map[string]*schema.Schema{ "workspace": { - Description: "Name of the workspace", + Description: "Name of the workspace (defaults to 'default')", Type: schema.TypeString, - Required: true, + Optional: true, + Default: "default", }, "name": { Description: "Name of the stack", diff --git a/internal/provider/data_source_stack_component.go b/internal/provider/data_source_stack_component.go index 2ed7c9a..2a5dfef 100644 --- a/internal/provider/data_source_stack_component.go +++ b/internal/provider/data_source_stack_component.go @@ -15,9 +15,10 @@ func dataSourceStackComponent() *schema.Resource { ReadContext: dataSourceStackComponentRead, Schema: map[string]*schema.Schema{ "workspace": { - Description: "Name of the workspace", + Description: "Name of the workspace (defaults to 'default')", Type: schema.TypeString, - Required: true, + Optional: true, + Default: "default", }, "name": { Description: "Name of the stack component", diff --git a/internal/provider/resource_service_connector.go b/internal/provider/resource_service_connector.go index 5cf0d62..c50b83a 100644 --- a/internal/provider/resource_service_connector.go +++ b/internal/provider/resource_service_connector.go @@ -67,7 +67,8 @@ func resourceServiceConnector() *schema.Resource { }, "workspace": { Type: schema.TypeString, - Required: true, + Optional: true, + Default: "default", ForceNew: true, }, "labels": { diff --git a/internal/provider/resource_stack.go b/internal/provider/resource_stack.go index ed35e48..e4953af 100644 --- a/internal/provider/resource_stack.go +++ b/internal/provider/resource_stack.go @@ -16,6 +16,12 @@ func resourceStack() *schema.Resource { Delete: resourceStackDelete, Schema: map[string]*schema.Schema{ + "workspace": { + Type: schema.TypeString, + Optional: true, + Default: "default", + ForceNew: true, + }, "name": { Type: schema.TypeString, Required: true, @@ -68,8 +74,8 @@ func resourceStack() *schema.Resource { func resourceStackCreate(d *schema.ResourceData, m interface{}) error { client := m.(*Client) - // Get the workspace from configuration or use a default - workspace := "default" // You may want to make this configurable + // Get the workspace from schema instead of hardcoding + workspace := d.Get("workspace").(string) stack := StackRequest{ Name: d.Get("name").(string), @@ -77,12 +83,12 @@ func resourceStackCreate(d *schema.ResourceData, m interface{}) error { // Handle components if v, ok := d.GetOk("components"); ok { - components := make(map[string][]string) - for k, v := range v.(map[string]interface{}) { - // Convert single ID to array of IDs since API expects array - components[k] = []string{v.(string)} - } - stack.Components = components + components := make(map[string][]string) + for k, v := range v.(map[string]interface{}) { + // Convert single ID to array of IDs since API expects array + components[k] = []string{v.(string)} + } + stack.Components = components } resp, err := client.CreateStack(workspace, stack) diff --git a/internal/provider/resource_stack_component.go b/internal/provider/resource_stack_component.go index bdc6cb7..8b3dde3 100644 --- a/internal/provider/resource_stack_component.go +++ b/internal/provider/resource_stack_component.go @@ -34,7 +34,8 @@ func resourceStackComponent() *schema.Resource { Schema: map[string]*schema.Schema{ "workspace": { Type: schema.TypeString, - Required: true, + Optional: true, + Default: "default", ForceNew: true, }, "name": { diff --git a/terraform-provider-zenml b/terraform-provider-zenml index 288f195..d51b7d7 100755 Binary files a/terraform-provider-zenml and b/terraform-provider-zenml differ