diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 02c94671..9a8c014b 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -6,7 +6,7 @@ labels: '' assignees: '' --- -- [ ] I have checked that a similar [feature request](https://github.com/astronomer/astronomer-terraform-provider/issues?q=is%3Aopen+is%3Aissue+label%3A%22feature+request%22) does not already exist. +- [ ] I have checked that a similar [feature request](https://github.com/astronomer/terraform-provider-astro/issues?q=is%3Aopen+is%3Aissue+label%3A%22feature+request%22) does not already exist. **✍️ Is your feature request related to a problem? Please describe.** diff --git a/.terraformrc b/.terraformrc index fadef5f1..b7c8b89f 100644 --- a/.terraformrc +++ b/.terraformrc @@ -1,6 +1,6 @@ provider_installation { dev_overrides { - "registry.terraform.io/astronomer/astronomer" = "~/astronomer/astronomer-terraform-provider/bin" + "registry.terraform.io/astronomer/astro" = "~/astronomer/terraform-provider-astro/bin" } direct {} } \ No newline at end of file diff --git a/LICENSE b/LICENSE index 30404ce4..345a7f9c 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1,31 @@ -TODO \ No newline at end of file +Licensed under the Apache License, Version 2.0 (the "License") modified with +Commons Clause Restriction; you may not use this code except in compliance with +the License. You may obtain a copy of the License at: + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. + +"Commons Clause" License Condition v1.0 + +The Software is provided to you by the Licensor under the License, as defined +below, subject to the following condition. + +Without limiting other conditions in the License, the grant of rights under the +License will not include, and the License does not grant to you, the right to +Sell the Software. + +For purposes of the foregoing, "Sell" means practicing any or all of the rights +granted to you under the License to provide to third parties, for a fee or other +consideration (including without limitation fees for hosting or +consulting/support services related to the Software), a product or service whose +value derives, entirely or substantially, from the functionality of the +Software. Any license notice or attribution required by the License must also +include this Commons Clause License Condition notice. + +Software: Terraform Provider Astro +License: Apache 2.0 +Licensor: Astronomer, Inc. \ No newline at end of file diff --git a/Makefile b/Makefile index 759c1eed..631c680a 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ dep: .PHONY: build build: - go build -o ${ENVTEST_ASSETS_DIR}/terraform-provider-astronomer + go build -o ${ENVTEST_ASSETS_DIR} go generate ./... .PHONY: api_client_gen diff --git a/README.md b/README.md index f036e31f..5e0e87e8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Astronomer Terraform Provider +# Terraform Provider Astro ## Requirements @@ -38,13 +38,13 @@ Then commit the changes to `go.mod` and `go.sum`. ```terraform terraform { required_providers { - astronomer = { - source = "registry.terraform.io/astronomer/astronomer" + astro = { + source = "registry.terraform.io/astronomer/astro" } } } -provider "astronomer" { +provider "astro" { organization_id = "" } @@ -71,7 +71,7 @@ To run terraform with the provider, create a `.terraformrc` file in your home di ```hcl provider_installation { dev_overrides { - "registry.terraform.io/astronomer/astronomer" = "~/astronomer-terraform-provider/bin" # Your path to the provider binary + "registry.terraform.io/astronomer/astro" = "~/terraform-provider-astro/bin" # Your path to the provider binary } direct {} } @@ -81,30 +81,30 @@ provider_installation { ```terraform terraform { required_providers { - astronomer = { - source = "registry.terraform.io/astronomer/astronomer" + astro = { + source = "registry.terraform.io/astronomer/astro" } } } # provider configuration -provider "astronomer" { +provider "astro" { organization_id = "" host = "https://api.astronomer-dev.io" } # get information on an existing workspace -data "astronomer_workspace" "example" { - id = ">" +data "astro_workspace" "example" { + id = "" } # output the workspace data to the terminal output "data_workspace_example" { - value = data.astronomer_workspace.example + value = data.astro_workspace.example } # create a new workspace -resource "astronomer_workspace" "tf_workspace" { +resource "astro_workspace" "tf_workspace" { name = "my workspace" description = "my first workspace" cicd_enforced_default = false @@ -112,18 +112,18 @@ resource "astronomer_workspace" "tf_workspace" { # output the newly created workspace resource to the terminal output "terraform_workspace" { - value = astronomer_workspace.tf_workspace + value = astro_workspace.tf_workspace } # create a new cluster resource -resource "astronomer_cluster" "tf_cluster" { +resource "astro_cluster" "tf_cluster" { type = "DEDICATED" name = "my first cluster" region = "us-east-1" cloud_provider = "AWS" db_instance_type = "db.m6g.large" vpc_subnet_range = "172.20.0.0/20" - workspace_ids = [astronomer_workspace.tf_workspace.id, data.astronomer_workspace.example.id] + workspace_ids = [astro_workspace.tf_workspace.id, data.astro_workspace.example.id] timeouts = { create = "3h" update = "2h" @@ -132,10 +132,10 @@ resource "astronomer_cluster" "tf_cluster" { } # create a new dedicated deployment resource in that cluster -resource "astronomer_deployment" "tf_deployment" { +resource "astro_deployment" "tf_dedicated_deployment" { name = "my first dedicated deployment" description = "" - cluster_id = astronomer_cluster.tf_cluster.id + cluster_id = astro_cluster.tf_cluster.id type = "DEDICATED" contact_emails = ["example@astronomer.io"] default_task_pod_cpu = "0.25" @@ -148,7 +148,7 @@ resource "astronomer_deployment" "tf_deployment" { resource_quota_cpu = "10" resource_quota_memory = "20Gi" scheduler_size = "SMALL" - workspace_id = astronomer_workspace.tf_workspace.id + workspace_id = astro_workspace.tf_workspace.id environment_variables = [{ key = "key1" value = "value1" @@ -157,7 +157,7 @@ resource "astronomer_deployment" "tf_deployment" { } # create a new standard deployment resource -resource "astronomer_standard_deployment" "tf_standard_deployment" { +resource "astro_deployment" "tf_standard_deployment" { name = "my first standard deployment" description = "" type = "STANDARD" @@ -174,7 +174,7 @@ resource "astronomer_standard_deployment" "tf_standard_deployment" { resource_quota_cpu = "10" resource_quota_memory = "20Gi" scheduler_size = "SMALL" - workspace_id = astronomer_workspace.tf_workspace.id + workspace_id = astro_workspace.tf_workspace.id environment_variables = [] worker_queues = [{ name = "default" diff --git a/docs/data-sources/cluster.md b/docs/data-sources/cluster.md index 1afb9d71..9bcb3e40 100644 --- a/docs/data-sources/cluster.md +++ b/docs/data-sources/cluster.md @@ -1,19 +1,19 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_cluster Data Source - astronomer" +page_title: "astro_cluster Data Source - astro" subcategory: "" description: |- Cluster data source --- -# astronomer_cluster (Data Source) +# astro_cluster (Data Source) Cluster data source ## Example Usage ```terraform -data "astronomer_cluster" "example" { +data "astro_cluster" "example" { id = "clozc036j01to01jrlgvueo8t" } ``` @@ -33,26 +33,26 @@ data "astronomer_cluster" "example" { - `is_limited` (Boolean) Whether the cluster is limited - `metadata` (Attributes) Cluster metadata (see [below for nested schema](#nestedatt--metadata)) - `name` (String) Cluster name -- `node_pools` (Attributes List) Cluster node pools (see [below for nested schema](#nestedatt--node_pools)) +- `node_pools` (Attributes Set) Cluster node pools (see [below for nested schema](#nestedatt--node_pools)) - `pod_subnet_range` (String) Cluster pod subnet range - `provider_account` (String) Cluster provider account - `region` (String) Cluster region - `service_peering_range` (String) Cluster service peering range - `service_subnet_range` (String) Cluster service subnet range - `status` (String) Cluster status -- `tags` (Attributes List) Cluster tags (see [below for nested schema](#nestedatt--tags)) +- `tags` (Attributes Set) Cluster tags (see [below for nested schema](#nestedatt--tags)) - `tenant_id` (String) Cluster tenant ID - `type` (String) Cluster type - `updated_at` (String) Cluster last updated timestamp - `vpc_subnet_range` (String) Cluster VPC subnet range -- `workspace_ids` (List of String) Cluster workspace IDs +- `workspace_ids` (Set of String) Cluster workspace IDs ### Nested Schema for `metadata` Read-Only: -- `external_ips` (List of String) Cluster external IPs +- `external_ips` (Set of String) Cluster external IPs - `oidc_issuer_url` (String) Cluster OIDC issuer URL @@ -69,7 +69,7 @@ Read-Only: - `max_node_count` (Number) Node pool maximum node count - `name` (String) Node pool name - `node_instance_type` (String) Node pool node instance type -- `supported_astro_machines` (List of String) Node pool supported Astro machines +- `supported_astro_machines` (Set of String) Node pool supported Astro machines - `updated_at` (String) Node pool last updated timestamp diff --git a/docs/data-sources/cluster_options.md b/docs/data-sources/cluster_options.md index 17e457aa..55569ffc 100644 --- a/docs/data-sources/cluster_options.md +++ b/docs/data-sources/cluster_options.md @@ -1,23 +1,23 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_cluster_options Data Source - astronomer" +page_title: "astro_cluster_options Data Source - astro" subcategory: "" description: |- ClusterOptions data source --- -# astronomer_cluster_options (Data Source) +# astro_cluster_options (Data Source) ClusterOptions data source ## Example Usage ```terraform -data "astronomer_cluster_options" "example_cluster_options" { +data "astro_cluster_options" "example_cluster_options" { type = "HYBRID" } -data "astronomer_cluster_options" "example_cluster_options_filter_by_provider" { +data "astro_cluster_options" "example_cluster_options_filter_by_provider" { type = "HYBRID" cloud_provider = "AWS" } @@ -36,14 +36,14 @@ data "astronomer_cluster_options" "example_cluster_options_filter_by_provider" { ### Read-Only -- `cluster_options` (Attributes List) (see [below for nested schema](#nestedatt--cluster_options)) +- `cluster_options` (Attributes Set) (see [below for nested schema](#nestedatt--cluster_options)) ### Nested Schema for `cluster_options` Read-Only: -- `database_instances` (Attributes List) ClusterOption database instances (see [below for nested schema](#nestedatt--cluster_options--database_instances)) +- `database_instances` (Attributes Set) ClusterOption database instances (see [below for nested schema](#nestedatt--cluster_options--database_instances)) - `default_database_instance` (Attributes) ClusterOption default database instance (see [below for nested schema](#nestedatt--cluster_options--default_database_instance)) - `default_node_instance` (Attributes) ClusterOption default node instance (see [below for nested schema](#nestedatt--cluster_options--default_node_instance)) - `default_pod_subnet_range` (String) ClusterOption default pod subnet range @@ -54,9 +54,9 @@ Read-Only: - `node_count_default` (Number) ClusterOption node count default - `node_count_max` (Number) ClusterOption node count max - `node_count_min` (Number) ClusterOption node count min -- `node_instances` (Attributes List) ClusterOption node instances (see [below for nested schema](#nestedatt--cluster_options--node_instances)) +- `node_instances` (Attributes Set) ClusterOption node instances (see [below for nested schema](#nestedatt--cluster_options--node_instances)) - `provider` (String) ClusterOption provider -- `regions` (Attributes List) ClusterOption regions (see [below for nested schema](#nestedatt--cluster_options--regions)) +- `regions` (Attributes Set) ClusterOption regions (see [below for nested schema](#nestedatt--cluster_options--regions)) ### Nested Schema for `cluster_options.database_instances` @@ -93,7 +93,7 @@ Read-Only: Read-Only: -- `banned_instances` (List of String) Region banned instances +- `banned_instances` (Set of String) Region banned instances - `limited` (Boolean) Region is limited bool - `name` (String) Region is limited bool @@ -113,6 +113,6 @@ Read-Only: Read-Only: -- `banned_instances` (List of String) Region banned instances +- `banned_instances` (Set of String) Region banned instances - `limited` (Boolean) Region is limited bool - `name` (String) Region is limited bool diff --git a/docs/data-sources/clusters.md b/docs/data-sources/clusters.md index 44f0bd5a..ac6015e7 100644 --- a/docs/data-sources/clusters.md +++ b/docs/data-sources/clusters.md @@ -1,25 +1,25 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_clusters Data Source - astronomer" +page_title: "astro_clusters Data Source - astro" subcategory: "" description: |- Clusters data source --- -# astronomer_clusters (Data Source) +# astro_clusters (Data Source) Clusters data source ## Example Usage ```terraform -data "astronomer_clusters" "example_clusters" {} +data "astro_clusters" "example_clusters" {} -data "astronomer_clusters" "example_clusters_filter_by_names" { +data "astro_clusters" "example_clusters_filter_by_names" { names = ["my cluster"] } -data "astronomer_clusters" "example_clusters_filter_by_cloud_provider" { +data "astro_clusters" "example_clusters_filter_by_cloud_provider" { cloud_provider = ["AWS"] } ``` @@ -30,11 +30,11 @@ data "astronomer_clusters" "example_clusters_filter_by_cloud_provider" { ### Optional - `cloud_provider` (String) -- `names` (List of String) +- `names` (Set of String) ### Read-Only -- `clusters` (Attributes List) (see [below for nested schema](#nestedatt--clusters)) +- `clusters` (Attributes Set) (see [below for nested schema](#nestedatt--clusters)) ### Nested Schema for `clusters` @@ -51,26 +51,26 @@ Read-Only: - `is_limited` (Boolean) Whether the cluster is limited - `metadata` (Attributes) Cluster metadata (see [below for nested schema](#nestedatt--clusters--metadata)) - `name` (String) Cluster name -- `node_pools` (Attributes List) Cluster node pools (see [below for nested schema](#nestedatt--clusters--node_pools)) +- `node_pools` (Attributes Set) Cluster node pools (see [below for nested schema](#nestedatt--clusters--node_pools)) - `pod_subnet_range` (String) Cluster pod subnet range - `provider_account` (String) Cluster provider account - `region` (String) Cluster region - `service_peering_range` (String) Cluster service peering range - `service_subnet_range` (String) Cluster service subnet range - `status` (String) Cluster status -- `tags` (Attributes List) Cluster tags (see [below for nested schema](#nestedatt--clusters--tags)) +- `tags` (Attributes Set) Cluster tags (see [below for nested schema](#nestedatt--clusters--tags)) - `tenant_id` (String) Cluster tenant ID - `type` (String) Cluster type - `updated_at` (String) Cluster last updated timestamp - `vpc_subnet_range` (String) Cluster VPC subnet range -- `workspace_ids` (List of String) Cluster workspace IDs +- `workspace_ids` (Set of String) Cluster workspace IDs ### Nested Schema for `clusters.metadata` Read-Only: -- `external_ips` (List of String) Cluster external IPs +- `external_ips` (Set of String) Cluster external IPs - `oidc_issuer_url` (String) Cluster OIDC issuer URL @@ -87,7 +87,7 @@ Read-Only: - `max_node_count` (Number) Node pool maximum node count - `name` (String) Node pool name - `node_instance_type` (String) Node pool node instance type -- `supported_astro_machines` (List of String) Node pool supported Astro machines +- `supported_astro_machines` (Set of String) Node pool supported Astro machines - `updated_at` (String) Node pool last updated timestamp diff --git a/docs/data-sources/deployment.md b/docs/data-sources/deployment.md index 560d1459..5831ae3e 100644 --- a/docs/data-sources/deployment.md +++ b/docs/data-sources/deployment.md @@ -1,19 +1,19 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_deployment Data Source - astronomer" +page_title: "astro_deployment Data Source - astro" subcategory: "" description: |- Deployment data source --- -# astronomer_deployment (Data Source) +# astro_deployment (Data Source) Deployment data source ## Example Usage ```terraform -data "astronomer_deployment" "example" { +data "astro_deployment" "example" { id = "clozc036j01to01jrlgvueo8t" } ``` @@ -31,7 +31,7 @@ data "astronomer_deployment" "example" { - `astro_runtime_version` (String) Deployment Astro Runtime version - `cloud_provider` (String) Deployment cloud provider - `cluster_id` (String) Deployment cluster identifier -- `contact_emails` (List of String) Deployment contact emails +- `contact_emails` (Set of String) Deployment contact emails - `created_at` (String) Deployment creation timestamp - `created_by` (Attributes) Deployment creator (see [below for nested schema](#nestedatt--created_by)) - `dag_tarball_version` (String) Deployment DAG tarball version @@ -39,9 +39,9 @@ data "astronomer_deployment" "example" { - `default_task_pod_memory` (String) Deployment default task pod memory - `description` (String) Deployment description - `desired_dag_tarball_version` (String) Deployment desired DAG tarball version -- `environment_variables` (Attributes List) Deployment environment variables (see [below for nested schema](#nestedatt--environment_variables)) +- `environment_variables` (Attributes Set) Deployment environment variables (see [below for nested schema](#nestedatt--environment_variables)) - `executor` (String) Deployment executor -- `external_ips` (List of String) Deployment external IPs +- `external_ips` (Set of String) Deployment external IPs - `image_repository` (String) Deployment image repository - `image_tag` (String) Deployment image tag - `image_version` (String) Deployment image version @@ -71,7 +71,7 @@ data "astronomer_deployment" "example" { - `webserver_airflow_api_url` (String) Deployment webserver Airflow API URL - `webserver_ingress_hostname` (String) Deployment webserver ingress hostname - `webserver_url` (String) Deployment webserver URL -- `worker_queues` (Attributes List) Deployment worker queues (see [below for nested schema](#nestedatt--worker_queues)) +- `worker_queues` (Attributes Set) Deployment worker queues (see [below for nested schema](#nestedatt--worker_queues)) - `workload_identity` (String) Deployment workload identity - `workspace_id` (String) Deployment workspace identifier @@ -112,7 +112,7 @@ Read-Only: Read-Only: - `override` (Attributes) (see [below for nested schema](#nestedatt--scaling_spec--hibernation_spec--override)) -- `schedules` (Attributes List) (see [below for nested schema](#nestedatt--scaling_spec--hibernation_spec--schedules)) +- `schedules` (Attributes Set) (see [below for nested schema](#nestedatt--scaling_spec--hibernation_spec--schedules)) ### Nested Schema for `scaling_spec.hibernation_spec.override` diff --git a/docs/data-sources/deployment_options.md b/docs/data-sources/deployment_options.md index 824ca5e6..c8a1c143 100644 --- a/docs/data-sources/deployment_options.md +++ b/docs/data-sources/deployment_options.md @@ -1,33 +1,33 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_deployment_options Data Source - astronomer" +page_title: "astro_deployment_options Data Source - astro" subcategory: "" description: |- Deployment options data source --- -# astronomer_deployment_options (Data Source) +# astro_deployment_options (Data Source) Deployment options data source ## Example Usage ```terraform -data "astronomer_deployment_options" "example" {} +data "astro_deployment_options" "example" {} -data "astronomer_deployment_options" "example_with_deployment_id_query_param" { +data "astro_deployment_options" "example_with_deployment_id_query_param" { deployment_id = "clozc036j01to01jrlgvueo8t" } -data "astronomer_deployment_options" "example_with_deployment_type_query_param" { +data "astro_deployment_options" "example_with_deployment_type_query_param" { deployment_type = "DEDICATED" } -data "astronomer_deployment_options" "example_with_executor_query_param" { +data "astro_deployment_options" "example_with_executor_query_param" { executor = "CELERY" } -data "astronomer_deployment_options" "example_with_cloud_provider_query_param" { +data "astro_deployment_options" "example_with_cloud_provider_query_param" { cloud_provider = "AWS" } ``` @@ -44,13 +44,13 @@ data "astronomer_deployment_options" "example_with_cloud_provider_query_param" { ### Read-Only -- `executors` (List of String) Available executors +- `executors` (Set of String) Available executors - `resource_quotas` (Attributes) Resource quota options (see [below for nested schema](#nestedatt--resource_quotas)) -- `runtime_releases` (List of Object) Available Astro Runtime versions (see [below for nested schema](#nestedatt--runtime_releases)) -- `scheduler_machines` (List of Object) Available scheduler sizes (see [below for nested schema](#nestedatt--scheduler_machines)) -- `worker_machines` (List of Object) Available worker machine types (see [below for nested schema](#nestedatt--worker_machines)) +- `runtime_releases` (Set of Object) Available Astro Runtime versions (see [below for nested schema](#nestedatt--runtime_releases)) +- `scheduler_machines` (Set of Object) Available scheduler sizes (see [below for nested schema](#nestedatt--scheduler_machines)) +- `worker_machines` (Set of Object) Available worker machine types (see [below for nested schema](#nestedatt--worker_machines)) - `worker_queues` (Attributes) Available worker queue options (see [below for nested schema](#nestedatt--worker_queues)) -- `workload_identity_options` (List of Object) Available workload identity options (see [below for nested schema](#nestedatt--workload_identity_options)) +- `workload_identity_options` (Set of Object) Available workload identity options (see [below for nested schema](#nestedatt--workload_identity_options)) ### Nested Schema for `resource_quotas` diff --git a/docs/data-sources/deployments.md b/docs/data-sources/deployments.md index 4ce39d1c..45b00593 100644 --- a/docs/data-sources/deployments.md +++ b/docs/data-sources/deployments.md @@ -1,25 +1,25 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_deployments Data Source - astronomer" +page_title: "astro_deployments Data Source - astro" subcategory: "" description: |- Deployments data source --- -# astronomer_deployments (Data Source) +# astro_deployments (Data Source) Deployments data source ## Example Usage ```terraform -data "astronomer_clusters" "example_clusters" {} +data "astro_clusters" "example_clusters" {} -data "astronomer_clusters" "example_clusters_filter_by_names" { +data "astro_clusters" "example_clusters_filter_by_names" { names = ["my cluster"] } -data "astronomer_clusters" "example_clusters_filter_by_cloud_provider" { +data "astro_clusters" "example_clusters_filter_by_cloud_provider" { cloud_provider = ["AWS"] } ``` @@ -29,13 +29,13 @@ data "astronomer_clusters" "example_clusters_filter_by_cloud_provider" { ### Optional -- `deployment_ids` (List of String) -- `names` (List of String) -- `workspace_ids` (List of String) +- `deployment_ids` (Set of String) +- `names` (Set of String) +- `workspace_ids` (Set of String) ### Read-Only -- `deployments` (Attributes List) (see [below for nested schema](#nestedatt--deployments)) +- `deployments` (Attributes Set) (see [below for nested schema](#nestedatt--deployments)) ### Nested Schema for `deployments` @@ -50,7 +50,7 @@ Read-Only: - `astro_runtime_version` (String) Deployment Astro Runtime version - `cloud_provider` (String) Deployment cloud provider - `cluster_id` (String) Deployment cluster identifier -- `contact_emails` (List of String) Deployment contact emails +- `contact_emails` (Set of String) Deployment contact emails - `created_at` (String) Deployment creation timestamp - `created_by` (Attributes) Deployment creator (see [below for nested schema](#nestedatt--deployments--created_by)) - `dag_tarball_version` (String) Deployment DAG tarball version @@ -58,9 +58,9 @@ Read-Only: - `default_task_pod_memory` (String) Deployment default task pod memory - `description` (String) Deployment description - `desired_dag_tarball_version` (String) Deployment desired DAG tarball version -- `environment_variables` (Attributes List) Deployment environment variables (see [below for nested schema](#nestedatt--deployments--environment_variables)) +- `environment_variables` (Attributes Set) Deployment environment variables (see [below for nested schema](#nestedatt--deployments--environment_variables)) - `executor` (String) Deployment executor -- `external_ips` (List of String) Deployment external IPs +- `external_ips` (Set of String) Deployment external IPs - `image_repository` (String) Deployment image repository - `image_tag` (String) Deployment image tag - `image_version` (String) Deployment image version @@ -90,7 +90,7 @@ Read-Only: - `webserver_airflow_api_url` (String) Deployment webserver Airflow API URL - `webserver_ingress_hostname` (String) Deployment webserver ingress hostname - `webserver_url` (String) Deployment webserver URL -- `worker_queues` (Attributes List) Deployment worker queues (see [below for nested schema](#nestedatt--deployments--worker_queues)) +- `worker_queues` (Attributes Set) Deployment worker queues (see [below for nested schema](#nestedatt--deployments--worker_queues)) - `workload_identity` (String) Deployment workload identity - `workspace_id` (String) Deployment workspace identifier @@ -131,7 +131,7 @@ Read-Only: Read-Only: - `override` (Attributes) (see [below for nested schema](#nestedatt--deployments--scaling_spec--hibernation_spec--override)) -- `schedules` (Attributes List) (see [below for nested schema](#nestedatt--deployments--scaling_spec--hibernation_spec--schedules)) +- `schedules` (Attributes Set) (see [below for nested schema](#nestedatt--deployments--scaling_spec--hibernation_spec--schedules)) ### Nested Schema for `deployments.scaling_spec.hibernation_spec.override` diff --git a/docs/data-sources/organization.md b/docs/data-sources/organization.md index 1a75e3d8..93cb836f 100644 --- a/docs/data-sources/organization.md +++ b/docs/data-sources/organization.md @@ -1,19 +1,19 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_organization Data Source - astronomer" +page_title: "astro_organization Data Source - astro" subcategory: "" description: |- Organization data source --- -# astronomer_organization (Data Source) +# astro_organization (Data Source) Organization data source ## Example Usage ```terraform -data "astronomer_organization" "example" {} +data "astro_organization" "example" {} ``` diff --git a/docs/data-sources/workspace.md b/docs/data-sources/workspace.md index 25256922..b5522e12 100644 --- a/docs/data-sources/workspace.md +++ b/docs/data-sources/workspace.md @@ -1,19 +1,19 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_workspace Data Source - astronomer" +page_title: "astro_workspace Data Source - astro" subcategory: "" description: |- Workspace data source --- -# astronomer_workspace (Data Source) +# astro_workspace (Data Source) Workspace data source ## Example Usage ```terraform -data "astronomer_workspace" "example" { +data "astro_workspace" "example" { id = "clozc036j01to01jrlgvueo8t" } ``` diff --git a/docs/data-sources/workspaces.md b/docs/data-sources/workspaces.md index baccb85d..acfeadc5 100644 --- a/docs/data-sources/workspaces.md +++ b/docs/data-sources/workspaces.md @@ -1,25 +1,25 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_workspaces Data Source - astronomer" +page_title: "astro_workspaces Data Source - astro" subcategory: "" description: |- Workspaces data source --- -# astronomer_workspaces (Data Source) +# astro_workspaces (Data Source) Workspaces data source ## Example Usage ```terraform -data "astronomer_workspaces" "example_workspaces" {} +data "astro_workspaces" "example_workspaces" {} -data "astronomer_workspaces" "example_workspaces_filter_by_workspace_ids" { +data "astro_workspaces" "example_workspaces_filter_by_workspace_ids" { workspace_ids = ["clozc036j01to01jrlgvueo8t", "clozc036j01to01jrlgvueo81"] } -data "astronomer_workspaces" "example_workspaces_filter_by_names" { +data "astro_workspaces" "example_workspaces_filter_by_names" { names = ["my first workspace", "my second workspace"] } ``` @@ -29,12 +29,12 @@ data "astronomer_workspaces" "example_workspaces_filter_by_names" { ### Optional -- `names` (List of String) -- `workspace_ids` (List of String) +- `names` (Set of String) +- `workspace_ids` (Set of String) ### Read-Only -- `workspaces` (Attributes List) (see [below for nested schema](#nestedatt--workspaces)) +- `workspaces` (Attributes Set) (see [below for nested schema](#nestedatt--workspaces)) ### Nested Schema for `workspaces` diff --git a/docs/index.md b/docs/index.md index 47725c74..ec0f63d4 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,19 +1,19 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer Provider" +page_title: "astro Provider" subcategory: "" description: |- --- -# astronomer Provider +# astro Provider ## Example Usage ```terraform -provider "astronomer" { +provider "astro" { organization_id = "cljzz64cc001n01mln1p12345" } ``` diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index dc4ede34..fabc6dfe 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -1,19 +1,19 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_cluster Resource - astronomer" +page_title: "astro_cluster Resource - astro" subcategory: "" description: |- Cluster resource --- -# astronomer_cluster (Resource) +# astro_cluster (Resource) Cluster resource ## Example Usage ```terraform -resource "astronomer_cluster" "aws_example" { +resource "astro_cluster" "aws_example" { type = "DEDICATED" name = "my first aws cluster" region = "us-east-1" @@ -28,7 +28,7 @@ resource "astronomer_cluster" "aws_example" { } } -resource "astronomer_cluster" "azure_example" { +resource "astro_cluster" "azure_example" { type = "DEDICATED" name = "my first azure cluster" region = "westus2" @@ -38,7 +38,7 @@ resource "astronomer_cluster" "azure_example" { workspace_ids = ["clv4wcf6f003u01m3zp7gsvzg"] } -resource "astronomer_cluster" "gcp_example" { +resource "astro_cluster" "gcp_example" { type = "DEDICATED" name = "my first gcp cluster" region = "us-central1" @@ -63,7 +63,7 @@ resource "astronomer_cluster" "gcp_example" { - `region` (String) Cluster region - if changed, the cluster will be recreated. - `type` (String) Cluster type - `vpc_subnet_range` (String) Cluster VPC subnet range. If changed, the cluster will be recreated. -- `workspace_ids` (List of String) Cluster workspace IDs +- `workspace_ids` (Set of String) Cluster workspace IDs ### Optional @@ -78,7 +78,7 @@ resource "astronomer_cluster" "gcp_example" { - `id` (String) Cluster identifier - `is_limited` (Boolean) Whether the cluster is limited - `metadata` (Attributes) Cluster metadata (see [below for nested schema](#nestedatt--metadata)) -- `node_pools` (Attributes List) Cluster node pools (see [below for nested schema](#nestedatt--node_pools)) +- `node_pools` (Attributes Set) Cluster node pools (see [below for nested schema](#nestedatt--node_pools)) - `provider_account` (String) Cluster provider account - `status` (String) Cluster status - `tenant_id` (String) Cluster tenant ID @@ -99,7 +99,7 @@ Optional: Read-Only: -- `external_ips` (List of String) Cluster external IPs +- `external_ips` (Set of String) Cluster external IPs - `oidc_issuer_url` (String) Cluster OIDC issuer URL @@ -116,5 +116,5 @@ Read-Only: - `max_node_count` (Number) Node pool maximum node count - `name` (String) Node pool name - `node_instance_type` (String) Node pool node instance type -- `supported_astro_machines` (List of String) Node pool supported Astro machines +- `supported_astro_machines` (Set of String) Node pool supported Astro machines - `updated_at` (String) Node pool last updated timestamp diff --git a/docs/resources/deployment.md b/docs/resources/deployment.md index 376f803e..8d9d6b81 100644 --- a/docs/resources/deployment.md +++ b/docs/resources/deployment.md @@ -1,19 +1,19 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_deployment Resource - astronomer" +page_title: "astro_deployment Resource - astro" subcategory: "" description: |- Deployment resource --- -# astronomer_deployment (Resource) +# astro_deployment (Resource) Deployment resource ## Example Usage ```terraform -resource "astronomer_deployment" "dedicated" { +resource "astro_deployment" "dedicated" { name = "my dedicated deployment" description = "an example deployment" type = "DEDICATED" @@ -37,7 +37,7 @@ resource "astronomer_deployment" "dedicated" { }] } -resource "astronomer_deployment" "standard" { +resource "astro_deployment" "standard" { name = "my standard deployment" description = "an example deployment" type = "STANDARD" @@ -66,7 +66,7 @@ resource "astronomer_deployment" "standard" { }] } -resource "astronomer_deployment" "hybrid" { +resource "astro_deployment" "hybrid" { name = "my hybrid deployment" description = "an example deployment" type = "HYBRID" @@ -92,9 +92,9 @@ resource "astronomer_deployment" "hybrid" { ### Required -- `contact_emails` (List of String) Deployment contact emails +- `contact_emails` (Set of String) Deployment contact emails - `description` (String) Deployment description -- `environment_variables` (Attributes List) Deployment environment variables (see [below for nested schema](#nestedatt--environment_variables)) +- `environment_variables` (Attributes Set) Deployment environment variables (see [below for nested schema](#nestedatt--environment_variables)) - `executor` (String) Deployment executor - `is_cicd_enforced` (Boolean) Deployment CI/CD enforced - `is_dag_deploy_enabled` (Boolean) Whether DAG deploy is enabled - Changing this value may disrupt your deployment. Read more at https://docs.astronomer.io/astro/deploy-dags#enable-or-disable-dag-only-deploys-on-a-deployment @@ -118,7 +118,7 @@ resource "astronomer_deployment" "hybrid" { - `scheduler_replicas` (Number) Deployment scheduler replicas - required for 'HYBRID' deployments - `scheduler_size` (String) Deployment scheduler size - required for 'STANDARD' and 'DEDICATED' deployments - `task_pod_node_pool_id` (String) Deployment task pod node pool identifier - required if executor is 'KUBERNETES' and type is 'HYBRID' -- `worker_queues` (Attributes List) Deployment worker queues - required for deployments with 'CELERY' executor (see [below for nested schema](#nestedatt--worker_queues)) +- `worker_queues` (Attributes Set) Deployment worker queues - required for deployments with 'CELERY' executor (see [below for nested schema](#nestedatt--worker_queues)) ### Read-Only @@ -128,7 +128,7 @@ resource "astronomer_deployment" "hybrid" { - `created_by` (Attributes) Deployment creator (see [below for nested schema](#nestedatt--created_by)) - `dag_tarball_version` (String) Deployment DAG tarball version - `desired_dag_tarball_version` (String) Deployment desired DAG tarball version -- `external_ips` (List of String) Deployment external IPs +- `external_ips` (Set of String) Deployment external IPs - `id` (String) Deployment identifier - `image_repository` (String) Deployment image repository - `image_tag` (String) Deployment image tag @@ -174,7 +174,7 @@ Optional: Optional: - `override` (Attributes) (see [below for nested schema](#nestedatt--scaling_spec--hibernation_spec--override)) -- `schedules` (Attributes List) (see [below for nested schema](#nestedatt--scaling_spec--hibernation_spec--schedules)) +- `schedules` (Attributes Set) (see [below for nested schema](#nestedatt--scaling_spec--hibernation_spec--schedules)) ### Nested Schema for `scaling_spec.hibernation_spec.override` @@ -223,7 +223,6 @@ Optional: Read-Only: -- `id` (String) Worker queue identifier - `pod_cpu` (String) Worker queue pod CPU - `pod_memory` (String) Worker queue pod memory diff --git a/docs/resources/workspace.md b/docs/resources/workspace.md index 8eb2dc62..8f24ce8b 100644 --- a/docs/resources/workspace.md +++ b/docs/resources/workspace.md @@ -1,19 +1,19 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "astronomer_workspace Resource - astronomer" +page_title: "astro_workspace Resource - astro" subcategory: "" description: |- Workspace resource --- -# astronomer_workspace (Resource) +# astro_workspace (Resource) Workspace resource ## Example Usage ```terraform -resource "workspace_resource" "example" { +resource "astro_workspace" "example" { name = "my-workspace" description = "my first workspace" cicd_enforced_default = true diff --git a/examples/data-sources/astro_cluster/data-source.tf b/examples/data-sources/astro_cluster/data-source.tf new file mode 100644 index 00000000..89dcc89e --- /dev/null +++ b/examples/data-sources/astro_cluster/data-source.tf @@ -0,0 +1,3 @@ +data "astro_cluster" "example" { + id = "clozc036j01to01jrlgvueo8t" +} diff --git a/examples/data-sources/astro_cluster_options/data-source.tf b/examples/data-sources/astro_cluster_options/data-source.tf new file mode 100644 index 00000000..9b9bae17 --- /dev/null +++ b/examples/data-sources/astro_cluster_options/data-source.tf @@ -0,0 +1,8 @@ +data "astro_cluster_options" "example_cluster_options" { + type = "HYBRID" +} + +data "astro_cluster_options" "example_cluster_options_filter_by_provider" { + type = "HYBRID" + cloud_provider = "AWS" +} diff --git a/examples/data-sources/astro_clusters/data-source.tf b/examples/data-sources/astro_clusters/data-source.tf new file mode 100644 index 00000000..ba518c98 --- /dev/null +++ b/examples/data-sources/astro_clusters/data-source.tf @@ -0,0 +1,9 @@ +data "astro_clusters" "example_clusters" {} + +data "astro_clusters" "example_clusters_filter_by_names" { + names = ["my cluster"] +} + +data "astro_clusters" "example_clusters_filter_by_cloud_provider" { + cloud_provider = ["AWS"] +} \ No newline at end of file diff --git a/examples/data-sources/astro_deployment/data-source.tf b/examples/data-sources/astro_deployment/data-source.tf new file mode 100644 index 00000000..12660926 --- /dev/null +++ b/examples/data-sources/astro_deployment/data-source.tf @@ -0,0 +1,3 @@ +data "astro_deployment" "example" { + id = "clozc036j01to01jrlgvueo8t" +} diff --git a/examples/data-sources/astro_deployment_options/data-source.tf b/examples/data-sources/astro_deployment_options/data-source.tf new file mode 100644 index 00000000..4beb8d0d --- /dev/null +++ b/examples/data-sources/astro_deployment_options/data-source.tf @@ -0,0 +1,17 @@ +data "astro_deployment_options" "example" {} + +data "astro_deployment_options" "example_with_deployment_id_query_param" { + deployment_id = "clozc036j01to01jrlgvueo8t" +} + +data "astro_deployment_options" "example_with_deployment_type_query_param" { + deployment_type = "DEDICATED" +} + +data "astro_deployment_options" "example_with_executor_query_param" { + executor = "CELERY" +} + +data "astro_deployment_options" "example_with_cloud_provider_query_param" { + cloud_provider = "AWS" +} diff --git a/examples/data-sources/astro_deployments/data-source.tf b/examples/data-sources/astro_deployments/data-source.tf new file mode 100644 index 00000000..ba518c98 --- /dev/null +++ b/examples/data-sources/astro_deployments/data-source.tf @@ -0,0 +1,9 @@ +data "astro_clusters" "example_clusters" {} + +data "astro_clusters" "example_clusters_filter_by_names" { + names = ["my cluster"] +} + +data "astro_clusters" "example_clusters_filter_by_cloud_provider" { + cloud_provider = ["AWS"] +} \ No newline at end of file diff --git a/examples/data-sources/astro_organization/data-source.tf b/examples/data-sources/astro_organization/data-source.tf new file mode 100644 index 00000000..6e6e6565 --- /dev/null +++ b/examples/data-sources/astro_organization/data-source.tf @@ -0,0 +1 @@ +data "astro_organization" "example" {} diff --git a/examples/data-sources/astro_workspace/data-source.tf b/examples/data-sources/astro_workspace/data-source.tf new file mode 100644 index 00000000..225de010 --- /dev/null +++ b/examples/data-sources/astro_workspace/data-source.tf @@ -0,0 +1,3 @@ +data "astro_workspace" "example" { + id = "clozc036j01to01jrlgvueo8t" +} diff --git a/examples/data-sources/astro_workspaces/data-source.tf b/examples/data-sources/astro_workspaces/data-source.tf new file mode 100644 index 00000000..bea59091 --- /dev/null +++ b/examples/data-sources/astro_workspaces/data-source.tf @@ -0,0 +1,9 @@ +data "astro_workspaces" "example_workspaces" {} + +data "astro_workspaces" "example_workspaces_filter_by_workspace_ids" { + workspace_ids = ["clozc036j01to01jrlgvueo8t", "clozc036j01to01jrlgvueo81"] +} + +data "astro_workspaces" "example_workspaces_filter_by_names" { + names = ["my first workspace", "my second workspace"] +} diff --git a/examples/data-sources/astronomer_cluster/data-source.tf b/examples/data-sources/astronomer_cluster/data-source.tf deleted file mode 100644 index 831010c9..00000000 --- a/examples/data-sources/astronomer_cluster/data-source.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "astronomer_cluster" "example" { - id = "clozc036j01to01jrlgvueo8t" -} diff --git a/examples/data-sources/astronomer_cluster_options/data-source.tf b/examples/data-sources/astronomer_cluster_options/data-source.tf deleted file mode 100644 index 888b62e8..00000000 --- a/examples/data-sources/astronomer_cluster_options/data-source.tf +++ /dev/null @@ -1,8 +0,0 @@ -data "astronomer_cluster_options" "example_cluster_options" { - type = "HYBRID" -} - -data "astronomer_cluster_options" "example_cluster_options_filter_by_provider" { - type = "HYBRID" - cloud_provider = "AWS" -} diff --git a/examples/data-sources/astronomer_clusters/data-source.tf b/examples/data-sources/astronomer_clusters/data-source.tf deleted file mode 100644 index 232ae891..00000000 --- a/examples/data-sources/astronomer_clusters/data-source.tf +++ /dev/null @@ -1,9 +0,0 @@ -data "astronomer_clusters" "example_clusters" {} - -data "astronomer_clusters" "example_clusters_filter_by_names" { - names = ["my cluster"] -} - -data "astronomer_clusters" "example_clusters_filter_by_cloud_provider" { - cloud_provider = ["AWS"] -} \ No newline at end of file diff --git a/examples/data-sources/astronomer_deployment/data-source.tf b/examples/data-sources/astronomer_deployment/data-source.tf deleted file mode 100644 index fa9333ea..00000000 --- a/examples/data-sources/astronomer_deployment/data-source.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "astronomer_deployment" "example" { - id = "clozc036j01to01jrlgvueo8t" -} diff --git a/examples/data-sources/astronomer_deployment_options/data-source.tf b/examples/data-sources/astronomer_deployment_options/data-source.tf deleted file mode 100644 index 0fbbc298..00000000 --- a/examples/data-sources/astronomer_deployment_options/data-source.tf +++ /dev/null @@ -1,17 +0,0 @@ -data "astronomer_deployment_options" "example" {} - -data "astronomer_deployment_options" "example_with_deployment_id_query_param" { - deployment_id = "clozc036j01to01jrlgvueo8t" -} - -data "astronomer_deployment_options" "example_with_deployment_type_query_param" { - deployment_type = "DEDICATED" -} - -data "astronomer_deployment_options" "example_with_executor_query_param" { - executor = "CELERY" -} - -data "astronomer_deployment_options" "example_with_cloud_provider_query_param" { - cloud_provider = "AWS" -} diff --git a/examples/data-sources/astronomer_deployments/data-source.tf b/examples/data-sources/astronomer_deployments/data-source.tf deleted file mode 100644 index 232ae891..00000000 --- a/examples/data-sources/astronomer_deployments/data-source.tf +++ /dev/null @@ -1,9 +0,0 @@ -data "astronomer_clusters" "example_clusters" {} - -data "astronomer_clusters" "example_clusters_filter_by_names" { - names = ["my cluster"] -} - -data "astronomer_clusters" "example_clusters_filter_by_cloud_provider" { - cloud_provider = ["AWS"] -} \ No newline at end of file diff --git a/examples/data-sources/astronomer_organization/data-source.tf b/examples/data-sources/astronomer_organization/data-source.tf deleted file mode 100644 index 281da173..00000000 --- a/examples/data-sources/astronomer_organization/data-source.tf +++ /dev/null @@ -1 +0,0 @@ -data "astronomer_organization" "example" {} diff --git a/examples/data-sources/astronomer_workspace/data-source.tf b/examples/data-sources/astronomer_workspace/data-source.tf deleted file mode 100644 index 0bd88555..00000000 --- a/examples/data-sources/astronomer_workspace/data-source.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "astronomer_workspace" "example" { - id = "clozc036j01to01jrlgvueo8t" -} diff --git a/examples/data-sources/astronomer_workspaces/data-source.tf b/examples/data-sources/astronomer_workspaces/data-source.tf deleted file mode 100644 index e56ad1af..00000000 --- a/examples/data-sources/astronomer_workspaces/data-source.tf +++ /dev/null @@ -1,9 +0,0 @@ -data "astronomer_workspaces" "example_workspaces" {} - -data "astronomer_workspaces" "example_workspaces_filter_by_workspace_ids" { - workspace_ids = ["clozc036j01to01jrlgvueo8t", "clozc036j01to01jrlgvueo81"] -} - -data "astronomer_workspaces" "example_workspaces_filter_by_names" { - names = ["my first workspace", "my second workspace"] -} diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 177655f3..43d6a268 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -1,3 +1,3 @@ -provider "astronomer" { +provider "astro" { organization_id = "cljzz64cc001n01mln1p12345" } \ No newline at end of file diff --git a/examples/resources/astronomer_cluster/resource.tf b/examples/resources/astro_cluster/resource.tf similarity index 87% rename from examples/resources/astronomer_cluster/resource.tf rename to examples/resources/astro_cluster/resource.tf index 45c57713..4168706d 100644 --- a/examples/resources/astronomer_cluster/resource.tf +++ b/examples/resources/astro_cluster/resource.tf @@ -1,4 +1,4 @@ -resource "astronomer_cluster" "aws_example" { +resource "astro_cluster" "aws_example" { type = "DEDICATED" name = "my first aws cluster" region = "us-east-1" @@ -13,7 +13,7 @@ resource "astronomer_cluster" "aws_example" { } } -resource "astronomer_cluster" "azure_example" { +resource "astro_cluster" "azure_example" { type = "DEDICATED" name = "my first azure cluster" region = "westus2" @@ -23,7 +23,7 @@ resource "astronomer_cluster" "azure_example" { workspace_ids = ["clv4wcf6f003u01m3zp7gsvzg"] } -resource "astronomer_cluster" "gcp_example" { +resource "astro_cluster" "gcp_example" { type = "DEDICATED" name = "my first gcp cluster" region = "us-central1" diff --git a/examples/resources/astronomer_deployment/resource.tf b/examples/resources/astro_deployment/resource.tf similarity index 94% rename from examples/resources/astronomer_deployment/resource.tf rename to examples/resources/astro_deployment/resource.tf index 8ba97dd3..2972a034 100644 --- a/examples/resources/astronomer_deployment/resource.tf +++ b/examples/resources/astro_deployment/resource.tf @@ -1,4 +1,4 @@ -resource "astronomer_deployment" "dedicated" { +resource "astro_deployment" "dedicated" { name = "my dedicated deployment" description = "an example deployment" type = "DEDICATED" @@ -22,7 +22,7 @@ resource "astronomer_deployment" "dedicated" { }] } -resource "astronomer_deployment" "standard" { +resource "astro_deployment" "standard" { name = "my standard deployment" description = "an example deployment" type = "STANDARD" @@ -51,7 +51,7 @@ resource "astronomer_deployment" "standard" { }] } -resource "astronomer_deployment" "hybrid" { +resource "astro_deployment" "hybrid" { name = "my hybrid deployment" description = "an example deployment" type = "HYBRID" diff --git a/examples/resources/astronomer_workspace/resource.tf b/examples/resources/astro_workspace/resource.tf similarity index 74% rename from examples/resources/astronomer_workspace/resource.tf rename to examples/resources/astro_workspace/resource.tf index c29b0337..51a0da1a 100644 --- a/examples/resources/astronomer_workspace/resource.tf +++ b/examples/resources/astro_workspace/resource.tf @@ -1,4 +1,4 @@ -resource "workspace_resource" "example" { +resource "astro_workspace" "example" { name = "my-workspace" description = "my first workspace" cicd_enforced_default = true diff --git a/go.mod b/go.mod index 79bfe5bd..38926af8 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/astronomer/astronomer-terraform-provider +module github.com/astronomer/terraform-provider-astro go 1.21 diff --git a/internal/clients/iam/client.go b/internal/clients/iam/client.go index 7a0458c3..6dc6b293 100644 --- a/internal/clients/iam/client.go +++ b/internal/clients/iam/client.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients" ) func NewIamClient(host, token, version string) (*ClientWithResponses, error) { diff --git a/internal/clients/platform/client.go b/internal/clients/platform/client.go index 315dc184..935fc595 100644 --- a/internal/clients/platform/client.go +++ b/internal/clients/platform/client.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients" ) func NewPlatformClient(host, token, version string) (*ClientWithResponses, error) { diff --git a/internal/clients/utils.go b/internal/clients/utils.go index 4c14ae65..dc44281d 100644 --- a/internal/clients/utils.go +++ b/internal/clients/utils.go @@ -26,10 +26,10 @@ func CoreRequestEditor( } req.URL = requestURL req.Header.Add("authorization", fmt.Sprintf("Bearer %v", token)) - req.Header.Add("x-astro-client-identifier", "astronomer-terraform-provider") + req.Header.Add("x-astro-client-identifier", "terraform-provider-astro") req.Header.Add("x-astro-client-version", version) req.Header.Add("x-client-os-identifier", os+"-"+arch) - req.Header.Add("User-Agent", fmt.Sprintf("astronomer-terraform-provider/%s", version)) + req.Header.Add("User-Agent", fmt.Sprintf("terraform-provider-astro/%s", version)) return nil } diff --git a/internal/clients/utils_test.go b/internal/clients/utils_test.go index 99b748a4..97ea6aec 100644 --- a/internal/clients/utils_test.go +++ b/internal/clients/utils_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients" ) func TestUnit_CoreRequestEditor(t *testing.T) { @@ -19,10 +19,10 @@ func TestUnit_CoreRequestEditor(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "http://localhost/path", req.URL.String()) assert.Equal(t, "Bearer token", req.Header.Get("authorization")) - assert.Equal(t, "astronomer-terraform-provider", req.Header.Get("x-astro-client-identifier")) + assert.Equal(t, "terraform-provider-astro", req.Header.Get("x-astro-client-identifier")) assert.NotEmpty(t, req.Header.Get("x-astro-client-version")) assert.NotEmpty(t, req.Header.Get("x-client-os-identifier")) - assert.Equal(t, "astronomer-terraform-provider/v1", req.Header.Get("User-Agent")) + assert.Equal(t, "terraform-provider-astro/v1", req.Header.Get("User-Agent")) } func TestUnit_NormalizeAPIError(t *testing.T) { diff --git a/internal/provider/datasources/data_source_cluster.go b/internal/provider/datasources/data_source_cluster.go index b76a1747..837bd852 100644 --- a/internal/provider/datasources/data_source_cluster.go +++ b/internal/provider/datasources/data_source_cluster.go @@ -4,11 +4,11 @@ import ( "context" "fmt" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-log/tflog" diff --git a/internal/provider/datasources/data_source_cluster_options.go b/internal/provider/datasources/data_source_cluster_options.go index 0d0a681d..31635da0 100644 --- a/internal/provider/datasources/data_source_cluster_options.go +++ b/internal/provider/datasources/data_source_cluster_options.go @@ -4,11 +4,11 @@ import ( "context" "fmt" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-log/tflog" diff --git a/internal/provider/datasources/data_source_cluster_options_test.go b/internal/provider/datasources/data_source_cluster_options_test.go index 236c1527..bc12feca 100644 --- a/internal/provider/datasources/data_source_cluster_options_test.go +++ b/internal/provider/datasources/data_source_cluster_options_test.go @@ -5,9 +5,9 @@ import ( "regexp" "testing" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/utils" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" ) @@ -41,7 +41,7 @@ func TestAcc_DataSourceClusterOptions(t *testing.T) { func clusterOptions(clusterType, provider string) string { return fmt.Sprintf(` -data astronomer_cluster_options "test_data_cluster_options" { +data astro_cluster_options "test_data_cluster_options" { type = "%v" cloud_provider = "%v" }`, clusterType, provider) @@ -49,7 +49,7 @@ data astronomer_cluster_options "test_data_cluster_options" { func clusterOptionsWithoutProviderFilter(clusterType string) string { return fmt.Sprintf(` -data astronomer_cluster_options "test_data_cluster_options" { +data astro_cluster_options "test_data_cluster_options" { type = "%v" }`, clusterType) } diff --git a/internal/provider/datasources/data_source_cluster_test.go b/internal/provider/datasources/data_source_cluster_test.go index c29c7337..7044821c 100644 --- a/internal/provider/datasources/data_source_cluster_test.go +++ b/internal/provider/datasources/data_source_cluster_test.go @@ -5,14 +5,14 @@ import ( "os" "testing" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) func TestAcc_DataSourceCluster(t *testing.T) { hybridClusterId := os.Getenv("HYBRID_CLUSTER_ID") resourceName := "test_data_cluster_hybrid" - resourceVar := fmt.Sprintf("data.astronomer_cluster.%v", resourceName) + resourceVar := fmt.Sprintf("data.astro_cluster.%v", resourceName) resource.Test(t, resource.TestCase{ PreCheck: func() { astronomerprovider.TestAccPreCheck(t) @@ -45,7 +45,7 @@ func TestAcc_DataSourceCluster(t *testing.T) { func cluster(resourceName, clusterId string) string { return fmt.Sprintf(` -data astronomer_cluster "%v" { +data astro_cluster "%v" { id = "%v" }`, resourceName, clusterId) } diff --git a/internal/provider/datasources/data_source_clusters.go b/internal/provider/datasources/data_source_clusters.go index b37d776e..951f001f 100644 --- a/internal/provider/datasources/data_source_clusters.go +++ b/internal/provider/datasources/data_source_clusters.go @@ -8,11 +8,11 @@ import ( "github.com/samber/lo" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -92,7 +92,7 @@ func (d *clustersDataSource) Read( if len(data.CloudProvider.ValueString()) > 0 { params.Provider = (*platform.ListClustersParamsProvider)(data.CloudProvider.ValueStringPointer()) } - params.Names, diags = utils.TypesListToStringSlicePtr(ctx, data.Names) + params.Names, diags = utils.TypesSetToStringSlicePtr(ctx, data.Names) if diags.HasError() { resp.Diagnostics.Append(diags...) return diff --git a/internal/provider/datasources/data_source_clusters_test.go b/internal/provider/datasources/data_source_clusters_test.go index ae1f121a..bb45f9bf 100644 --- a/internal/provider/datasources/data_source_clusters_test.go +++ b/internal/provider/datasources/data_source_clusters_test.go @@ -4,12 +4,12 @@ import ( "fmt" "testing" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/utils" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" "github.com/hashicorp/terraform-plugin-testing/terraform" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) @@ -34,7 +34,7 @@ func TestAcc_DataSourceClustersHybrid(t *testing.T) { func clusters(tfVarName string) string { return fmt.Sprintf(` -data astronomer_clusters "%v" {}`, tfVarName) +data astro_clusters "%v" {}`, tfVarName) } func checkClusters(tfVarName string) resource.TestCheckFunc { diff --git a/internal/provider/datasources/data_source_deployment.go b/internal/provider/datasources/data_source_deployment.go index 1c95b5ef..675bf97d 100644 --- a/internal/provider/datasources/data_source_deployment.go +++ b/internal/provider/datasources/data_source_deployment.go @@ -4,11 +4,11 @@ import ( "context" "fmt" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -106,7 +106,7 @@ func (d *deploymentDataSource) Read( } // Populate the model with the response data - diags := data.ReadFromResponse(ctx, deployment.JSON200) + diags := data.ReadFromResponse(ctx, deployment.JSON200, false) if diags.HasError() { resp.Diagnostics.Append(diags...) return diff --git a/internal/provider/datasources/data_source_deployment_options.go b/internal/provider/datasources/data_source_deployment_options.go index 4317dd72..6e6794b9 100644 --- a/internal/provider/datasources/data_source_deployment_options.go +++ b/internal/provider/datasources/data_source_deployment_options.go @@ -4,11 +4,11 @@ import ( "context" "fmt" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-log/tflog" diff --git a/internal/provider/datasources/data_source_deployment_options_test.go b/internal/provider/datasources/data_source_deployment_options_test.go index 3a1d5138..40c79499 100644 --- a/internal/provider/datasources/data_source_deployment_options_test.go +++ b/internal/provider/datasources/data_source_deployment_options_test.go @@ -5,13 +5,13 @@ import ( "strconv" "testing" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) func TestAcc_DataSourceDeploymentOptionsHosted(t *testing.T) { resourceName := "test_hosted" - resourceVar := fmt.Sprintf("data.astronomer_deployment_options.%v", resourceName) + resourceVar := fmt.Sprintf("data.astro_deployment_options.%v", resourceName) resource.Test(t, resource.TestCase{ PreCheck: func() { astronomerprovider.TestAccPreCheck(t) @@ -72,7 +72,7 @@ func TestAcc_DataSourceDeploymentOptionsHosted(t *testing.T) { func TestAcc_DataSourceDeploymentOptionsHybrid(t *testing.T) { resourceName := "test_hybrid" - resourceVar := fmt.Sprintf("data.astronomer_deployment_options.%v", resourceName) + resourceVar := fmt.Sprintf("data.astro_deployment_options.%v", resourceName) resource.Test(t, resource.TestCase{ PreCheck: func() { astronomerprovider.TestAccPreCheck(t) @@ -174,7 +174,7 @@ func CheckAttributeLengthIsNotEmpty(value string) error { func deploymentOptions(tfVarName, queryParams string) string { return fmt.Sprintf(` -data astronomer_deployment_options "%v" { +data astro_deployment_options "%v" { %v }`, tfVarName, queryParams) } diff --git a/internal/provider/datasources/data_source_deployments.go b/internal/provider/datasources/data_source_deployments.go index dbc875b1..c897390d 100644 --- a/internal/provider/datasources/data_source_deployments.go +++ b/internal/provider/datasources/data_source_deployments.go @@ -8,11 +8,11 @@ import ( "github.com/samber/lo" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -89,17 +89,17 @@ func (d *deploymentsDataSource) Read( Limit: lo.ToPtr(1000), } var diags diag.Diagnostics - params.DeploymentIds, diags = utils.TypesListToStringSlicePtr(ctx, data.DeploymentIds) + params.DeploymentIds, diags = utils.TypesSetToStringSlicePtr(ctx, data.DeploymentIds) if diags.HasError() { resp.Diagnostics.Append(diags...) return } - params.WorkspaceIds, diags = utils.TypesListToStringSlicePtr(ctx, data.WorkspaceIds) + params.WorkspaceIds, diags = utils.TypesSetToStringSlicePtr(ctx, data.WorkspaceIds) if diags.HasError() { resp.Diagnostics.Append(diags...) return } - params.Names, diags = utils.TypesListToStringSlicePtr(ctx, data.Names) + params.Names, diags = utils.TypesSetToStringSlicePtr(ctx, data.Names) if diags.HasError() { resp.Diagnostics.Append(diags...) return diff --git a/internal/provider/datasources/data_source_deployments_test.go b/internal/provider/datasources/data_source_deployments_test.go index a9b1744e..c880c8a5 100644 --- a/internal/provider/datasources/data_source_deployments_test.go +++ b/internal/provider/datasources/data_source_deployments_test.go @@ -6,8 +6,8 @@ import ( "github.com/lucsky/cuid" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" ) @@ -28,47 +28,47 @@ func TestAcc_DataSourceDeployments(t *testing.T) { // Doing all checks in one step because we do not want to unnecessarily create multiple deployments for the data sources test // These checks are for the deployment data source (singular) - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "id"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "name", fmt.Sprintf("%v-1", deploymentName)), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "description"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "workspace_id"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "created_by.id"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "created_at"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "updated_by.id"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "updated_at"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "region", "us-east4"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "cloud_provider", "GCP"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "astro_runtime_version"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "airflow_version"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "namespace"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "contact_emails.0", "preview@astronomer.test"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "executor", "KUBERNETES"), - resource.TestCheckNoResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "worker_queues"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "scheduler_replicas"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "image_tag"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "image_repository"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "environment_variables.0.key", "key1"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "environment_variables.0.value", "value1"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "environment_variables.0.is_secret", "false"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "webserver_ingress_hostname"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "webserver_url"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "webserver_airflow_api_url"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "status"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "is_cicd_enforced", "true"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "type", "STANDARD"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "is_dag_deploy_enabled", "true"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "scheduler_size", "SMALL"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "is_high_availability", "true"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "is_development_mode", "false"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "workload_identity"), - resource.TestCheckResourceAttrSet("data.astronomer_deployment.test_data_deployment_kubernetes", "external_ips.0"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "resource_quota_cpu", "10"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "resource_quota_memory", "20Gi"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "default_task_pod_cpu", "0.25"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_kubernetes", "default_task_pod_memory", "0.5Gi"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "id"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "name", fmt.Sprintf("%v-1", deploymentName)), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "description"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "workspace_id"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "created_by.id"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "created_at"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "updated_by.id"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "updated_at"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "region", "us-east4"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "cloud_provider", "GCP"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "astro_runtime_version"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "airflow_version"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "namespace"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "contact_emails.0", "preview@astronomer.test"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "executor", "KUBERNETES"), + resource.TestCheckNoResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "worker_queues"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "scheduler_replicas"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "image_tag"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "image_repository"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "environment_variables.0.key", "key1"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "environment_variables.0.value", "value1"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "environment_variables.0.is_secret", "false"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "webserver_ingress_hostname"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "webserver_url"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "webserver_airflow_api_url"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "status"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "is_cicd_enforced", "true"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "type", "STANDARD"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "is_dag_deploy_enabled", "true"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "scheduler_size", "SMALL"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "is_high_availability", "true"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "is_development_mode", "false"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "workload_identity"), + resource.TestCheckResourceAttrSet("data.astro_deployment.test_data_deployment_kubernetes", "external_ips.0"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "resource_quota_cpu", "10"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "resource_quota_memory", "20Gi"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "default_task_pod_cpu", "0.25"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_kubernetes", "default_task_pod_memory", "0.5Gi"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_celery", "executor", "CELERY"), - resource.TestCheckResourceAttr("data.astronomer_deployment.test_data_deployment_celery", "worker_queues.0.name", "default"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_celery", "executor", "CELERY"), + resource.TestCheckResourceAttr("data.astro_deployment.test_data_deployment_celery", "worker_queues.0.name", "default"), // These checks are for the deployments data source (plural) checkDeployments("test_data_deployments_no_filters", deploymentName+"-1"), @@ -106,18 +106,18 @@ func TestAcc_DataSourceDeployments(t *testing.T) { func hybridDeployments() string { return ` -data astronomer_deployments "test_data_deployments_hybrid_no_filters" {}` +data astro_deployments "test_data_deployments_hybrid_no_filters" {}` } func hostedDeployments(name string) string { return fmt.Sprintf(` -resource "astronomer_workspace" "test_workspace" { +resource "astro_workspace" "test_workspace" { name = "%v" description = "%v" cicd_enforced_default = true } -resource "astronomer_deployment" "test_deployment_kubernetes" { +resource "astro_deployment" "test_deployment_kubernetes" { name = "%v-1" description = "%v" type = "STANDARD" @@ -134,7 +134,7 @@ resource "astronomer_deployment" "test_deployment_kubernetes" { resource_quota_cpu = "10" resource_quota_memory = "20Gi" scheduler_size = "SMALL" - workspace_id = astronomer_workspace.test_workspace.id + workspace_id = astro_workspace.test_workspace.id environment_variables = [{ key = "key1" value = "value1" @@ -142,7 +142,7 @@ resource "astronomer_deployment" "test_deployment_kubernetes" { }] } -resource "astronomer_deployment" "test_deployment_celery" { +resource "astro_deployment" "test_deployment_celery" { name = "%v-2" description = "%v" type = "STANDARD" @@ -159,7 +159,7 @@ resource "astronomer_deployment" "test_deployment_celery" { resource_quota_cpu = "10" resource_quota_memory = "20Gi" scheduler_size = "SMALL" - workspace_id = astronomer_workspace.test_workspace.id + workspace_id = astro_workspace.test_workspace.id environment_variables = [] worker_queues = [{ name = "default" @@ -171,47 +171,47 @@ resource "astronomer_deployment" "test_deployment_celery" { }] } -data astronomer_deployment "test_data_deployment_kubernetes" { - depends_on = [astronomer_deployment.test_deployment_kubernetes] - id = astronomer_deployment.test_deployment_kubernetes.id +data astro_deployment "test_data_deployment_kubernetes" { + depends_on = [astro_deployment.test_deployment_kubernetes] + id = astro_deployment.test_deployment_kubernetes.id } -data astronomer_deployment "test_data_deployment_celery" { - depends_on = [astronomer_deployment.test_deployment_celery] - id = astronomer_deployment.test_deployment_celery.id +data astro_deployment "test_data_deployment_celery" { + depends_on = [astro_deployment.test_deployment_celery] + id = astro_deployment.test_deployment_celery.id } -data astronomer_deployments "test_data_deployments_no_filters" { - depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery] +data astro_deployments "test_data_deployments_no_filters" { + depends_on = [astro_deployment.test_deployment_kubernetes, astro_deployment.test_deployment_celery] } -data astronomer_deployments "test_data_deployments_workspace_ids_filter" { - depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery] - workspace_ids = [astronomer_workspace.test_workspace.id] +data astro_deployments "test_data_deployments_workspace_ids_filter" { + depends_on = [astro_deployment.test_deployment_kubernetes, astro_deployment.test_deployment_celery] + workspace_ids = [astro_workspace.test_workspace.id] } -data astronomer_deployments "test_data_deployments_deployment_ids_filter" { - depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery] - deployment_ids = [astronomer_deployment.test_deployment_kubernetes.id] +data astro_deployments "test_data_deployments_deployment_ids_filter" { + depends_on = [astro_deployment.test_deployment_kubernetes, astro_deployment.test_deployment_celery] + deployment_ids = [astro_deployment.test_deployment_kubernetes.id] } -data astronomer_deployments "test_data_deployments_names_filter" { - depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery] +data astro_deployments "test_data_deployments_names_filter" { + depends_on = [astro_deployment.test_deployment_kubernetes, astro_deployment.test_deployment_celery] names = ["%v-1"] } -data astronomer_deployments "test_data_deployments_incorrect_workspace_ids_filter" { - depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery] +data astro_deployments "test_data_deployments_incorrect_workspace_ids_filter" { + depends_on = [astro_deployment.test_deployment_kubernetes, astro_deployment.test_deployment_celery] workspace_ids = ["%v"] } -data astronomer_deployments "test_data_deployments_incorrect_deployment_ids_filter" { - depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery] +data astro_deployments "test_data_deployments_incorrect_deployment_ids_filter" { + depends_on = [astro_deployment.test_deployment_kubernetes, astro_deployment.test_deployment_celery] deployment_ids = ["%v"] } -data astronomer_deployments "test_data_deployments_incorrect_names_filter" { - depends_on = [astronomer_deployment.test_deployment_kubernetes, astronomer_deployment.test_deployment_celery] +data astro_deployments "test_data_deployments_incorrect_names_filter" { + depends_on = [astro_deployment.test_deployment_kubernetes, astro_deployment.test_deployment_celery] names = ["%v"] } `, name, utils.TestResourceDescription, name, utils.TestResourceDescription, name, utils.TestResourceDescription, name, cuid.New(), cuid.New(), cuid.New()) diff --git a/internal/provider/datasources/data_source_organization.go b/internal/provider/datasources/data_source_organization.go index 4553db02..a5bc05f2 100644 --- a/internal/provider/datasources/data_source_organization.go +++ b/internal/provider/datasources/data_source_organization.go @@ -4,11 +4,11 @@ import ( "context" "fmt" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-log/tflog" diff --git a/internal/provider/datasources/data_source_organization_test.go b/internal/provider/datasources/data_source_organization_test.go index b56eb919..ccf31130 100644 --- a/internal/provider/datasources/data_source_organization_test.go +++ b/internal/provider/datasources/data_source_organization_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) @@ -19,15 +19,15 @@ func TestAcc_DataSourceOrganization(t *testing.T) { { Config: astronomerprovider.ProviderConfig(t, true) + organization(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("data.astronomer_organization.t", "id", os.Getenv("HOSTED_ORGANIZATION_ID")), - resource.TestCheckResourceAttrSet("data.astronomer_organization.t", "name"), - resource.TestCheckResourceAttrSet("data.astronomer_organization.t", "support_plan"), - resource.TestCheckResourceAttrSet("data.astronomer_organization.t", "product"), - resource.TestCheckResourceAttrSet("data.astronomer_organization.t", "created_by.id"), - resource.TestCheckResourceAttrSet("data.astronomer_organization.t", "created_at"), - resource.TestCheckResourceAttrSet("data.astronomer_organization.t", "updated_by.id"), - resource.TestCheckResourceAttrSet("data.astronomer_organization.t", "updated_at"), - resource.TestCheckResourceAttrSet("data.astronomer_organization.t", "status"), + resource.TestCheckResourceAttr("data.astro_organization.t", "id", os.Getenv("HOSTED_ORGANIZATION_ID")), + resource.TestCheckResourceAttrSet("data.astro_organization.t", "name"), + resource.TestCheckResourceAttrSet("data.astro_organization.t", "support_plan"), + resource.TestCheckResourceAttrSet("data.astro_organization.t", "product"), + resource.TestCheckResourceAttrSet("data.astro_organization.t", "created_by.id"), + resource.TestCheckResourceAttrSet("data.astro_organization.t", "created_at"), + resource.TestCheckResourceAttrSet("data.astro_organization.t", "updated_by.id"), + resource.TestCheckResourceAttrSet("data.astro_organization.t", "updated_at"), + resource.TestCheckResourceAttrSet("data.astro_organization.t", "status"), ), }, }, @@ -36,5 +36,5 @@ func TestAcc_DataSourceOrganization(t *testing.T) { func organization() string { return ` -data astronomer_organization "t" {}` +data astro_organization "t" {}` } diff --git a/internal/provider/datasources/data_source_workspace.go b/internal/provider/datasources/data_source_workspace.go index 60e09ab3..ef72e931 100644 --- a/internal/provider/datasources/data_source_workspace.go +++ b/internal/provider/datasources/data_source_workspace.go @@ -4,11 +4,11 @@ import ( "context" "fmt" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-log/tflog" diff --git a/internal/provider/datasources/data_source_workspaces.go b/internal/provider/datasources/data_source_workspaces.go index 84e2ac07..7e7d93cc 100644 --- a/internal/provider/datasources/data_source_workspaces.go +++ b/internal/provider/datasources/data_source_workspaces.go @@ -8,11 +8,11 @@ import ( "github.com/samber/lo" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -89,13 +89,13 @@ func (d *workspacesDataSource) Read( Limit: lo.ToPtr(1000), } var diags diag.Diagnostics - params.WorkspaceIds, diags = utils.TypesListToStringSlicePtr(ctx, data.WorkspaceIds) + params.WorkspaceIds, diags = utils.TypesSetToStringSlicePtr(ctx, data.WorkspaceIds) if diags.HasError() { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to read workspaces, got error %v", diags.Errors()[0].Summary())) resp.Diagnostics.Append(diags...) return } - params.Names, diags = utils.TypesListToStringSlicePtr(ctx, data.Names) + params.Names, diags = utils.TypesSetToStringSlicePtr(ctx, data.Names) if diags.HasError() { resp.Diagnostics.Append(diags...) return diff --git a/internal/provider/datasources/data_source_workspaces_test.go b/internal/provider/datasources/data_source_workspaces_test.go index a5f0de84..6db21a8f 100644 --- a/internal/provider/datasources/data_source_workspaces_test.go +++ b/internal/provider/datasources/data_source_workspaces_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/lucsky/cuid" @@ -25,14 +25,14 @@ func TestAcc_DataSourceWorkspaces(t *testing.T) { Config: astronomerprovider.ProviderConfig(t, true) + workspaces(workspaceName, ""), Check: resource.ComposeTestCheckFunc( // These checks are for the workspace data source (singular) - resource.TestCheckResourceAttrSet("data.astronomer_workspace.test_data_workspace", "id"), - resource.TestCheckResourceAttr("data.astronomer_workspace.test_data_workspace", "name", fmt.Sprintf("%v-1", workspaceName)), - resource.TestCheckResourceAttrSet("data.astronomer_workspace.test_data_workspace", "description"), - resource.TestCheckResourceAttr("data.astronomer_workspace.test_data_workspace", "cicd_enforced_default", "true"), - resource.TestCheckResourceAttrSet("data.astronomer_workspace.test_data_workspace", "created_by.id"), - resource.TestCheckResourceAttrSet("data.astronomer_workspace.test_data_workspace", "created_at"), - resource.TestCheckResourceAttrSet("data.astronomer_workspace.test_data_workspace", "updated_by.id"), - resource.TestCheckResourceAttrSet("data.astronomer_workspace.test_data_workspace", "updated_at"), + resource.TestCheckResourceAttrSet("data.astro_workspace.test_data_workspace", "id"), + resource.TestCheckResourceAttr("data.astro_workspace.test_data_workspace", "name", fmt.Sprintf("%v-1", workspaceName)), + resource.TestCheckResourceAttrSet("data.astro_workspace.test_data_workspace", "description"), + resource.TestCheckResourceAttr("data.astro_workspace.test_data_workspace", "cicd_enforced_default", "true"), + resource.TestCheckResourceAttrSet("data.astro_workspace.test_data_workspace", "created_by.id"), + resource.TestCheckResourceAttrSet("data.astro_workspace.test_data_workspace", "created_at"), + resource.TestCheckResourceAttrSet("data.astro_workspace.test_data_workspace", "updated_by.id"), + resource.TestCheckResourceAttrSet("data.astro_workspace.test_data_workspace", "updated_at"), // These checks are for the workspaces data source (plural) checkWorkspaces(workspaceName+"-1"), @@ -41,7 +41,7 @@ func TestAcc_DataSourceWorkspaces(t *testing.T) { }, // The following tests are for filtering the workspaces data source { - Config: astronomerprovider.ProviderConfig(t, true) + workspaces(workspaceName, `workspace_ids = [astronomer_workspace.test_workspace1.id]`), + Config: astronomerprovider.ProviderConfig(t, true) + workspaces(workspaceName, `workspace_ids = [astro_workspace.test_workspace1.id]`), Check: resource.ComposeTestCheckFunc( checkWorkspaces(workspaceName + "-1"), ), @@ -66,25 +66,25 @@ func TestAcc_DataSourceWorkspaces(t *testing.T) { func workspaces(name, filter string) string { return fmt.Sprintf(` -resource "astronomer_workspace" "test_workspace1" { +resource "astro_workspace" "test_workspace1" { name = "%v-1" description = "%v" cicd_enforced_default = true } -resource "astronomer_workspace" "test_workspace2" { +resource "astro_workspace" "test_workspace2" { name = "%v-2" description = "%v" cicd_enforced_default = true } -data astronomer_workspace "test_data_workspace" { - depends_on = [astronomer_workspace.test_workspace1] - id = astronomer_workspace.test_workspace1.id +data astro_workspace "test_data_workspace" { + depends_on = [astro_workspace.test_workspace1] + id = astro_workspace.test_workspace1.id } -data astronomer_workspaces "test_data_workspaces" { - depends_on = [astronomer_workspace.test_workspace1, astronomer_workspace.test_workspace2] +data astro_workspaces "test_data_workspaces" { + depends_on = [astro_workspace.test_workspace1, astro_workspace.test_workspace2] %v }`, name, utils.TestResourceDescription, name, utils.TestResourceDescription, filter) } diff --git a/internal/provider/models/api_clients.go b/internal/provider/models/api_clients.go index d6e5b977..a73b882f 100644 --- a/internal/provider/models/api_clients.go +++ b/internal/provider/models/api_clients.go @@ -1,8 +1,8 @@ package models import ( - "github.com/astronomer/astronomer-terraform-provider/internal/clients/iam" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/clients/iam" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" ) type ApiClientsModel struct { diff --git a/internal/provider/models/cluster.go b/internal/provider/models/cluster.go index 363ec3ef..2f020589 100644 --- a/internal/provider/models/cluster.go +++ b/internal/provider/models/cluster.go @@ -5,9 +5,9 @@ import ( "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" ) @@ -30,8 +30,8 @@ type ClusterResource struct { Type types.String `tfsdk:"type"` TenantId types.String `tfsdk:"tenant_id"` ProviderAccount types.String `tfsdk:"provider_account"` - NodePools types.List `tfsdk:"node_pools"` - WorkspaceIds types.List `tfsdk:"workspace_ids"` + NodePools types.Set `tfsdk:"node_pools"` + WorkspaceIds types.Set `tfsdk:"workspace_ids"` IsLimited types.Bool `tfsdk:"is_limited"` Timeouts timeouts.Value `tfsdk:"timeouts"` // To allow users to set timeouts for the resource. } @@ -54,9 +54,9 @@ type ClusterDataSource struct { Type types.String `tfsdk:"type"` TenantId types.String `tfsdk:"tenant_id"` ProviderAccount types.String `tfsdk:"provider_account"` - NodePools types.List `tfsdk:"node_pools"` - WorkspaceIds types.List `tfsdk:"workspace_ids"` - Tags types.List `tfsdk:"tags"` + NodePools types.Set `tfsdk:"node_pools"` + WorkspaceIds types.Set `tfsdk:"workspace_ids"` + Tags types.Set `tfsdk:"tags"` IsLimited types.Bool `tfsdk:"is_limited"` } @@ -73,7 +73,7 @@ type NodePool struct { MaxNodeCount types.Int64 `tfsdk:"max_node_count"` NodeInstanceType types.String `tfsdk:"node_instance_type"` IsDefault types.Bool `tfsdk:"is_default"` - SupportedAstroMachines types.List `tfsdk:"supported_astro_machines"` + SupportedAstroMachines types.Set `tfsdk:"supported_astro_machines"` CreatedAt types.String `tfsdk:"created_at"` UpdatedAt types.String `tfsdk:"updated_at"` } @@ -102,11 +102,11 @@ func (data *ClusterResource) ReadFromResponse( data.Type = types.StringValue(string(cluster.Type)) data.TenantId = types.StringPointerValue(cluster.TenantId) data.ProviderAccount = types.StringPointerValue(cluster.ProviderAccount) - data.NodePools, diags = utils.ObjectList(ctx, cluster.NodePools, schemas.NodePoolAttributeTypes(), NodePoolTypesObject) + data.NodePools, diags = utils.ObjectSet(ctx, cluster.NodePools, schemas.NodePoolAttributeTypes(), NodePoolTypesObject) if diags.HasError() { return diags } - data.WorkspaceIds, diags = utils.StringList(cluster.WorkspaceIds) + data.WorkspaceIds, diags = utils.StringSet(cluster.WorkspaceIds) if diags.HasError() { return diags } @@ -139,15 +139,15 @@ func (data *ClusterDataSource) ReadFromResponse( data.Type = types.StringValue(string(cluster.Type)) data.TenantId = types.StringPointerValue(cluster.TenantId) data.ProviderAccount = types.StringPointerValue(cluster.ProviderAccount) - data.NodePools, diags = utils.ObjectList(ctx, cluster.NodePools, schemas.NodePoolAttributeTypes(), NodePoolTypesObject) + data.NodePools, diags = utils.ObjectSet(ctx, cluster.NodePools, schemas.NodePoolAttributeTypes(), NodePoolTypesObject) if diags.HasError() { return diags } - data.WorkspaceIds, diags = utils.StringList(cluster.WorkspaceIds) + data.WorkspaceIds, diags = utils.StringSet(cluster.WorkspaceIds) if diags.HasError() { return diags } - data.Tags, diags = utils.ObjectList(ctx, cluster.Tags, schemas.ClusterTagAttributeTypes(), ClusterTagTypesObject) + data.Tags, diags = utils.ObjectSet(ctx, cluster.Tags, schemas.ClusterTagAttributeTypes(), ClusterTagTypesObject) if diags.HasError() { return diags } @@ -172,7 +172,7 @@ func NodePoolTypesObject( ctx context.Context, nodePool platform.NodePool, ) (types.Object, diag.Diagnostics) { - supportedAstroMachines, diags := utils.StringList(nodePool.SupportedAstroMachines) + supportedAstroMachines, diags := utils.StringSet(nodePool.SupportedAstroMachines) if diags.HasError() { return types.ObjectNull(schemas.NodePoolAttributeTypes()), diags } @@ -194,7 +194,7 @@ func NodePoolTypesObject( type ClusterMetadata struct { OidcIssuerUrl types.String `tfsdk:"oidc_issuer_url"` - ExternalIps types.List `tfsdk:"external_ips"` + ExternalIps types.Set `tfsdk:"external_ips"` } func ClusterMetadataTypesObject( @@ -202,7 +202,7 @@ func ClusterMetadataTypesObject( metadata *platform.ClusterMetadata, ) (types.Object, diag.Diagnostics) { if metadata != nil { - externalIps, diags := utils.StringList(metadata.ExternalIPs) + externalIps, diags := utils.StringSet(metadata.ExternalIPs) if diags.HasError() { return types.ObjectNull(schemas.ClusterMetadataAttributeTypes()), diags } diff --git a/internal/provider/models/cluster_options.go b/internal/provider/models/cluster_options.go index 85e4b943..c4a0942e 100644 --- a/internal/provider/models/cluster_options.go +++ b/internal/provider/models/cluster_options.go @@ -3,10 +3,10 @@ package models import ( "context" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/utils" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" @@ -14,7 +14,7 @@ import ( // ClusterOptionsDataSource describes the data source data model. type ClusterOptionsDataSource struct { - ClusterOptions types.List `tfsdk:"cluster_options"` + ClusterOptions types.Set `tfsdk:"cluster_options"` Type types.String `tfsdk:"type"` CloudProvider types.String `tfsdk:"cloud_provider"` } @@ -24,7 +24,7 @@ func (data *ClusterOptionsDataSource) ReadFromResponse( clusterOptions []platform.ClusterOptions, ) diag.Diagnostics { if len(clusterOptions) == 0 { - types.ListNull(types.ObjectType{AttrTypes: schemas.ClusterOptionsElementAttributeTypes()}) + types.SetNull(types.ObjectType{AttrTypes: schemas.ClusterOptionsElementAttributeTypes()}) } values := make([]attr.Value, len(clusterOptions)) @@ -42,7 +42,7 @@ func (data *ClusterOptionsDataSource) ReadFromResponse( values[i] = objectValue } var diags diag.Diagnostics - data.ClusterOptions, diags = types.ListValue(types.ObjectType{AttrTypes: schemas.ClusterOptionsElementAttributeTypes()}, values) + data.ClusterOptions, diags = types.SetValue(types.ObjectType{AttrTypes: schemas.ClusterOptionsElementAttributeTypes()}, values) if diags.HasError() { return diags } @@ -60,11 +60,11 @@ type ClusterOptionDataSource struct { NodeCountMax types.Int64 `tfsdk:"node_count_max"` NodeCountDefault types.Int64 `tfsdk:"node_count_default"` DefaultRegion types.Object `tfsdk:"default_region"` - Regions types.List `tfsdk:"regions"` + Regions types.Set `tfsdk:"regions"` DefaultNodeInstance types.Object `tfsdk:"default_node_instance"` - NodeInstances types.List `tfsdk:"node_instances"` + NodeInstances types.Set `tfsdk:"node_instances"` DefaultDatabaseInstance types.Object `tfsdk:"default_database_instance"` - DatabaseInstances types.List `tfsdk:"database_instances"` + DatabaseInstances types.Set `tfsdk:"database_instances"` } func (data *ClusterOptionDataSource) ReadFromResponse( @@ -85,7 +85,7 @@ func (data *ClusterOptionDataSource) ReadFromResponse( return diags } - data.Regions, diags = utils.ObjectList(ctx, &clusterOption.Regions, schemas.RegionAttributeTypes(), RegionTypesObject) + data.Regions, diags = utils.ObjectSet(ctx, &clusterOption.Regions, schemas.RegionAttributeTypes(), RegionTypesObject) if diags.HasError() { return diags } @@ -94,7 +94,7 @@ func (data *ClusterOptionDataSource) ReadFromResponse( return diags } - data.NodeInstances, diags = utils.ObjectList(ctx, &clusterOption.NodeInstances, schemas.ProviderInstanceAttributeTypes(), ProviderInstanceObject) + data.NodeInstances, diags = utils.ObjectSet(ctx, &clusterOption.NodeInstances, schemas.ProviderInstanceAttributeTypes(), ProviderInstanceObject) if diags.HasError() { return diags } @@ -104,7 +104,7 @@ func (data *ClusterOptionDataSource) ReadFromResponse( return diags } - data.DatabaseInstances, diags = utils.ObjectList(ctx, &clusterOption.DatabaseInstances, schemas.ProviderInstanceAttributeTypes(), ProviderInstanceObject) + data.DatabaseInstances, diags = utils.ObjectSet(ctx, &clusterOption.DatabaseInstances, schemas.ProviderInstanceAttributeTypes(), ProviderInstanceObject) if diags.HasError() { return diags } @@ -115,7 +115,7 @@ func (data *ClusterOptionDataSource) ReadFromResponse( type Region struct { Name types.String `tfsdk:"name"` Limited types.Bool `tfsdk:"limited"` - BannedInstances types.List `tfsdk:"banned_instances"` + BannedInstances types.Set `tfsdk:"banned_instances"` } func RegionTypesObject( @@ -125,7 +125,7 @@ func RegionTypesObject( region := Region{ Name: types.StringValue(regionInput.Name), } - region.BannedInstances, diags = utils.StringList(regionInput.BannedInstances) + region.BannedInstances, diags = utils.StringSet(regionInput.BannedInstances) if diags.HasError() { return regionOutput, diags } diff --git a/internal/provider/models/clusters.go b/internal/provider/models/clusters.go index a27d8682..d963d810 100644 --- a/internal/provider/models/clusters.go +++ b/internal/provider/models/clusters.go @@ -3,8 +3,8 @@ package models import ( "context" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" @@ -12,9 +12,9 @@ import ( // ClustersDataSource describes the data source data model. type ClustersDataSource struct { - Clusters types.List `tfsdk:"clusters"` + Clusters types.Set `tfsdk:"clusters"` CloudProvider types.String `tfsdk:"cloud_provider"` // query parameter - Names types.List `tfsdk:"names"` // query parameter + Names types.Set `tfsdk:"names"` // query parameter } func (data *ClustersDataSource) ReadFromResponse( @@ -36,7 +36,7 @@ func (data *ClustersDataSource) ReadFromResponse( values[i] = objectValue } var diags diag.Diagnostics - data.Clusters, diags = types.ListValue(types.ObjectType{AttrTypes: schemas.ClustersElementAttributeTypes()}, values) + data.Clusters, diags = types.SetValue(types.ObjectType{AttrTypes: schemas.ClustersElementAttributeTypes()}, values) if diags.HasError() { return diags } diff --git a/internal/provider/models/deployment.go b/internal/provider/models/deployment.go index 977896af..0e72d556 100644 --- a/internal/provider/models/deployment.go +++ b/internal/provider/models/deployment.go @@ -3,9 +3,9 @@ package models import ( "context" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" ) @@ -26,7 +26,7 @@ type Deployment struct { AstroRuntimeVersion types.String `tfsdk:"astro_runtime_version"` AirflowVersion types.String `tfsdk:"airflow_version"` Namespace types.String `tfsdk:"namespace"` - ContactEmails types.List `tfsdk:"contact_emails"` + ContactEmails types.Set `tfsdk:"contact_emails"` Executor types.String `tfsdk:"executor"` SchedulerCpu types.String `tfsdk:"scheduler_cpu"` SchedulerMemory types.String `tfsdk:"scheduler_memory"` @@ -35,7 +35,7 @@ type Deployment struct { ImageTag types.String `tfsdk:"image_tag"` ImageRepository types.String `tfsdk:"image_repository"` ImageVersion types.String `tfsdk:"image_version"` - EnvironmentVariables types.List `tfsdk:"environment_variables"` + EnvironmentVariables types.Set `tfsdk:"environment_variables"` WebserverIngressHostname types.String `tfsdk:"webserver_ingress_hostname"` WebserverUrl types.String `tfsdk:"webserver_url"` WebserverAirflowApiUrl types.String `tfsdk:"webserver_airflow_api_url"` @@ -46,9 +46,9 @@ type Deployment struct { IsCicdEnforced types.Bool `tfsdk:"is_cicd_enforced"` IsDagDeployEnabled types.Bool `tfsdk:"is_dag_deploy_enabled"` WorkloadIdentity types.String `tfsdk:"workload_identity"` - ExternalIps types.List `tfsdk:"external_ips"` + ExternalIps types.Set `tfsdk:"external_ips"` OidcIssuerUrl types.String `tfsdk:"oidc_issuer_url"` - WorkerQueues types.List `tfsdk:"worker_queues"` + WorkerQueues types.Set `tfsdk:"worker_queues"` // Hybrid and dedicated specific fields ClusterId types.String `tfsdk:"cluster_id"` @@ -71,6 +71,7 @@ type Deployment struct { func (data *Deployment) ReadFromResponse( ctx context.Context, deployment *platform.Deployment, + isResource bool, ) diag.Diagnostics { // Read common fields data.Id = types.StringValue(deployment.Id) @@ -99,7 +100,7 @@ func (data *Deployment) ReadFromResponse( data.AstroRuntimeVersion = types.StringValue(deployment.AstroRuntimeVersion) data.AirflowVersion = types.StringValue(deployment.AirflowVersion) data.Namespace = types.StringValue(deployment.Namespace) - data.ContactEmails, diags = utils.StringList(deployment.ContactEmails) + data.ContactEmails, diags = utils.StringSet(deployment.ContactEmails) if diags.HasError() { return diags } @@ -114,7 +115,7 @@ func (data *Deployment) ReadFromResponse( data.ImageTag = types.StringValue(deployment.ImageTag) data.ImageRepository = types.StringValue(deployment.ImageRepository) data.ImageVersion = types.StringPointerValue(deployment.ImageVersion) - data.EnvironmentVariables, diags = utils.ObjectList(ctx, deployment.EnvironmentVariables, schemas.DeploymentEnvironmentVariableAttributeTypes(), DeploymentEnvironmentVariableTypesObject) + data.EnvironmentVariables, diags = utils.ObjectSet(ctx, deployment.EnvironmentVariables, schemas.DeploymentEnvironmentVariableAttributeTypes(), DeploymentEnvironmentVariableTypesObject) if diags.HasError() { return diags } @@ -126,15 +127,22 @@ func (data *Deployment) ReadFromResponse( data.Type = types.StringPointerValue((*string)(deployment.Type)) data.DagTarballVersion = types.StringPointerValue(deployment.DagTarballVersion) data.DesiredDagTarballVersion = types.StringPointerValue(deployment.DesiredDagTarballVersion) - data.WorkerQueues, diags = utils.ObjectList(ctx, deployment.WorkerQueues, schemas.WorkerQueueAttributeTypes(), WorkerQueueTypesObject) - if diags.HasError() { - return diags + if isResource { + data.WorkerQueues, diags = utils.ObjectSet(ctx, deployment.WorkerQueues, schemas.WorkerQueueResourceAttributeTypes(), WorkerQueueResourceTypesObject) + if diags.HasError() { + return diags + } + } else { + data.WorkerQueues, diags = utils.ObjectSet(ctx, deployment.WorkerQueues, schemas.WorkerQueueDataSourceAttributeTypes(), WorkerQueueDataSourceTypesObject) + if diags.HasError() { + return diags + } } data.IsCicdEnforced = types.BoolValue(deployment.IsCicdEnforced) data.IsDagDeployEnabled = types.BoolValue(deployment.IsDagDeployEnabled) data.WorkloadIdentity = types.StringPointerValue(deployment.WorkloadIdentity) - data.ExternalIps, diags = utils.StringList(deployment.ExternalIPs) + data.ExternalIps, diags = utils.StringSet(deployment.ExternalIPs) if diags.HasError() { return diags } @@ -173,7 +181,7 @@ type DeploymentEnvironmentVariable struct { IsSecret types.Bool `tfsdk:"is_secret"` } -type WorkerQueue struct { +type WorkerQueueDataSource struct { Id types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` AstroMachine types.String `tfsdk:"astro_machine"` @@ -186,6 +194,18 @@ type WorkerQueue struct { WorkerConcurrency types.Int64 `tfsdk:"worker_concurrency"` } +type WorkerQueueResource struct { + Name types.String `tfsdk:"name"` + AstroMachine types.String `tfsdk:"astro_machine"` + IsDefault types.Bool `tfsdk:"is_default"` + MaxWorkerCount types.Int64 `tfsdk:"max_worker_count"` + MinWorkerCount types.Int64 `tfsdk:"min_worker_count"` + NodePoolId types.String `tfsdk:"node_pool_id"` + PodCpu types.String `tfsdk:"pod_cpu"` + PodMemory types.String `tfsdk:"pod_memory"` + WorkerConcurrency types.Int64 `tfsdk:"worker_concurrency"` +} + func DeploymentEnvironmentVariableTypesObject( ctx context.Context, envVar platform.DeploymentEnvironmentVariable, @@ -200,11 +220,30 @@ func DeploymentEnvironmentVariableTypesObject( return types.ObjectValueFrom(ctx, schemas.DeploymentEnvironmentVariableAttributeTypes(), obj) } -func WorkerQueueTypesObject( +func WorkerQueueResourceTypesObject( + ctx context.Context, + workerQueue platform.WorkerQueue, +) (types.Object, diag.Diagnostics) { + obj := WorkerQueueResource{ + Name: types.StringValue(workerQueue.Name), + AstroMachine: types.StringPointerValue(workerQueue.AstroMachine), + IsDefault: types.BoolValue(workerQueue.IsDefault), + MaxWorkerCount: types.Int64Value(int64(workerQueue.MaxWorkerCount)), + MinWorkerCount: types.Int64Value(int64(workerQueue.MinWorkerCount)), + NodePoolId: types.StringPointerValue(workerQueue.NodePoolId), + PodCpu: types.StringValue(workerQueue.PodCpu), + PodMemory: types.StringValue(workerQueue.PodMemory), + WorkerConcurrency: types.Int64Value(int64(workerQueue.WorkerConcurrency)), + } + + return types.ObjectValueFrom(ctx, schemas.WorkerQueueResourceAttributeTypes(), obj) +} + +func WorkerQueueDataSourceTypesObject( ctx context.Context, workerQueue platform.WorkerQueue, ) (types.Object, diag.Diagnostics) { - obj := WorkerQueue{ + obj := WorkerQueueDataSource{ Id: types.StringValue(workerQueue.Id), Name: types.StringValue(workerQueue.Name), AstroMachine: types.StringPointerValue(workerQueue.AstroMachine), @@ -217,7 +256,7 @@ func WorkerQueueTypesObject( WorkerConcurrency: types.Int64Value(int64(workerQueue.WorkerConcurrency)), } - return types.ObjectValueFrom(ctx, schemas.WorkerQueueAttributeTypes(), obj) + return types.ObjectValueFrom(ctx, schemas.WorkerQueueDataSourceAttributeTypes(), obj) } type DeploymentScalingSpec struct { diff --git a/internal/provider/models/deployment_options.go b/internal/provider/models/deployment_options.go index a9633b29..2ee7964a 100644 --- a/internal/provider/models/deployment_options.go +++ b/internal/provider/models/deployment_options.go @@ -4,22 +4,22 @@ import ( "context" "strconv" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/utils" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" ) type DeploymentOptions struct { - Executors types.List `tfsdk:"executors"` + Executors types.Set `tfsdk:"executors"` ResourceQuotas types.Object `tfsdk:"resource_quotas"` - RuntimeReleases types.List `tfsdk:"runtime_releases"` - SchedulerMachines types.List `tfsdk:"scheduler_machines"` - WorkerMachines types.List `tfsdk:"worker_machines"` + RuntimeReleases types.Set `tfsdk:"runtime_releases"` + SchedulerMachines types.Set `tfsdk:"scheduler_machines"` + WorkerMachines types.Set `tfsdk:"worker_machines"` WorkerQueues types.Object `tfsdk:"worker_queues"` - WorkloadIdentityOptions types.List `tfsdk:"workload_identity_options"` + WorkloadIdentityOptions types.Set `tfsdk:"workload_identity_options"` // Query params DeploymentId types.String `tfsdk:"deployment_id"` @@ -87,7 +87,7 @@ func (data *DeploymentOptions) ReadFromResponse( options *platform.DeploymentOptions, ) diag.Diagnostics { var diags diag.Diagnostics - data.Executors, diags = utils.StringList(&options.Executors) + data.Executors, diags = utils.StringSet(&options.Executors) if diags.HasError() { return diags } @@ -95,15 +95,15 @@ func (data *DeploymentOptions) ReadFromResponse( if diags.HasError() { return diags } - data.RuntimeReleases, diags = utils.ObjectList(ctx, &options.RuntimeReleases, schemas.RuntimeReleaseAttributeTypes(), RuntimeReleaseTypesObject) + data.RuntimeReleases, diags = utils.ObjectSet(ctx, &options.RuntimeReleases, schemas.RuntimeReleaseAttributeTypes(), RuntimeReleaseTypesObject) if diags.HasError() { return diags } - data.SchedulerMachines, diags = utils.ObjectList(ctx, &options.SchedulerMachines, schemas.SchedulerMachineAttributeTypes(), SchedulerMachineTypesObject) + data.SchedulerMachines, diags = utils.ObjectSet(ctx, &options.SchedulerMachines, schemas.SchedulerMachineAttributeTypes(), SchedulerMachineTypesObject) if diags.HasError() { return diags } - data.WorkerMachines, diags = utils.ObjectList(ctx, &options.WorkerMachines, schemas.WorkerMachineAttributeTypes(), WorkerMachineTypesObject) + data.WorkerMachines, diags = utils.ObjectSet(ctx, &options.WorkerMachines, schemas.WorkerMachineAttributeTypes(), WorkerMachineTypesObject) if diags.HasError() { return diags } @@ -111,7 +111,7 @@ func (data *DeploymentOptions) ReadFromResponse( if diags.HasError() { return diags } - data.WorkloadIdentityOptions, diags = utils.ObjectList(ctx, options.WorkloadIdentityOptions, schemas.WorkloadIdentityOptionsAttributeTypes(), WorkloadIdentityOptionTypesObject) + data.WorkloadIdentityOptions, diags = utils.ObjectSet(ctx, options.WorkloadIdentityOptions, schemas.WorkloadIdentityOptionsAttributeTypes(), WorkloadIdentityOptionTypesObject) if diags.HasError() { return diags } diff --git a/internal/provider/models/deployments.go b/internal/provider/models/deployments.go index 0ad090f9..dfe16f64 100644 --- a/internal/provider/models/deployments.go +++ b/internal/provider/models/deployments.go @@ -3,8 +3,8 @@ package models import ( "context" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" @@ -12,10 +12,10 @@ import ( // Deployments describes the data source data model. type Deployments struct { - Deployments types.List `tfsdk:"deployments"` - WorkspaceIds types.List `tfsdk:"workspace_ids"` // query parameter - DeploymentIds types.List `tfsdk:"deployment_ids"` // query parameter - Names types.List `tfsdk:"names"` // query parameter + Deployments types.Set `tfsdk:"deployments"` + WorkspaceIds types.Set `tfsdk:"workspace_ids"` // query parameter + DeploymentIds types.Set `tfsdk:"deployment_ids"` // query parameter + Names types.Set `tfsdk:"names"` // query parameter } func (data *Deployments) ReadFromResponse( @@ -25,7 +25,7 @@ func (data *Deployments) ReadFromResponse( values := make([]attr.Value, len(deployments)) for i, deployment := range deployments { var singleDeploymentData Deployment - diags := singleDeploymentData.ReadFromResponse(ctx, &deployment) + diags := singleDeploymentData.ReadFromResponse(ctx, &deployment, false) if diags.HasError() { return diags } @@ -37,7 +37,7 @@ func (data *Deployments) ReadFromResponse( values[i] = objectValue } var diags diag.Diagnostics - data.Deployments, diags = types.ListValue(types.ObjectType{AttrTypes: schemas.DeploymentsElementAttributeTypes()}, values) + data.Deployments, diags = types.SetValue(types.ObjectType{AttrTypes: schemas.DeploymentsElementAttributeTypes()}, values) if diags.HasError() { return diags } diff --git a/internal/provider/models/organization.go b/internal/provider/models/organization.go index c24fe634..a7e221f6 100644 --- a/internal/provider/models/organization.go +++ b/internal/provider/models/organization.go @@ -3,7 +3,7 @@ package models import ( "context" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" ) diff --git a/internal/provider/models/provider.go b/internal/provider/models/provider.go index 9e502732..1edfc28b 100644 --- a/internal/provider/models/provider.go +++ b/internal/provider/models/provider.go @@ -2,8 +2,8 @@ package models import "github.com/hashicorp/terraform-plugin-framework/types" -// AstronomerProviderModel describes the provider data model. -type AstronomerProviderModel struct { +// AstroProviderModel describes the provider data model. +type AstroProviderModel struct { Token types.String `tfsdk:"token"` OrganizationId types.String `tfsdk:"organization_id"` Host types.String `tfsdk:"host"` diff --git a/internal/provider/models/subject_profile.go b/internal/provider/models/subject_profile.go index 823a7ab0..fba6df6c 100644 --- a/internal/provider/models/subject_profile.go +++ b/internal/provider/models/subject_profile.go @@ -3,11 +3,11 @@ package models import ( "context" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/iam" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/clients/iam" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" ) diff --git a/internal/provider/models/workspace.go b/internal/provider/models/workspace.go index a25047a8..24c519b5 100644 --- a/internal/provider/models/workspace.go +++ b/internal/provider/models/workspace.go @@ -3,7 +3,7 @@ package models import ( "context" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" ) diff --git a/internal/provider/models/workspaces.go b/internal/provider/models/workspaces.go index e0e2bb9b..b95bb025 100644 --- a/internal/provider/models/workspaces.go +++ b/internal/provider/models/workspaces.go @@ -3,8 +3,8 @@ package models import ( "context" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" @@ -12,9 +12,9 @@ import ( // Workspaces describes the data source data model. type Workspaces struct { - Workspaces types.List `tfsdk:"workspaces"` - WorkspaceIds types.List `tfsdk:"workspace_ids"` // query parameter - Names types.List `tfsdk:"names"` // query parameter + Workspaces types.Set `tfsdk:"workspaces"` + WorkspaceIds types.Set `tfsdk:"workspace_ids"` // query parameter + Names types.Set `tfsdk:"names"` // query parameter } func (data *Workspaces) ReadFromResponse( @@ -36,7 +36,7 @@ func (data *Workspaces) ReadFromResponse( values[i] = objectValue } var diags diag.Diagnostics - data.Workspaces, diags = types.ListValue(types.ObjectType{AttrTypes: schemas.WorkspacesElementAttributeTypes()}, values) + data.Workspaces, diags = types.SetValue(types.ObjectType{AttrTypes: schemas.WorkspacesElementAttributeTypes()}, values) if diags.HasError() { return diags } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index a6b4df88..794a4074 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -4,12 +4,12 @@ import ( "context" "os" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/iam" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/datasources" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/resources" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/clients/iam" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/datasources" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/resources" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/function" "github.com/hashicorp/terraform-plugin-framework/path" @@ -20,28 +20,28 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" ) -// Ensure AstronomerProvider satisfies various provider interfaces. -var _ provider.Provider = &AstronomerProvider{} -var _ provider.ProviderWithFunctions = &AstronomerProvider{} +// Ensure AstroProvider satisfies various provider interfaces. +var _ provider.Provider = &AstroProvider{} +var _ provider.ProviderWithFunctions = &AstroProvider{} -// AstronomerProvider defines the provider implementation. -type AstronomerProvider struct { +// AstroProvider defines the provider implementation. +type AstroProvider struct { // version is set to the provider version on release, "dev" when the // provider is built and ran locally, and "test" when running acceptance // testing. version string } -func (p *AstronomerProvider) Metadata( +func (p *AstroProvider) Metadata( ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse, ) { - resp.TypeName = "astronomer" + resp.TypeName = "astro" resp.Version = p.version } -func (p *AstronomerProvider) Schema( +func (p *AstroProvider) Schema( ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse, @@ -55,14 +55,14 @@ func providerSchema() schema.Schema { } } -func (p *AstronomerProvider) Configure( +func (p *AstroProvider) Configure( ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse, ) { - tflog.Info(ctx, "Configuring Astronomer Terraform Provider client") + tflog.Info(ctx, "Configuring Terraform Provider Astro client") - var data models.AstronomerProviderModel + var data models.AstroProviderModel resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) if resp.Diagnostics.HasError() { @@ -118,7 +118,7 @@ func (p *AstronomerProvider) Configure( resp.ResourceData = apiClientsModel } -func (p *AstronomerProvider) Resources(ctx context.Context) []func() resource.Resource { +func (p *AstroProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{ resources.NewWorkspaceResource, resources.NewDeploymentResource, @@ -126,7 +126,7 @@ func (p *AstronomerProvider) Resources(ctx context.Context) []func() resource.Re } } -func (p *AstronomerProvider) DataSources(ctx context.Context) []func() datasource.DataSource { +func (p *AstroProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ datasources.NewWorkspaceDataSource, datasources.NewWorkspacesDataSource, @@ -140,13 +140,13 @@ func (p *AstronomerProvider) DataSources(ctx context.Context) []func() datasourc } } -func (p *AstronomerProvider) Functions(ctx context.Context) []func() function.Function { +func (p *AstroProvider) Functions(ctx context.Context) []func() function.Function { return []func() function.Function{} } func New(version string) func() provider.Provider { return func() provider.Provider { - return &AstronomerProvider{ + return &AstroProvider{ version: version, } } diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index 2b10630e..4fc53c3c 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-go/tftypes" @@ -65,7 +65,7 @@ func TestAcc_Provider_config(t *testing.T) { { Config: explicitHostConfig(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.astronomer_organization.test", "id"), + resource.TestCheckResourceAttrSet("data.astro_organization.test", "id"), ), }, }, @@ -74,7 +74,7 @@ func TestAcc_Provider_config(t *testing.T) { func explicitHostConfig() string { return fmt.Sprintf(` -provider "astronomer" { +provider "astro" { organization_id = "%v" host = "%v" token = "%v" @@ -83,20 +83,20 @@ token = "%v" func missingOrganizationIdConfig() string { return ` -provider "astronomer" { +provider "astro" { }` + dataSourceConfig() } func organizationIdIsNotCuidConfig() string { return ` -provider "astronomer" { +provider "astro" { organization_id = "not-a-cuid" }` + dataSourceConfig() } func invalidHost() string { return fmt.Sprintf(` -provider "astronomer" { +provider "astro" { organization_id = "%v" host = "https://api.astronomer.com" }`, os.Getenv("HOSTED_ORGANIZATION_ID")) + dataSourceConfig() @@ -105,5 +105,5 @@ host = "https://api.astronomer.com" // dataSourceConfig is needed to actually run the "Configure" method in the provider func dataSourceConfig() string { return ` -data "astronomer_organization" "test" {}` +data "astro_organization" "test" {}` } diff --git a/internal/provider/provider_test_utils.go b/internal/provider/provider_test_utils.go index 547e2a25..800c9210 100644 --- a/internal/provider/provider_test_utils.go +++ b/internal/provider/provider_test_utils.go @@ -15,7 +15,7 @@ import ( // CLI command executed to create a provider server to which the CLI can // reattach. var TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "astronomer": providerserver.NewProtocol6WithError(New("test")()), + "astro": providerserver.NewProtocol6WithError(New("test")()), } func TestAccPreCheck(t *testing.T) { @@ -60,7 +60,7 @@ func ProviderConfig(t *testing.T, isHosted bool) string { } return fmt.Sprintf(` -provider "astronomer" { +provider "astro" { organization_id = "%v" host = "%v" token = "%v" diff --git a/internal/provider/resources/resource_cluster.go b/internal/provider/resources/resource_cluster.go index e9eed5f8..1f9f4e71 100644 --- a/internal/provider/resources/resource_cluster.go +++ b/internal/provider/resources/resource_cluster.go @@ -8,11 +8,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -106,7 +106,7 @@ func (r *ClusterResource) Create( } // workspaceIds - createAwsDedicatedClusterRequest.WorkspaceIds, diags = utils.TypesListToStringSlicePtr(ctx, data.WorkspaceIds) + createAwsDedicatedClusterRequest.WorkspaceIds, diags = utils.TypesSetToStringSlicePtr(ctx, data.WorkspaceIds) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -135,7 +135,7 @@ func (r *ClusterResource) Create( } // workspaceIds - createAzureDedicatedClusterRequest.WorkspaceIds, diags = utils.TypesListToStringSlicePtr(ctx, data.WorkspaceIds) + createAzureDedicatedClusterRequest.WorkspaceIds, diags = utils.TypesSetToStringSlicePtr(ctx, data.WorkspaceIds) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -166,7 +166,7 @@ func (r *ClusterResource) Create( } // workspaceIds - createGcpDedicatedClusterRequest.WorkspaceIds, diags = utils.TypesListToStringSlicePtr(ctx, data.WorkspaceIds) + createGcpDedicatedClusterRequest.WorkspaceIds, diags = utils.TypesSetToStringSlicePtr(ctx, data.WorkspaceIds) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -318,7 +318,7 @@ func (r *ClusterResource) Update( } // workspaceIds - updateDedicatedClusterRequest.WorkspaceIds, diags = utils.TypesListToStringSlicePtr(ctx, data.WorkspaceIds) + updateDedicatedClusterRequest.WorkspaceIds, diags = utils.TypesSetToStringSlicePtr(ctx, data.WorkspaceIds) if diags.HasError() { resp.Diagnostics.Append(diags...) return diff --git a/internal/provider/resources/resource_cluster_test.go b/internal/provider/resources/resource_cluster_test.go index 9fd67952..c22f250e 100644 --- a/internal/provider/resources/resource_cluster_test.go +++ b/internal/provider/resources/resource_cluster_test.go @@ -7,14 +7,14 @@ import ( "strings" "testing" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" "github.com/hashicorp/terraform-plugin-testing/config" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/plancheck" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" ) @@ -22,18 +22,24 @@ import ( // These acceptance tests are testing the creation of dedicated clusters in the Astronomer platform. // We are also testing 'DEDICATED' deployment resources in these tests since they will be created in the clusters we create. +const SKIP_CLUSTER_RESOURCE_TESTS = "SKIP_CLUSTER_RESOURCE_TESTS" +const SKIP_CLUSTER_RESOURCE_TESTS_REASON = "Skipping dedicated cluster (and dedicated deployment) resource tests. To run these tests, unset the SKIP_CLUSTER_RESOURCE_TESTS environment variable." + func TestAcc_ResourceClusterAwsWithDedicatedDeployments(t *testing.T) { + if os.Getenv(SKIP_CLUSTER_RESOURCE_TESTS) == "True" { + t.Skip(SKIP_CLUSTER_RESOURCE_TESTS_REASON) + } namePrefix := utils.GenerateTestResourceName(10) workspaceName := fmt.Sprintf("%v_workspace", namePrefix) awsDeploymentName := fmt.Sprintf("%v_deployment_aws", namePrefix) - workspaceResourceVar := fmt.Sprintf("astronomer_workspace.%v", workspaceName) - awsDeploymentResourceVar := fmt.Sprintf("astronomer_deployment.%v", awsDeploymentName) + workspaceResourceVar := fmt.Sprintf("astro_workspace.%v", workspaceName) + awsDeploymentResourceVar := fmt.Sprintf("astro_deployment.%v", awsDeploymentName) // deployments in AWS cluster will switch executors during our tests awsClusterName := fmt.Sprintf("%v_aws", namePrefix) - awsResourceVar := fmt.Sprintf("astronomer_cluster.%v", awsClusterName) + awsResourceVar := fmt.Sprintf("astro_cluster.%v", awsClusterName) // aws cluster resource.ParallelTest(t, resource.TestCase{ @@ -199,16 +205,19 @@ func TestAcc_ResourceClusterAwsWithDedicatedDeployments(t *testing.T) { } func TestAcc_ResourceClusterAzureWithDedicatedDeployments(t *testing.T) { + if os.Getenv(SKIP_CLUSTER_RESOURCE_TESTS) == "True" { + t.Skip(SKIP_CLUSTER_RESOURCE_TESTS_REASON) + } namePrefix := utils.GenerateTestResourceName(10) workspaceName := fmt.Sprintf("%v_workspace", namePrefix) azureDeploymentName := fmt.Sprintf("%v_deployment_azure", namePrefix) - workspaceResourceVar := fmt.Sprintf("astronomer_workspace.%v", workspaceName) - azureDeploymentResourceVar := fmt.Sprintf("astronomer_deployment.%v", azureDeploymentName) + workspaceResourceVar := fmt.Sprintf("astro_workspace.%v", workspaceName) + azureDeploymentResourceVar := fmt.Sprintf("astro_deployment.%v", azureDeploymentName) azureClusterName := fmt.Sprintf("%v_azure", namePrefix) - azureResourceVar := fmt.Sprintf("astronomer_cluster.%v", azureClusterName) + azureResourceVar := fmt.Sprintf("astro_cluster.%v", azureClusterName) // azure cluster resource.ParallelTest(t, resource.TestCase{ @@ -269,16 +278,19 @@ func TestAcc_ResourceClusterAzureWithDedicatedDeployments(t *testing.T) { } func TestAcc_ResourceClusterGcpWithDedicatedDeployments(t *testing.T) { + if os.Getenv(SKIP_CLUSTER_RESOURCE_TESTS) == "True" { + t.Skip(SKIP_CLUSTER_RESOURCE_TESTS_REASON) + } namePrefix := utils.GenerateTestResourceName(10) workspaceName := fmt.Sprintf("%v_workspace", namePrefix) gcpDeploymentName := fmt.Sprintf("%v_deployment_gcp", namePrefix) - workspaceResourceVar := fmt.Sprintf("astronomer_workspace.%v", workspaceName) - gcpDeploymentResourceVar := fmt.Sprintf("astronomer_deployment.%v", gcpDeploymentName) + workspaceResourceVar := fmt.Sprintf("astro_workspace.%v", workspaceName) + gcpDeploymentResourceVar := fmt.Sprintf("astro_deployment.%v", gcpDeploymentName) gcpClusterName := fmt.Sprintf("%v_gcp", namePrefix) - gcpResourceVar := fmt.Sprintf("astronomer_cluster.%v", gcpClusterName) + gcpResourceVar := fmt.Sprintf("astro_cluster.%v", gcpClusterName) // gcp cluster resource.ParallelTest(t, resource.TestCase{ @@ -342,8 +354,11 @@ func TestAcc_ResourceClusterGcpWithDedicatedDeployments(t *testing.T) { } func TestAcc_ResourceClusterRemovedOutsideOfTerraform(t *testing.T) { + if os.Getenv(SKIP_CLUSTER_RESOURCE_TESTS) == "True" { + t.Skip(SKIP_CLUSTER_RESOURCE_TESTS_REASON) + } clusterName := utils.GenerateTestResourceName(10) - clusterResource := fmt.Sprintf("astronomer_cluster.%v", clusterName) + clusterResource := fmt.Sprintf("astro_cluster.%v", clusterName) depInput := clusterInput{ Name: clusterName, Region: "us-east-1", @@ -397,7 +412,7 @@ type dedicatedDeploymentInput struct { } func dedicatedDeployment(input dedicatedDeploymentInput) string { - return fmt.Sprintf(`resource "astronomer_deployment" "%v" { + return fmt.Sprintf(`resource "astro_deployment" "%v" { name = "%s" description = "%s" type = "DEDICATED" @@ -439,7 +454,7 @@ func cluster(input clusterInput) string { service_peering_range = "172.23.0.0/20" service_subnet_range = "172.22.0.0/22"` } - return fmt.Sprintf(`resource "astronomer_cluster" "%v" { + return fmt.Sprintf(`resource "astro_cluster" "%v" { name = "%s" type = "DEDICATED" region = "%v" diff --git a/internal/provider/resources/resource_deployment.go b/internal/provider/resources/resource_deployment.go index be5e898e..22c22d14 100644 --- a/internal/provider/resources/resource_deployment.go +++ b/internal/provider/resources/resource_deployment.go @@ -11,11 +11,11 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/samber/lo" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -144,7 +144,7 @@ func (r *DeploymentResource) Create( } // contact emails - createStandardDeploymentRequest.ContactEmails, diags = utils.TypesListToStringSlicePtr(ctx, data.ContactEmails) + createStandardDeploymentRequest.ContactEmails, diags = utils.TypesSetToStringSlicePtr(ctx, data.ContactEmails) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -203,7 +203,7 @@ func (r *DeploymentResource) Create( } // contact emails - createDedicatedDeploymentRequest.ContactEmails, diags = utils.TypesListToStringSlicePtr(ctx, data.ContactEmails) + createDedicatedDeploymentRequest.ContactEmails, diags = utils.TypesSetToStringSlicePtr(ctx, data.ContactEmails) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -260,7 +260,7 @@ func (r *DeploymentResource) Create( } // contact emails - createHybridDeploymentRequest.ContactEmails, diags = utils.TypesListToStringSlicePtr(ctx, data.ContactEmails) + createHybridDeploymentRequest.ContactEmails, diags = utils.TypesSetToStringSlicePtr(ctx, data.ContactEmails) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -311,7 +311,7 @@ func (r *DeploymentResource) Create( return } - diags = data.ReadFromResponse(ctx, deployment.JSON200) + diags = data.ReadFromResponse(ctx, deployment.JSON200, true) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -363,7 +363,7 @@ func (r *DeploymentResource) Read( return } - diags := data.ReadFromResponse(ctx, deployment.JSON200) + diags := data.ReadFromResponse(ctx, deployment.JSON200, true) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -412,7 +412,7 @@ func (r *DeploymentResource) Update( } // contact emails - updateStandardDeploymentRequest.ContactEmails, diags = utils.TypesListToStringSlicePtr(ctx, data.ContactEmails) + updateStandardDeploymentRequest.ContactEmails, diags = utils.TypesSetToStringSlicePtr(ctx, data.ContactEmails) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -469,7 +469,7 @@ func (r *DeploymentResource) Update( } // contact emails - updateDedicatedDeploymentRequest.ContactEmails, diags = utils.TypesListToStringSlicePtr(ctx, data.ContactEmails) + updateDedicatedDeploymentRequest.ContactEmails, diags = utils.TypesSetToStringSlicePtr(ctx, data.ContactEmails) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -524,7 +524,7 @@ func (r *DeploymentResource) Update( } // contact emails - updateHybridDeploymentRequest.ContactEmails, diags = utils.TypesListToStringSlicePtr(ctx, data.ContactEmails) + updateHybridDeploymentRequest.ContactEmails, diags = utils.TypesSetToStringSlicePtr(ctx, data.ContactEmails) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -576,7 +576,7 @@ func (r *DeploymentResource) Update( return } - diags = data.ReadFromResponse(ctx, deployment.JSON200) + diags = data.ReadFromResponse(ctx, deployment.JSON200, true) if diags.HasError() { resp.Diagnostics.Append(diags...) return @@ -744,7 +744,7 @@ func validateHybridConfig(ctx context.Context, data *models.Deployment) diag.Dia // Need to check worker_queues for hybrid deployments have `node_pool_id` and do not have `astro_machine` if len(data.WorkerQueues.Elements()) > 0 { - var workerQueues []models.WorkerQueue + var workerQueues []models.WorkerQueueResource diags = append(diags, data.WorkerQueues.ElementsAs(ctx, &workerQueues, false)...) for _, workerQueue := range workerQueues { if !workerQueue.AstroMachine.IsNull() { @@ -882,7 +882,7 @@ func validateHostedConfig(ctx context.Context, data *models.Deployment) diag.Dia // Need to check worker_queues for hosted deployments have `astro_machine` and do not have `node_pool_id` if len(data.WorkerQueues.Elements()) > 0 { - var workerQueues []models.WorkerQueue + var workerQueues []models.WorkerQueueResource diags = append(diags, data.WorkerQueues.ElementsAs(ctx, &workerQueues, false)...) for _, workerQueue := range workerQueues { if workerQueue.AstroMachine.IsNull() { @@ -965,18 +965,18 @@ func RequestScalingSpec(ctx context.Context, scalingSpecObj types.Object) (*plat return platformScalingSpec, nil } -// RequestHostedWorkerQueues converts a Terraform list to a list of platform.WorkerQueueRequest to be used in create and update requests -func RequestHostedWorkerQueues(ctx context.Context, workerQueuesObjList types.List) (*[]platform.WorkerQueueRequest, diag.Diagnostics) { - if len(workerQueuesObjList.Elements()) == 0 { +// RequestHostedWorkerQueues converts a Terraform set to a list of platform.WorkerQueueRequest to be used in create and update requests +func RequestHostedWorkerQueues(ctx context.Context, workerQueuesObjSet types.Set) (*[]platform.WorkerQueueRequest, diag.Diagnostics) { + if len(workerQueuesObjSet.Elements()) == 0 { return nil, nil } - var workerQueues []models.WorkerQueue - diags := workerQueuesObjList.ElementsAs(ctx, &workerQueues, false) + var workerQueues []models.WorkerQueueResource + diags := workerQueuesObjSet.ElementsAs(ctx, &workerQueues, false) if diags.HasError() { return nil, diags } - platformWorkerQueues := lo.Map(workerQueues, func(workerQueue models.WorkerQueue, _ int) platform.WorkerQueueRequest { + platformWorkerQueues := lo.Map(workerQueues, func(workerQueue models.WorkerQueueResource, _ int) platform.WorkerQueueRequest { return platform.WorkerQueueRequest{ AstroMachine: platform.WorkerQueueRequestAstroMachine(workerQueue.AstroMachine.ValueString()), IsDefault: workerQueue.IsDefault.ValueBool(), @@ -989,20 +989,19 @@ func RequestHostedWorkerQueues(ctx context.Context, workerQueuesObjList types.Li return &platformWorkerQueues, nil } -// RequestHybridWorkerQueues converts a Terraform list to a list of platform.WorkerQueueRequest to be used in create and update requests -func RequestHybridWorkerQueues(ctx context.Context, workerQueuesObjList types.List) (*[]platform.HybridWorkerQueueRequest, diag.Diagnostics) { - if len(workerQueuesObjList.Elements()) == 0 { +// RequestHybridWorkerQueues converts a Terraform set to a list of platform.WorkerQueueRequest to be used in create and update requests +func RequestHybridWorkerQueues(ctx context.Context, workerQueuesObjSet types.Set) (*[]platform.HybridWorkerQueueRequest, diag.Diagnostics) { + if len(workerQueuesObjSet.Elements()) == 0 { return nil, nil } - var workerQueues []models.WorkerQueue - diags := workerQueuesObjList.ElementsAs(ctx, &workerQueues, false) + var workerQueues []models.WorkerQueueResource + diags := workerQueuesObjSet.ElementsAs(ctx, &workerQueues, false) if diags.HasError() { return nil, diags } - platformWorkerQueues := lo.Map(workerQueues, func(workerQueue models.WorkerQueue, _ int) platform.HybridWorkerQueueRequest { + platformWorkerQueues := lo.Map(workerQueues, func(workerQueue models.WorkerQueueResource, _ int) platform.HybridWorkerQueueRequest { return platform.HybridWorkerQueueRequest{ - Id: nil, IsDefault: workerQueue.IsDefault.ValueBool(), MaxWorkerCount: int(workerQueue.MaxWorkerCount.ValueInt64()), MinWorkerCount: int(workerQueue.MinWorkerCount.ValueInt64()), @@ -1014,14 +1013,14 @@ func RequestHybridWorkerQueues(ctx context.Context, workerQueuesObjList types.Li return &platformWorkerQueues, nil } -// RequestDeploymentEnvironmentVariables converts a Terraform list to a list of platform.DeploymentEnvironmentVariableRequest to be used in create and update requests -func RequestDeploymentEnvironmentVariables(ctx context.Context, environmentVariablesObjList types.List) ([]platform.DeploymentEnvironmentVariableRequest, diag.Diagnostics) { - if len(environmentVariablesObjList.Elements()) == 0 { +// RequestDeploymentEnvironmentVariables converts a Terraform set to a list of platform.DeploymentEnvironmentVariableRequest to be used in create and update requests +func RequestDeploymentEnvironmentVariables(ctx context.Context, environmentVariablesObjSet types.Set) ([]platform.DeploymentEnvironmentVariableRequest, diag.Diagnostics) { + if len(environmentVariablesObjSet.Elements()) == 0 { return []platform.DeploymentEnvironmentVariableRequest{}, nil } var envVars []models.DeploymentEnvironmentVariable - diags := environmentVariablesObjList.ElementsAs(ctx, &envVars, false) + diags := environmentVariablesObjSet.ElementsAs(ctx, &envVars, false) if diags.HasError() { return nil, diags } diff --git a/internal/provider/resources/resource_deployment_test.go b/internal/provider/resources/resource_deployment_test.go index b224b5cc..f6eb1cd3 100644 --- a/internal/provider/resources/resource_deployment_test.go +++ b/internal/provider/resources/resource_deployment_test.go @@ -7,14 +7,14 @@ import ( "strings" "testing" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" "github.com/hashicorp/terraform-plugin-testing/config" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/plancheck" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" ) @@ -27,7 +27,7 @@ func TestAcc_ResourceDeploymentHybrid(t *testing.T) { clusterId := os.Getenv("HYBRID_CLUSTER_ID") nodePoolId := os.Getenv("HYBRID_NODE_POOL_ID") deploymentName := fmt.Sprintf("%v_hybrid", namePrefix) - resourceVar := fmt.Sprintf("astronomer_deployment.%v", deploymentName) + resourceVar := fmt.Sprintf("astro_deployment.%v", deploymentName) resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: astronomerprovider.TestAccProtoV6ProviderFactories, @@ -119,9 +119,9 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) { azureCeleryDeploymentName := fmt.Sprintf("%v_azure_celery", namePrefix) gcpKubernetesDeploymentName := fmt.Sprintf("%v_gcp_kubernetes", namePrefix) - awsResourceVar := fmt.Sprintf("astronomer_deployment.%v", awsDeploymentName) - azureCeleryResourceVar := fmt.Sprintf("astronomer_deployment.%v", azureCeleryDeploymentName) - gcpKubernetesResourceVar := fmt.Sprintf("astronomer_deployment.%v", gcpKubernetesDeploymentName) + awsResourceVar := fmt.Sprintf("astro_deployment.%v", awsDeploymentName) + azureCeleryResourceVar := fmt.Sprintf("astro_deployment.%v", azureCeleryDeploymentName) + gcpKubernetesResourceVar := fmt.Sprintf("astro_deployment.%v", gcpKubernetesDeploymentName) // standard aws deployment resource.Test(t, resource.TestCase{ @@ -329,7 +329,7 @@ func TestAcc_ResourceDeploymentStandard(t *testing.T) { func TestAcc_ResourceDeploymentStandardRemovedOutsideOfTerraform(t *testing.T) { standardDeploymentName := utils.GenerateTestResourceName(10) - standardDeploymentResource := fmt.Sprintf("astronomer_deployment.%v", standardDeploymentName) + standardDeploymentResource := fmt.Sprintf("astro_deployment.%v", standardDeploymentName) depInput := standardDeploymentInput{ Name: standardDeploymentName, Description: utils.TestResourceDescription, @@ -425,13 +425,13 @@ func hybridDeployment(input hybridDeploymentInput) string { taskPodNodePoolIdStr = fmt.Sprintf(`task_pod_node_pool_id = "%v"`, input.NodePoolId) } return fmt.Sprintf(` -resource "astronomer_workspace" "%v_workspace" { +resource "astro_workspace" "%v_workspace" { name = "%s" description = "%s" cicd_enforced_default = true } -resource "astronomer_deployment" "%v" { +resource "astro_deployment" "%v" { name = "%s" description = "%s" type = "HYBRID" @@ -442,7 +442,7 @@ resource "astronomer_deployment" "%v" { is_dag_deploy_enabled = true scheduler_au = %v scheduler_replicas = 1 - workspace_id = astronomer_workspace.%v_workspace.id + workspace_id = astro_workspace.%v_workspace.id %v %v %v @@ -469,13 +469,13 @@ func standardDeployment(input standardDeploymentInput) string { wqStr = workerQueuesStr("") } return fmt.Sprintf(` -resource "astronomer_workspace" "%v_workspace" { +resource "astro_workspace" "%v_workspace" { name = "%s" description = "%s" cicd_enforced_default = true } -resource "astronomer_deployment" "%v" { +resource "astro_deployment" "%v" { name = "%s" description = "%s" type = "STANDARD" @@ -492,7 +492,7 @@ resource "astronomer_deployment" "%v" { resource_quota_cpu = "10" resource_quota_memory = "20Gi" scheduler_size = "%v" - workspace_id = astronomer_workspace.%v_workspace.id + workspace_id = astro_workspace.%v_workspace.id %v %v } diff --git a/internal/provider/resources/resource_workspace.go b/internal/provider/resources/resource_workspace.go index 740604c0..e370e2f6 100644 --- a/internal/provider/resources/resource_workspace.go +++ b/internal/provider/resources/resource_workspace.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" diff --git a/internal/provider/resources/resource_workspace_test.go b/internal/provider/resources/resource_workspace_test.go index 52e9a25f..4f1fbbe3 100644 --- a/internal/provider/resources/resource_workspace_test.go +++ b/internal/provider/resources/resource_workspace_test.go @@ -6,11 +6,11 @@ import ( "os" "testing" - "github.com/astronomer/astronomer-terraform-provider/internal/clients" + "github.com/astronomer/terraform-provider-astro/internal/clients" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - astronomerprovider "github.com/astronomer/astronomer-terraform-provider/internal/provider" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + astronomerprovider "github.com/astronomer/terraform-provider-astro/internal/provider" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-testing/config" "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -36,9 +36,9 @@ func TestAcc_ResourceWorkspace(t *testing.T) { { Config: astronomerprovider.ProviderConfig(t, true) + workspace("test", workspace1Name, "bad description", false), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("astronomer_workspace.test", "name", workspace1Name), - resource.TestCheckResourceAttr("astronomer_workspace.test", "description", "bad description"), - resource.TestCheckResourceAttr("astronomer_workspace.test", "cicd_enforced_default", "false"), + resource.TestCheckResourceAttr("astro_workspace.test", "name", workspace1Name), + resource.TestCheckResourceAttr("astro_workspace.test", "description", "bad description"), + resource.TestCheckResourceAttr("astro_workspace.test", "cicd_enforced_default", "false"), // Check via API that workspace exists testAccCheckWorkspaceExistence(t, workspace1Name, true), ), @@ -47,16 +47,16 @@ func TestAcc_ResourceWorkspace(t *testing.T) { { Config: astronomerprovider.ProviderConfig(t, true) + workspace("test", workspace2Name, utils.TestResourceDescription, true), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("astronomer_workspace.test", "name", workspace2Name), - resource.TestCheckResourceAttr("astronomer_workspace.test", "description", utils.TestResourceDescription), - resource.TestCheckResourceAttr("astronomer_workspace.test", "cicd_enforced_default", "true"), + resource.TestCheckResourceAttr("astro_workspace.test", "name", workspace2Name), + resource.TestCheckResourceAttr("astro_workspace.test", "description", utils.TestResourceDescription), + resource.TestCheckResourceAttr("astro_workspace.test", "cicd_enforced_default", "true"), // Check via API that workspace exists testAccCheckWorkspaceExistence(t, workspace2Name, true), ), }, // Import existing workspace and check it is correctly imported - https://stackoverflow.com/questions/68824711/how-can-i-test-terraform-import-in-acceptance-tests { - ResourceName: "astronomer_workspace.test", + ResourceName: "astro_workspace.test", ImportState: true, ImportStateVerify: true, }, @@ -80,8 +80,8 @@ func TestAcc_WorkspaceRemovedOutsideOfTerraform(t *testing.T) { PreApply: []plancheck.PlanCheck{plancheck.ExpectNonEmptyPlan()}, }, Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("astronomer_workspace.test", "name", workspaceName), - resource.TestCheckResourceAttr("astronomer_workspace.test", "description", utils.TestResourceDescription), + resource.TestCheckResourceAttr("astro_workspace.test", "name", workspaceName), + resource.TestCheckResourceAttr("astro_workspace.test", "description", utils.TestResourceDescription), // Check via API that workspace exists testAccCheckWorkspaceExistence(t, workspaceName, true), ), @@ -96,8 +96,8 @@ func TestAcc_WorkspaceRemovedOutsideOfTerraform(t *testing.T) { PreApply: []plancheck.PlanCheck{plancheck.ExpectNonEmptyPlan()}, }, Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("astronomer_workspace.test", "name", workspaceName), - resource.TestCheckResourceAttr("astronomer_workspace.test", "description", utils.TestResourceDescription), + resource.TestCheckResourceAttr("astro_workspace.test", "name", workspaceName), + resource.TestCheckResourceAttr("astro_workspace.test", "description", utils.TestResourceDescription), // Check via API that workspace exists testAccCheckWorkspaceExistence(t, workspaceName, true), ), @@ -112,7 +112,7 @@ variable "name" { type = string } -resource "astronomer_workspace" "test" { +resource "astro_workspace" "test" { name = var.name description = "%s" cicd_enforced_default = true @@ -121,7 +121,7 @@ resource "astronomer_workspace" "test" { func workspace(tfVarName, name, description string, cicdEnforcedDefault bool) string { return fmt.Sprintf(` -resource "astronomer_workspace" "%s" { +resource "astro_workspace" "%s" { name = "%s" description = "%s" cicd_enforced_default = %t diff --git a/internal/provider/schemas/cluster.go b/internal/provider/schemas/cluster.go index 5f8e21b7..c8e1d008 100644 --- a/internal/provider/schemas/cluster.go +++ b/internal/provider/schemas/cluster.go @@ -3,17 +3,17 @@ package schemas import ( "context" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/validators" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/validators" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" - "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -134,23 +134,22 @@ func ClusterResourceSchemaAttributes(ctx context.Context) map[string]resourceSch stringplanmodifier.UseStateForUnknown(), }, }, - "node_pools": resourceSchema.ListNestedAttribute{ + "node_pools": resourceSchema.SetNestedAttribute{ NestedObject: resourceSchema.NestedAttributeObject{ Attributes: NodePoolResourceSchemaAttributes(), }, MarkdownDescription: "Cluster node pools", Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.UseStateForUnknown(), + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), }, }, - "workspace_ids": resourceSchema.ListAttribute{ + "workspace_ids": resourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Cluster workspace IDs", Required: true, - Validators: []validator.List{ - listvalidator.ValueStringsAre(validators.IsCuid()), - listvalidator.UniqueValues(), + Validators: []validator.Set{ + setvalidator.ValueStringsAre(validators.IsCuid()), }, }, "is_limited": resourceSchema.BoolAttribute{ @@ -233,7 +232,7 @@ func ClusterDataSourceSchemaAttributes() map[string]datasourceSchema.Attribute { MarkdownDescription: "Cluster provider account", Computed: true, }, - "node_pools": datasourceSchema.ListNestedAttribute{ + "node_pools": datasourceSchema.SetNestedAttribute{ NestedObject: datasourceSchema.NestedAttributeObject{ Attributes: NodePoolDataSourceSchemaAttributes(), }, @@ -241,12 +240,12 @@ func ClusterDataSourceSchemaAttributes() map[string]datasourceSchema.Attribute { MarkdownDescription: "Cluster node pools", Computed: true, }, - "workspace_ids": datasourceSchema.ListAttribute{ + "workspace_ids": datasourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Cluster workspace IDs", Computed: true, }, - "tags": datasourceSchema.ListNestedAttribute{ + "tags": datasourceSchema.SetNestedAttribute{ NestedObject: datasourceSchema.NestedAttributeObject{ Attributes: ClusterTagDataSourceAttributes(), }, @@ -262,14 +261,14 @@ func ClusterDataSourceSchemaAttributes() map[string]datasourceSchema.Attribute { func ClusterMetadataAttributeTypes() map[string]attr.Type { return map[string]attr.Type{ - "external_ips": types.ListType{ElemType: types.StringType}, + "external_ips": types.SetType{ElemType: types.StringType}, "oidc_issuer_url": types.StringType, } } func ClusterMetadataDataSourceAttributes() map[string]datasourceSchema.Attribute { return map[string]datasourceSchema.Attribute{ - "external_ips": datasourceSchema.ListAttribute{ + "external_ips": datasourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Cluster external IPs", Computed: true, @@ -283,7 +282,7 @@ func ClusterMetadataDataSourceAttributes() map[string]datasourceSchema.Attribute func ClusterMetadataResourceAttributes() map[string]resourceSchema.Attribute { return map[string]resourceSchema.Attribute{ - "external_ips": resourceSchema.ListAttribute{ + "external_ips": resourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Cluster external IPs", Computed: true, @@ -315,19 +314,6 @@ func ClusterTagDataSourceAttributes() map[string]datasourceSchema.Attribute { } } -func ClusterTagResourceAttributes() map[string]resourceSchema.Attribute { - return map[string]resourceSchema.Attribute{ - "key": resourceSchema.StringAttribute{ - MarkdownDescription: "Cluster tag key", - Required: true, - }, - "value": resourceSchema.StringAttribute{ - MarkdownDescription: "Cluster tag value", - Required: true, - }, - } -} - func NodePoolAttributeTypes() map[string]attr.Type { return map[string]attr.Type{ "id": types.StringType, @@ -337,7 +323,7 @@ func NodePoolAttributeTypes() map[string]attr.Type { "max_node_count": types.Int64Type, "node_instance_type": types.StringType, "is_default": types.BoolType, - "supported_astro_machines": types.ListType{ + "supported_astro_machines": types.SetType{ ElemType: types.StringType, }, "created_at": types.StringType, @@ -375,7 +361,7 @@ func NodePoolResourceSchemaAttributes() map[string]resourceSchema.Attribute { MarkdownDescription: "Whether the node pool is the default node pool of the cluster", Computed: true, }, - "supported_astro_machines": resourceSchema.ListAttribute{ + "supported_astro_machines": resourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Node pool supported Astro machines", Computed: true, @@ -421,7 +407,7 @@ func NodePoolDataSourceSchemaAttributes() map[string]datasourceSchema.Attribute MarkdownDescription: "Whether the node pool is the default node pool of the cluster", Computed: true, }, - "supported_astro_machines": datasourceSchema.ListAttribute{ + "supported_astro_machines": datasourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Node pool supported Astro machines", Computed: true, diff --git a/internal/provider/schemas/cluster_options.go b/internal/provider/schemas/cluster_options.go index b633e71f..9909af0b 100644 --- a/internal/provider/schemas/cluster_options.go +++ b/internal/provider/schemas/cluster_options.go @@ -1,7 +1,7 @@ package schemas import ( - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -23,7 +23,7 @@ func ClusterOptionsElementAttributeTypes() map[string]attr.Type { "default_region": types.ObjectType{ AttrTypes: RegionAttributeTypes(), }, - "regions": types.ListType{ + "regions": types.SetType{ ElemType: types.ObjectType{ AttrTypes: RegionAttributeTypes(), }, @@ -31,7 +31,7 @@ func ClusterOptionsElementAttributeTypes() map[string]attr.Type { "default_node_instance": types.ObjectType{ AttrTypes: ProviderInstanceAttributeTypes(), }, - "node_instances": types.ListType{ + "node_instances": types.SetType{ ElemType: types.ObjectType{ AttrTypes: ProviderInstanceAttributeTypes(), }, @@ -39,7 +39,7 @@ func ClusterOptionsElementAttributeTypes() map[string]attr.Type { "default_database_instance": types.ObjectType{ AttrTypes: ProviderInstanceAttributeTypes(), }, - "database_instances": types.ListType{ + "database_instances": types.SetType{ ElemType: types.ObjectType{ AttrTypes: ProviderInstanceAttributeTypes(), }, @@ -51,7 +51,7 @@ func RegionAttributeTypes() map[string]attr.Type { return map[string]attr.Type{ "name": types.StringType, "limited": types.BoolType, - "banned_instances": types.ListType{ + "banned_instances": types.SetType{ ElemType: types.StringType, }, } @@ -74,7 +74,7 @@ func TemplateVersionAttributeTypes() map[string]attr.Type { func ClusterOptionsDataSourceSchemaAttributes() map[string]schema.Attribute { return map[string]schema.Attribute{ - "cluster_options": schema.ListNestedAttribute{ + "cluster_options": schema.SetNestedAttribute{ NestedObject: schema.NestedAttributeObject{ Attributes: ClusterOptionDataSourceSchemaAttributes(), }, @@ -141,7 +141,7 @@ func ClusterOptionDataSourceSchemaAttributes() map[string]datasourceSchema.Attri Computed: true, Attributes: DatasourceRegionAttributes(), }, - "regions": datasourceSchema.ListNestedAttribute{ + "regions": datasourceSchema.SetNestedAttribute{ MarkdownDescription: "ClusterOption regions", Computed: true, NestedObject: schema.NestedAttributeObject{ @@ -153,7 +153,7 @@ func ClusterOptionDataSourceSchemaAttributes() map[string]datasourceSchema.Attri Computed: true, Attributes: DatasourceProviderInstanceAttributes(), }, - "node_instances": datasourceSchema.ListNestedAttribute{ + "node_instances": datasourceSchema.SetNestedAttribute{ MarkdownDescription: "ClusterOption node instances", Computed: true, NestedObject: schema.NestedAttributeObject{ @@ -165,7 +165,7 @@ func ClusterOptionDataSourceSchemaAttributes() map[string]datasourceSchema.Attri Computed: true, Attributes: DatasourceProviderInstanceAttributes(), }, - "database_instances": datasourceSchema.ListNestedAttribute{ + "database_instances": datasourceSchema.SetNestedAttribute{ MarkdownDescription: "ClusterOption database instances", Computed: true, NestedObject: schema.NestedAttributeObject{ @@ -185,7 +185,7 @@ func DatasourceRegionAttributes() map[string]datasourceSchema.Attribute { Computed: true, MarkdownDescription: "Region is limited bool", }, - "banned_instances": datasourceSchema.ListAttribute{ + "banned_instances": datasourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Region banned instances", Computed: true, diff --git a/internal/provider/schemas/clusters.go b/internal/provider/schemas/clusters.go index 3e10e3cf..95b090f2 100644 --- a/internal/provider/schemas/clusters.go +++ b/internal/provider/schemas/clusters.go @@ -1,8 +1,8 @@ package schemas import ( - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -30,15 +30,15 @@ func ClustersElementAttributeTypes() map[string]attr.Type { "type": types.StringType, "tenant_id": types.StringType, "provider_account": types.StringType, - "node_pools": types.ListType{ + "node_pools": types.SetType{ ElemType: types.ObjectType{ AttrTypes: NodePoolAttributeTypes(), }, }, - "workspace_ids": types.ListType{ + "workspace_ids": types.SetType{ ElemType: types.StringType, }, - "tags": types.ListType{ + "tags": types.SetType{ ElemType: types.ObjectType{ AttrTypes: ClusterTagAttributeTypes(), }, @@ -49,7 +49,7 @@ func ClustersElementAttributeTypes() map[string]attr.Type { func ClustersDataSourceSchemaAttributes() map[string]schema.Attribute { return map[string]schema.Attribute{ - "clusters": schema.ListNestedAttribute{ + "clusters": schema.SetNestedAttribute{ NestedObject: schema.NestedAttributeObject{ Attributes: ClusterDataSourceSchemaAttributes(), }, @@ -65,11 +65,11 @@ func ClustersDataSourceSchemaAttributes() map[string]schema.Attribute { ), }, }, - "names": schema.ListAttribute{ + "names": schema.SetAttribute{ ElementType: types.StringType, Optional: true, - Validators: []validator.List{ - listvalidator.ValueStringsAre(stringvalidator.LengthAtLeast(1)), + Validators: []validator.Set{ + setvalidator.ValueStringsAre(stringvalidator.LengthAtLeast(1)), }, }, } diff --git a/internal/provider/schemas/deployment.go b/internal/provider/schemas/deployment.go index edf2334e..fc4da08d 100644 --- a/internal/provider/schemas/deployment.go +++ b/internal/provider/schemas/deployment.go @@ -4,16 +4,17 @@ import ( "context" "regexp" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/validators" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/validators" "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" - "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" @@ -85,13 +86,12 @@ func DeploymentResourceSchemaAttributes() map[string]resourceSchema.Attribute { stringplanmodifier.UseStateForUnknown(), }, }, - "contact_emails": resourceSchema.ListAttribute{ + "contact_emails": resourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Deployment contact emails", Required: true, - Validators: []validator.List{ - listvalidator.ValueStringsAre(stringvalidator.RegexMatches(regexp.MustCompile(validators.EmailString), "must be a valid email address")), - listvalidator.UniqueValues(), + Validators: []validator.Set{ + setvalidator.ValueStringsAre(stringvalidator.RegexMatches(regexp.MustCompile(validators.EmailString), "must be a valid email address")), }, }, "executor": resourceSchema.StringAttribute{ @@ -121,14 +121,10 @@ func DeploymentResourceSchemaAttributes() map[string]resourceSchema.Attribute { MarkdownDescription: "Deployment image version", Computed: true, }, - "environment_variables": resourceSchema.ListNestedAttribute{ + "environment_variables": resourceSchema.SetNestedAttribute{ NestedObject: resourceSchema.NestedAttributeObject{ Attributes: DeploymentEnvironmentVariableResourceAttributes(), }, - Validators: []validator.List{ - listvalidator.UniqueValues(), - listvalidator.UniqueValues(), - }, MarkdownDescription: "Deployment environment variables", Required: true, }, @@ -177,12 +173,12 @@ func DeploymentResourceSchemaAttributes() map[string]resourceSchema.Attribute { MarkdownDescription: "Whether DAG deploy is enabled - Changing this value may disrupt your deployment. Read more at https://docs.astronomer.io/astro/deploy-dags#enable-or-disable-dag-only-deploys-on-a-deployment", Required: true, }, - "external_ips": resourceSchema.ListAttribute{ + "external_ips": resourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Deployment external IPs", Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.UseStateForUnknown(), + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), }, }, "oidc_issuer_url": resourceSchema.StringAttribute{ @@ -206,16 +202,15 @@ func DeploymentResourceSchemaAttributes() map[string]resourceSchema.Attribute { stringplanmodifier.RequiresReplaceIfConfigured(), }, }, - "worker_queues": resourceSchema.ListNestedAttribute{ + "worker_queues": resourceSchema.SetNestedAttribute{ Optional: true, NestedObject: resourceSchema.NestedAttributeObject{ Attributes: WorkerQueueResourceSchemaAttributes(), }, MarkdownDescription: "Deployment worker queues - required for deployments with 'CELERY' executor", - Validators: []validator.List{ + Validators: []validator.Set{ // Dynamic validation with 'executor' done in the resource.ValidateConfig function - listvalidator.SizeAtLeast(1), - listvalidator.UniqueValues(), + setvalidator.SizeAtLeast(1), }, }, "scheduler_au": resourceSchema.Int64Attribute{ @@ -404,7 +399,7 @@ func DeploymentDataSourceSchemaAttributes() map[string]datasourceSchema.Attribut MarkdownDescription: "Deployment namespace", Computed: true, }, - "contact_emails": datasourceSchema.ListAttribute{ + "contact_emails": datasourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Deployment contact emails", Computed: true, @@ -441,7 +436,7 @@ func DeploymentDataSourceSchemaAttributes() map[string]datasourceSchema.Attribut MarkdownDescription: "Deployment image version", Computed: true, }, - "environment_variables": datasourceSchema.ListNestedAttribute{ + "environment_variables": datasourceSchema.SetNestedAttribute{ NestedObject: datasourceSchema.NestedAttributeObject{ Attributes: DeploymentEnvironmentVariableDataSourceAttributes(), }, @@ -476,7 +471,7 @@ func DeploymentDataSourceSchemaAttributes() map[string]datasourceSchema.Attribut MarkdownDescription: "Deployment desired DAG tarball version", Computed: true, }, - "worker_queues": datasourceSchema.ListNestedAttribute{ + "worker_queues": datasourceSchema.SetNestedAttribute{ NestedObject: datasourceSchema.NestedAttributeObject{ Attributes: WorkerQueueDataSourceSchemaAttributes(), }, @@ -515,7 +510,7 @@ func DeploymentDataSourceSchemaAttributes() map[string]datasourceSchema.Attribut MarkdownDescription: "Deployment workload identity", Computed: true, }, - "external_ips": datasourceSchema.ListAttribute{ + "external_ips": datasourceSchema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Deployment external IPs", Computed: true, @@ -605,7 +600,21 @@ func DeploymentEnvironmentVariableResourceAttributes() map[string]resourceSchema } } -func WorkerQueueAttributeTypes() map[string]attr.Type { +func WorkerQueueResourceAttributeTypes() map[string]attr.Type { + return map[string]attr.Type{ + "name": types.StringType, + "is_default": types.BoolType, + "max_worker_count": types.Int64Type, + "min_worker_count": types.Int64Type, + "pod_cpu": types.StringType, + "pod_memory": types.StringType, + "worker_concurrency": types.Int64Type, + "node_pool_id": types.StringType, + "astro_machine": types.StringType, + } +} + +func WorkerQueueDataSourceAttributeTypes() map[string]attr.Type { return map[string]attr.Type{ "id": types.StringType, "name": types.StringType, @@ -667,10 +676,6 @@ func WorkerQueueDataSourceSchemaAttributes() map[string]datasourceSchema.Attribu func WorkerQueueResourceSchemaAttributes() map[string]resourceSchema.Attribute { return map[string]resourceSchema.Attribute{ - "id": resourceSchema.StringAttribute{ - MarkdownDescription: "Worker queue identifier", - Computed: true, - }, "name": resourceSchema.StringAttribute{ MarkdownDescription: "Worker queue name", Required: true, diff --git a/internal/provider/schemas/deployment_options.go b/internal/provider/schemas/deployment_options.go index d075952b..ddcd57db 100644 --- a/internal/provider/schemas/deployment_options.go +++ b/internal/provider/schemas/deployment_options.go @@ -1,8 +1,8 @@ package schemas import ( - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/validators" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/validators" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -12,7 +12,7 @@ import ( func DeploymentOptionsDataSourceSchemaAttributes() map[string]datasourceSchema.Attribute { return map[string]datasourceSchema.Attribute{ - "executors": datasourceSchema.ListAttribute{ + "executors": datasourceSchema.SetAttribute{ MarkdownDescription: "Available executors", ElementType: types.StringType, Computed: true, @@ -22,21 +22,21 @@ func DeploymentOptionsDataSourceSchemaAttributes() map[string]datasourceSchema.A Attributes: ResourceQuotaOptionsDataSourceSchemaAttributes(), Computed: true, }, - "runtime_releases": datasourceSchema.ListAttribute{ + "runtime_releases": datasourceSchema.SetAttribute{ MarkdownDescription: "Available Astro Runtime versions", ElementType: types.ObjectType{ AttrTypes: RuntimeReleaseAttributeTypes(), }, Computed: true, }, - "scheduler_machines": datasourceSchema.ListAttribute{ + "scheduler_machines": datasourceSchema.SetAttribute{ MarkdownDescription: "Available scheduler sizes", ElementType: types.ObjectType{ AttrTypes: SchedulerMachineAttributeTypes(), }, Computed: true, }, - "worker_machines": datasourceSchema.ListAttribute{ + "worker_machines": datasourceSchema.SetAttribute{ MarkdownDescription: "Available worker machine types", ElementType: types.ObjectType{ AttrTypes: WorkerMachineAttributeTypes(), @@ -48,7 +48,7 @@ func DeploymentOptionsDataSourceSchemaAttributes() map[string]datasourceSchema.A Attributes: WorkerQueueOptionsDataSourceSchemaAttributes(), Computed: true, }, - "workload_identity_options": datasourceSchema.ListAttribute{ + "workload_identity_options": datasourceSchema.SetAttribute{ MarkdownDescription: "Available workload identity options", ElementType: types.ObjectType{ AttrTypes: WorkloadIdentityOptionsAttributeTypes(), diff --git a/internal/provider/schemas/deployments.go b/internal/provider/schemas/deployments.go index a4f66b24..b3a2559c 100644 --- a/internal/provider/schemas/deployments.go +++ b/internal/provider/schemas/deployments.go @@ -1,8 +1,8 @@ package schemas import ( - "github.com/astronomer/astronomer-terraform-provider/internal/provider/validators" - "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" + "github.com/astronomer/terraform-provider-astro/internal/provider/validators" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -30,7 +30,7 @@ func DeploymentsElementAttributeTypes() map[string]attr.Type { "astro_runtime_version": types.StringType, "airflow_version": types.StringType, "namespace": types.StringType, - "contact_emails": types.ListType{ + "contact_emails": types.SetType{ ElemType: types.StringType, }, "executor": types.StringType, @@ -41,7 +41,7 @@ func DeploymentsElementAttributeTypes() map[string]attr.Type { "image_tag": types.StringType, "image_repository": types.StringType, "image_version": types.StringType, - "environment_variables": types.ListType{ + "environment_variables": types.SetType{ ElemType: types.ObjectType{ AttrTypes: DeploymentEnvironmentVariableAttributeTypes(), }, @@ -53,9 +53,9 @@ func DeploymentsElementAttributeTypes() map[string]attr.Type { "status_reason": types.StringType, "dag_tarball_version": types.StringType, "desired_dag_tarball_version": types.StringType, - "worker_queues": types.ListType{ + "worker_queues": types.SetType{ ElemType: types.ObjectType{ - AttrTypes: WorkerQueueAttributeTypes(), + AttrTypes: WorkerQueueDataSourceAttributeTypes(), }, }, "task_pod_node_pool_id": types.StringType, @@ -66,7 +66,7 @@ func DeploymentsElementAttributeTypes() map[string]attr.Type { "is_high_availability": types.BoolType, "is_development_mode": types.BoolType, "workload_identity": types.StringType, - "external_ips": types.ListType{ + "external_ips": types.SetType{ ElemType: types.StringType, }, "oidc_issuer_url": types.StringType, @@ -85,34 +85,31 @@ func DeploymentsElementAttributeTypes() map[string]attr.Type { func DeploymentsDataSourceSchemaAttributes() map[string]schema.Attribute { return map[string]schema.Attribute{ - "deployments": schema.ListNestedAttribute{ + "deployments": schema.SetNestedAttribute{ NestedObject: schema.NestedAttributeObject{ Attributes: DeploymentDataSourceSchemaAttributes(), }, Computed: true, }, - "deployment_ids": schema.ListAttribute{ + "deployment_ids": schema.SetAttribute{ ElementType: types.StringType, Optional: true, - Validators: []validator.List{ - listvalidator.ValueStringsAre(validators.IsCuid()), - listvalidator.UniqueValues(), + Validators: []validator.Set{ + setvalidator.ValueStringsAre(validators.IsCuid()), }, }, - "workspace_ids": schema.ListAttribute{ + "workspace_ids": schema.SetAttribute{ ElementType: types.StringType, Optional: true, - Validators: []validator.List{ - listvalidator.ValueStringsAre(validators.IsCuid()), - listvalidator.UniqueValues(), + Validators: []validator.Set{ + setvalidator.ValueStringsAre(validators.IsCuid()), }, }, - "names": schema.ListAttribute{ + "names": schema.SetAttribute{ ElementType: types.StringType, Optional: true, - Validators: []validator.List{ - listvalidator.ValueStringsAre(stringvalidator.LengthAtLeast(1)), - listvalidator.UniqueValues(), + Validators: []validator.Set{ + setvalidator.ValueStringsAre(stringvalidator.LengthAtLeast(1)), }, }, } diff --git a/internal/provider/schemas/provider.go b/internal/provider/schemas/provider.go index df629b39..cc010fb8 100644 --- a/internal/provider/schemas/provider.go +++ b/internal/provider/schemas/provider.go @@ -3,7 +3,7 @@ package schemas import ( "regexp" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/validators" + "github.com/astronomer/terraform-provider-astro/internal/provider/validators" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/schema/validator" diff --git a/internal/provider/schemas/scaling.go b/internal/provider/schemas/scaling.go index f97ba006..9b0d9d98 100644 --- a/internal/provider/schemas/scaling.go +++ b/internal/provider/schemas/scaling.go @@ -2,7 +2,7 @@ package schemas import ( "github.com/hashicorp/terraform-plugin-framework-validators/boolvalidator" - "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -26,7 +26,7 @@ func HibernationSpecAttributeTypes() map[string]attr.Type { "override": types.ObjectType{ AttrTypes: HibernationOverrideAttributeTypes(), }, - "schedules": types.ListType{ + "schedules": types.SetType{ ElemType: types.ObjectType{ AttrTypes: HibernationScheduleAttributeTypes(), }, @@ -49,7 +49,7 @@ func HibernationSpecDataSourceSchemaAttributes() map[string]datasourceSchema.Att Attributes: HibernationOverrideDataSourceSchemaAttributes(), Computed: true, }, - "schedules": datasourceSchema.ListNestedAttribute{ + "schedules": datasourceSchema.SetNestedAttribute{ NestedObject: datasourceSchema.NestedAttributeObject{ Attributes: HibernationScheduleDataSourceSchemaAttributes(), }, @@ -111,12 +111,12 @@ func HibernationSpecResourceSchemaAttributes() map[string]resourceSchema.Attribu Attributes: HibernationOverrideResourceSchemaAttributes(), Optional: true, }, - "schedules": resourceSchema.ListNestedAttribute{ + "schedules": resourceSchema.SetNestedAttribute{ NestedObject: resourceSchema.NestedAttributeObject{ Attributes: HibernationScheduleResourceSchemaAttributes(), }, - Validators: []validator.List{ - listvalidator.SizeAtMost(10), + Validators: []validator.Set{ + setvalidator.SizeAtMost(10), }, Optional: true, }, diff --git a/internal/provider/schemas/subject_profile_test.go b/internal/provider/schemas/subject_profile_test.go index 772c45e0..ef9ecefe 100644 --- a/internal/provider/schemas/subject_profile_test.go +++ b/internal/provider/schemas/subject_profile_test.go @@ -6,11 +6,11 @@ import ( "github.com/stretchr/testify/assert" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" + "github.com/astronomer/terraform-provider-astro/internal/provider/schemas" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/iam" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" + "github.com/astronomer/terraform-provider-astro/internal/clients/iam" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/provider/models" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/samber/lo" ) diff --git a/internal/provider/schemas/workspace.go b/internal/provider/schemas/workspace.go index 3d7d2c3c..642fcc69 100644 --- a/internal/provider/schemas/workspace.go +++ b/internal/provider/schemas/workspace.go @@ -1,7 +1,7 @@ package schemas import ( - "github.com/astronomer/astronomer-terraform-provider/internal/provider/validators" + "github.com/astronomer/terraform-provider-astro/internal/provider/validators" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" datasourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema" diff --git a/internal/provider/schemas/workspaces.go b/internal/provider/schemas/workspaces.go index 03d1c653..4bc84c33 100644 --- a/internal/provider/schemas/workspaces.go +++ b/internal/provider/schemas/workspaces.go @@ -1,8 +1,8 @@ package schemas import ( - "github.com/astronomer/astronomer-terraform-provider/internal/provider/validators" - "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" + "github.com/astronomer/terraform-provider-astro/internal/provider/validators" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -29,25 +29,23 @@ func WorkspacesElementAttributeTypes() map[string]attr.Type { func WorkspacesDataSourceSchemaAttributes() map[string]schema.Attribute { return map[string]schema.Attribute{ - "workspaces": schema.ListNestedAttribute{ + "workspaces": schema.SetNestedAttribute{ NestedObject: schema.NestedAttributeObject{ Attributes: WorkspaceDataSourceSchemaAttributes(), }, Computed: true, }, - "workspace_ids": schema.ListAttribute{ + "workspace_ids": schema.SetAttribute{ ElementType: types.StringType, - Validators: []validator.List{ - listvalidator.ValueStringsAre(validators.IsCuid()), - listvalidator.UniqueValues(), + Validators: []validator.Set{ + setvalidator.ValueStringsAre(validators.IsCuid()), }, Optional: true, }, - "names": schema.ListAttribute{ + "names": schema.SetAttribute{ ElementType: types.StringType, - Validators: []validator.List{ - listvalidator.ValueStringsAre(stringvalidator.LengthAtLeast(1)), - listvalidator.UniqueValues(), + Validators: []validator.Set{ + setvalidator.ValueStringsAre(stringvalidator.LengthAtLeast(1)), }, Optional: true, }, diff --git a/internal/provider/validators/is_cuid_test.go b/internal/provider/validators/is_cuid_test.go index 5916d93e..80ca890e 100644 --- a/internal/provider/validators/is_cuid_test.go +++ b/internal/provider/validators/is_cuid_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/validators" + "github.com/astronomer/terraform-provider-astro/internal/provider/validators" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/lucsky/cuid" diff --git a/internal/provider/validators/optional_test.go b/internal/provider/validators/optional_test.go index 07ff42cb..86ea7a97 100644 --- a/internal/provider/validators/optional_test.go +++ b/internal/provider/validators/optional_test.go @@ -3,7 +3,7 @@ package validators_test import ( "testing" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/validators" + "github.com/astronomer/terraform-provider-astro/internal/provider/validators" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/lucsky/cuid" diff --git a/internal/provider/validators/regex_test.go b/internal/provider/validators/regex_test.go index d3c398b7..1859bed3 100644 --- a/internal/provider/validators/regex_test.go +++ b/internal/provider/validators/regex_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/validators" + "github.com/astronomer/terraform-provider-astro/internal/provider/validators" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" diff --git a/internal/utils/errors_test.go b/internal/utils/errors_test.go index 1dfde97f..a63e1b25 100644 --- a/internal/utils/errors_test.go +++ b/internal/utils/errors_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/astronomer/astronomer-terraform-provider/internal/utils" + "github.com/astronomer/terraform-provider-astro/internal/utils" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/resource" ) diff --git a/internal/utils/list.go b/internal/utils/list.go deleted file mode 100644 index fcfaa4fa..00000000 --- a/internal/utils/list.go +++ /dev/null @@ -1,59 +0,0 @@ -package utils - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/samber/lo" -) - -// StringList is a helper that creates a types.List of string values -func StringList(values *[]string) (types.List, diag.Diagnostics) { - if values == nil { - return types.ListValue(types.StringType, []attr.Value{}) - } - return types.ListValue(types.StringType, lo.Map(*values, func(v string, _ int) attr.Value { - return types.StringValue(v) - })) -} - -// ObjectList is a helper that creates a types.List of objects where each types.Object is created by the transformer function -func ObjectList[T any](ctx context.Context, values *[]T, objectAttributeTypes map[string]attr.Type, transformer func(context.Context, T) (types.Object, diag.Diagnostics)) (types.List, diag.Diagnostics) { - if values == nil { - // NullList and EmptyList are different in Terraform - // Sometimes the API returns a null list, sometimes it returns an empty list - // However, in the Terraform framework, sometimes we need to return a null list, sometimes we need to return an empty list - // so there are four possible combinations we need to be aware of - return types.ListNull(types.ObjectType{AttrTypes: objectAttributeTypes}), nil - } - objs := make([]attr.Value, len(*values)) - for i, value := range *values { - obj, diags := transformer(ctx, value) - if diags.HasError() { - return types.List{}, diags - } - objs[i] = obj - } - return types.ListValue(types.ObjectType{AttrTypes: objectAttributeTypes}, objs) -} - -// TypesListToStringSlicePtr converts a types.List to a pointer to a slice of strings -// This is useful for converting a list of strings from the Terraform framework to a slice of strings used for calling the API -// We prefer to use a pointer to a slice of strings because our API client query params usually have type *[]string -// and we can easily assign the query param to the result of this function (regardless if the result is nil or not) -func TypesListToStringSlicePtr(ctx context.Context, list types.List) (*[]string, diag.Diagnostics) { - if len(list.Elements()) == 0 { - return nil, nil - } - var typesStringSlice []types.String - diags := list.ElementsAs(ctx, &typesStringSlice, false) - if diags.HasError() { - return nil, diags - } - resp := lo.Map(typesStringSlice, func(v types.String, _ int) string { - return v.ValueString() - }) - return &resp, nil -} diff --git a/internal/utils/list_test.go b/internal/utils/list_test.go deleted file mode 100644 index abbc7e48..00000000 --- a/internal/utils/list_test.go +++ /dev/null @@ -1,108 +0,0 @@ -package utils_test - -import ( - "context" - "fmt" - "testing" - - "github.com/astronomer/astronomer-terraform-provider/internal/provider/models" - "github.com/astronomer/astronomer-terraform-provider/internal/provider/schemas" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stretchr/testify/assert" - - "github.com/astronomer/astronomer-terraform-provider/internal/utils" -) - -func TestUnit_StringList(t *testing.T) { - t.Run("nil", func(t *testing.T) { - list, diags := utils.StringList(nil) - - assert.False(t, diags.HasError()) - assert.Equal(t, 0, len(list.Elements())) - }) - - t.Run("with values", func(t *testing.T) { - input := []string{"one", "two", "three"} - - list, diags := utils.StringList(&input) - - assert.False(t, diags.HasError()) - assert.Equal(t, len(input), len(list.Elements())) - for i, v := range input { - assert.Equal(t, fmt.Sprintf(`"%s"`, v), list.Elements()[i].String()) - } - }) -} - -func TestUnit_ObjectList(t *testing.T) { - transformer := func(ctx context.Context, value models.DeploymentEnvironmentVariable) (types.Object, diag.Diagnostics) { - obj, diags := types.ObjectValue(schemas.DeploymentEnvironmentVariableAttributeTypes(), map[string]attr.Value{ - "key": value.Key, - "value": value.Value, - "updated_at": value.UpdatedAt, - "is_secret": value.IsSecret, - }) - if diags.HasError() { - return types.Object{}, diags - } - return obj, nil - } - - t.Run("nil", func(t *testing.T) { - ctx := context.Background() - list, diags := utils.ObjectList(ctx, nil, schemas.DeploymentEnvironmentVariableAttributeTypes(), transformer) - - assert.False(t, diags.HasError()) - assert.Equal(t, 0, len(list.Elements())) - }) - - t.Run("with values", func(t *testing.T) { - ctx := context.Background() - input := []models.DeploymentEnvironmentVariable{ - { - Key: types.StringValue("key1"), - Value: types.StringValue("value1"), - UpdatedAt: types.StringValue("date1"), - IsSecret: types.BoolValue(false), - }, - { - Key: types.StringValue("key2"), - Value: types.StringValue("value2"), - UpdatedAt: types.StringValue("date2"), - IsSecret: types.BoolValue(true), - }, - } - list, diags := utils.ObjectList(ctx, &input, schemas.DeploymentEnvironmentVariableAttributeTypes(), transformer) - - assert.False(t, diags.HasError()) - assert.Equal(t, len(input), len(list.Elements())) - for i, v := range input { - objString := list.Elements()[i].String() - assert.Contains(t, objString, v.Key.ValueString()) - assert.Contains(t, objString, v.Value.ValueString()) - assert.Contains(t, objString, v.UpdatedAt.ValueString()) - assert.Contains(t, objString, fmt.Sprintf("%v", v.IsSecret.ValueBool())) - } - }) -} - -func TestUnit_TypesListToStringSlicePtr(t *testing.T) { - t.Run("empty", func(t *testing.T) { - list := types.ListValueMust(types.StringType, []attr.Value{}) - - result, diags := utils.TypesListToStringSlicePtr(context.Background(), list) - assert.Nil(t, diags) - assert.Nil(t, result) - }) - - t.Run("with values", func(t *testing.T) { - list := types.ListValueMust(types.StringType, []attr.Value{types.StringValue("string1"), types.StringValue("string2")}) - - expected := &[]string{"string1", "string2"} - result, diags := utils.TypesListToStringSlicePtr(context.Background(), list) - assert.Nil(t, diags) - assert.Equal(t, expected, result) - }) -} diff --git a/internal/utils/set.go b/internal/utils/set.go new file mode 100644 index 00000000..ee98e9f8 --- /dev/null +++ b/internal/utils/set.go @@ -0,0 +1,59 @@ +package utils + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/samber/lo" +) + +// StringSet is a helper that creates a types.Set of string values +func StringSet(values *[]string) (types.Set, diag.Diagnostics) { + if values == nil { + return types.SetValue(types.StringType, []attr.Value{}) + } + return types.SetValue(types.StringType, lo.Map(*values, func(v string, _ int) attr.Value { + return types.StringValue(v) + })) +} + +// ObjectSet is a helper that creates a types.Set of objects where each types.Object is created by the transformer function +func ObjectSet[T any](ctx context.Context, values *[]T, objectAttributeTypes map[string]attr.Type, transformer func(context.Context, T) (types.Object, diag.Diagnostics)) (types.Set, diag.Diagnostics) { + if values == nil { + // NullSet and EmptySet are different in Terraform + // Sometimes the API returns a null list, sometimes it returns an empty list + // However, in the Terraform framework, sometimes we need to return a null list, sometimes we need to return an empty list + // so there are four possible combinations we need to be aware of + return types.SetNull(types.ObjectType{AttrTypes: objectAttributeTypes}), nil + } + objs := make([]attr.Value, len(*values)) + for i, value := range *values { + obj, diags := transformer(ctx, value) + if diags.HasError() { + return types.Set{}, diags + } + objs[i] = obj + } + return types.SetValue(types.ObjectType{AttrTypes: objectAttributeTypes}, objs) +} + +// TypesSetToStringSlicePtr converts a types.Set to a pointer to a slice of strings +// This is useful for converting a set of strings from the Terraform framework to a slice of strings used for calling the API +// We prefer to use a pointer to a slice of strings because our API client query params usually have type *[]string +// and we can easily assign the query param to the result of this function (regardless if the result is nil or not) +func TypesSetToStringSlicePtr(ctx context.Context, s types.Set) (*[]string, diag.Diagnostics) { + if len(s.Elements()) == 0 { + return nil, nil + } + var typesStringSlice []types.String + diags := s.ElementsAs(ctx, &typesStringSlice, false) + if diags.HasError() { + return nil, diags + } + resp := lo.Map(typesStringSlice, func(v types.String, _ int) string { + return v.ValueString() + }) + return &resp, nil +} diff --git a/internal/utils/set_test.go b/internal/utils/set_test.go new file mode 100644 index 00000000..75cf557d --- /dev/null +++ b/internal/utils/set_test.go @@ -0,0 +1,53 @@ +package utils_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/stretchr/testify/assert" + + "github.com/astronomer/terraform-provider-astro/internal/utils" +) + +func TestUnit_StringSet(t *testing.T) { + t.Run("nil", func(t *testing.T) { + s, diags := utils.StringSet(nil) + + assert.False(t, diags.HasError()) + assert.Equal(t, 0, len(s.Elements())) + }) + + t.Run("with values", func(t *testing.T) { + input := []string{"one", "two", "three"} + + s, diags := utils.StringSet(&input) + + assert.False(t, diags.HasError()) + assert.Equal(t, len(input), len(s.Elements())) + for i, v := range input { + assert.Equal(t, fmt.Sprintf(`"%s"`, v), s.Elements()[i].String()) + } + }) +} + +func TestUnit_TypesSetToStringSlicePtr(t *testing.T) { + t.Run("empty", func(t *testing.T) { + s := types.SetValueMust(types.StringType, []attr.Value{}) + + result, diags := utils.TypesSetToStringSlicePtr(context.Background(), s) + assert.Nil(t, diags) + assert.Nil(t, result) + }) + + t.Run("with values", func(t *testing.T) { + s := types.SetValueMust(types.StringType, []attr.Value{types.StringValue("string1"), types.StringValue("string2")}) + + expected := &[]string{"string1", "string2"} + result, diags := utils.TypesSetToStringSlicePtr(context.Background(), s) + assert.Nil(t, diags) + assert.Equal(t, expected, result) + }) +} diff --git a/internal/utils/test.go b/internal/utils/test.go index 3ea89c71..05d70249 100644 --- a/internal/utils/test.go +++ b/internal/utils/test.go @@ -8,13 +8,13 @@ import ( "github.com/hashicorp/terraform-plugin-testing/terraform" - "github.com/astronomer/astronomer-terraform-provider/internal/clients/platform" + "github.com/astronomer/terraform-provider-astro/internal/clients/platform" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" ) var hostedPlatformClient, hybridPlatformClient *platform.ClientWithResponses -const TestResourceDescription = "Created by Terraform Acceptance Test - will self-cleanup" +const TestResourceDescription = "Created by Terraform Acceptance Test - should self-cleanup but can delete manually if needed after 2 hours." func GenerateTestResourceName(numRandomChars int) string { return fmt.Sprintf("TFAcceptanceTest_%v", strings.ToUpper(acctest.RandStringFromCharSet(numRandomChars, acctest.CharSetAlpha))) @@ -47,11 +47,11 @@ func GetTestHostedPlatformClient() (*platform.ClientWithResponses, error) { } // GetDataSourcesLength retrieves the number of elements returned from a data source in the Terraform state. -// For example, if the config is `data.astronomer_workspaces.my_workspaces`, the `dataSourceName` would be `workspaces` and +// For example, if the config is `data.astro_workspaces.my_workspaces`, the `dataSourceName` would be `workspaces` and // `tfVarName` would `my_workspaces`. // The returned value is the instance state, the number of elements in `workspaces` of that data source, and an error if there is one. func GetDataSourcesLength(state *terraform.State, tfVarName, dataSourceName string) (*terraform.InstanceState, int, error) { - resourceID := fmt.Sprintf("data.astronomer_%s.%s", dataSourceName, tfVarName) + resourceID := fmt.Sprintf("data.astro_%s.%s", dataSourceName, tfVarName) // Retrieve the resource state by its identifier. resourceState := state.Modules[0].Resources[resourceID] diff --git a/main.go b/main.go index d78c8fa4..f0cc5b9f 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( "flag" "log" - "github.com/astronomer/astronomer-terraform-provider/internal/provider" + "github.com/astronomer/terraform-provider-astro/internal/provider" "github.com/hashicorp/terraform-plugin-framework/providerserver" ) @@ -21,7 +21,7 @@ import ( // Run the docs generation tool, check its repository for more information on how it works and how docs // can be customized. -//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-name astronomer +//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-name astro var ( // these will be set by the goreleaser configuration @@ -46,7 +46,7 @@ func main() { opts := providerserver.ServeOpts{ // Also update the tfplugindocs generate command to either remove the // -provider-name flag or set its value to the updated provider name. - Address: "registry.terraform.io/astronomer/astronomer", + Address: "registry.terraform.io/astronomer/astro", Debug: debug, }