From 2436178b7ee06491a6199146498256f41ba4b9e7 Mon Sep 17 00:00:00 2001 From: Tyler Gillson Date: Thu, 25 Jul 2024 01:25:54 -0600 Subject: [PATCH] chore: remove master refs & improve CI (#489) * chore: remove lingering 'master' refs Signed-off-by: Tyler Gillson * ci: tidy workflows; ensure reviewable and run tests Signed-off-by: Tyler Gillson * ci: add go generate to reviewability checks Signed-off-by: Tyler Gillson * chore: remove lingering 'master' refs Signed-off-by: Tyler Gillson --------- Signed-off-by: Tyler Gillson --- .github/workflows/ci.yml | 15 ++- .github/workflows/release.yml | 27 ++--- .golangci.yaml | 108 ++---------------- GNUmakefile | 38 ++++-- docs/resources/cluster_custom_cloud.md | 2 +- .../config_templates/cloud_config.yaml | 2 +- ...r_pool_config.yaml => cp_pool_config.yaml} | 2 +- .../resource.tf | 4 +- .../spectrocloud_cluster_tke/resource.tf | 2 +- .../terraform.template.tfvars | 2 +- .../spectrocloud_cluster_tke/variables.tf | 2 +- spectrocloud/cluster_common_hash.go | 2 +- spectrocloud/data_source_cloud_account_aws.go | 4 +- .../data_source_cloud_account_azure.go | 20 ++-- spectrocloud/data_source_cloud_account_gcp.go | 4 +- spectrocloud/data_source_pack.go | 40 +++---- spectrocloud/resource_cluster_aws_test.go | 22 ++-- spectrocloud/resource_cluster_azure.go | 9 +- spectrocloud/resource_cluster_azure_test.go | 24 ++-- .../resource_cluster_custom_cloud_test.go | 8 +- .../resource_cluster_edge_native_test.go | 6 +- spectrocloud/resource_cluster_eks.go | 5 +- .../resource_cluster_eks_flatten_test.go | 5 +- spectrocloud/resource_cluster_libvirt.go | 7 +- spectrocloud/resource_cluster_mass_test.go | 3 +- spectrocloud/resource_cluster_tke.go | 3 +- spectrocloud/resource_cluster_vsphere_test.go | 48 ++++---- .../resources/cluster_custom_cloud.md.tmpl | 2 +- 28 files changed, 183 insertions(+), 233 deletions(-) rename examples/resources/spectrocloud_cluster_custom_cloud/config_templates/{master_pool_config.yaml => cp_pool_config.yaml} (99%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d34704f..c89ddec7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,20 +8,23 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Unshallow run: git fetch --prune --unshallow + - name: Configure git for private modules env: TOKEN: ${{ secrets.SPECTRO_TOKEN }} USER: ${{ secrets.SPECTRO_USER }} run: git config --global url."https://${USER}:${TOKEN}@github.com".insteadOf "https://github.com" + - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.21 - - name: Vet - run: make vet - - name: Lint - run: make lint - - name: Test + go-version-file: go.mod + + - name: Ensure reviewable + run: make check-diff + + - name: Run acceptance tests run: make testacc diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c6fcb90..9f26756e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,40 +10,41 @@ # in `goreleaser` to indicate this is being used in a non-interactive mode. # name: release + on: push: tags: - 'v*' + jobs: goreleaser: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v3 - - - name: Unshallow + + - name: Unshallow run: git fetch --prune --unshallow - - - name: Configure git for private modules + + - name: Configure git for private modules env: TOKEN: ${{ secrets.SPECTRO_TOKEN }} USER: ${{ secrets.SPECTRO_USER }} run: git config --global url."https://${USER}:${TOKEN}@github.com".insteadOf "https://github.com" - - - name: Set up Go + + - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.21 - - - name: Import GPG key + go-version-file: go.mod + + - name: Import GPG key id: import_gpg uses: crazy-max/ghaction-import-gpg@v5 with: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.PASSPHRASE }} - - - name: Run GoReleaser + + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 with: distribution: goreleaser diff --git a/.golangci.yaml b/.golangci.yaml index e892d8b2..7205eeb7 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,22 +1,15 @@ -## golangci-lint v1.46.2 - # References: # - https://golangci-lint.run/usage/linters/ -# - https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322 run: timeout: 10m # default 1m linters-settings: - gosimple: - go: "1.18" # default 1.13 govet: enable-all: true disable: - fieldalignment # too strict - shadow # too strict - staticcheck: - go: "1.18" # default 1.13 # Non-default cyclop: @@ -36,98 +29,15 @@ linters-settings: linters: disable-all: true enable: - ## enabled by default - - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases - - gosimple # Linter for Go source code that specializes in simplifying a code - - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string - - ineffassign # Detects when assignments to existing variables are not used - - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks - - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code - - unused # Checks Go code for unused constants, variables, functions and types - ## disabled by default - - cyclop # checks function and package cyclomatic complexity - - gocognit # Computes and checks the cognitive complexity of functions - ## disabled - #- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers - #- bidichk # Checks for dangerous unicode character sequences - #- bodyclose # checks whether HTTP response body is closed successfully - #- containedctx # containedctx is a linter that detects struct contained context.Context field - #- contextcheck # check the function whether use a non-inherited context - #- decorder # check declaration order and count of types, constants, variables and functions - #- depguard # [replaced by gomodguard] Go linter that checks if package imports are in a list of acceptable packages - #- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) - #- dupl # Tool for code clone detection - #- durationcheck # check for two durations multiplied together - #- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted. - #- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error. - #- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. - #- execinquery # execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds - #- exhaustive # check exhaustiveness of enum switch statements - #- exhaustivestruct # [deprecated, replaced by exhaustruct] Checks if all struct's fields are initialized - #- exhaustruct # [can be enabled, but have to be configured] Checks if all structure fields are initialized - #- exportloopref # checks for pointers to enclosing loop variables - #- forbidigo # Forbids identifiers - #- forcetypeassert # [replaced by errcheck] finds forced type assertions - #- funlen # Tool for detection of long functions - #- gci # Gci controls golang package import order and makes it always deterministic. - #- gocyclo # Computes and checks the cyclomatic complexity of functions - #- godox # Tool for detection of FIXME, TODO and other comment keywords - #- goerr113 # [too strict] Golang linter to check the errors handling expressions - #- gofmt # [replaced by goimports] Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification - #- gofumpt # [replaced by goimports, gofumports is not available yet] Gofumpt checks whether code was gofumpt-ed. - #- goheader # Checks is file header matches to pattern - #- golint # [deprecated, replaced by revive] Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes - #- grouper # An analyzer to analyze expression groups. - #- gochecknoglobals # check that no global variables exist - #- gochecknoinits # Checks that no init functions are present in Go code - #- goconst # Finds repeated strings that could be replaced by a constant - #- gocritic # Provides diagnostics that check for bugs, performance and style issues. - #- godot # Check if comments end in a period - #- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt. - #- gomnd # An analyzer to detect magic numbers. - #- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod. - #- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. - #- goprintffuncname # Checks that printf-like functions are named with f at the end - #- gosec # Inspects source code for security problems - #- ifshort # Checks that your code uses short syntax for if-statements whenever possible - #- importas # Enforces consistent import aliases - #- interfacer # [deprecated] Linter that suggests narrower interface types - #- ireturn # [good, but too strict] Accept Interfaces, Return Concrete Types - #- lll # Reports long lines - #- maintidx # maintidx measures the maintainability index of each function. - #- makezero # Finds slice declarations with non-zero initial length - #- maligned # [deprecated, replaced by govet fieldalignment] Tool to detect Go structs that would take less memory if their fields were sorted - #- misspell # [useless] Finds commonly misspelled English words in comments - #- nakedret # Finds naked returns in functions greater than a specified function length - #- nestif # Reports deeply nested if statements - #- nilerr # Finds the code that returns nil even if it checks that the error is not nil. - #- nilnil # Checks that there is no simultaneous return of nil error and an invalid value. - #- nlreturn # [too strict and mostly code is not more readable] nlreturn checks for a new line before return and branch statements to increase code clarity - #- noctx # noctx finds sending http request without context.Context - #- nolintlint # Reports ill-formed or insufficient nolint directives - #- nonamedreturns # Reports all named returns - #- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. - #- paralleltest # [too many false positives] paralleltest detects missing usage of t.Parallel() method in your Go test - #- prealloc # Finds slice declarations that could potentially be preallocated - #- predeclared # find code that shadows one of Go's predeclared identifiers - #- promlinter # Check Prometheus metrics naming via promlint - #- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. - #- rowserrcheck # checks whether Err of rows is checked successfully - #- scopelint # [deprecated, replaced by exportloopref] Scopelint checks for unpinned variables in go programs - #- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. - #- stylecheck # Stylecheck is a replacement for golint - #- tagliatelle # Checks the struct tags. - #- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 - #- testpackage # linter that makes you use a separate _test package - #- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers - #- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes - #- unconvert # Remove unnecessary type conversions - #- unparam # Reports unused function parameters - #- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope - #- wastedassign # wastedassign finds wasted assignment statements. - #- whitespace # Tool for detection of leading and trailing whitespace - #- wrapcheck # [too strict] Checks that errors returned from external packages are wrapped - #- wsl # [too strict and mostly code is not more readable] Whitespace Linter - Forces you to use empty lines! + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + - unused + - cyclop + - gocognit issues: max-issues-per-linter: 0 diff --git a/GNUmakefile b/GNUmakefile index c77770ca..6b6b063e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,39 +3,63 @@ .DEFAULT_GOAL:=help -DEV_PROVIDER_VERSION=100.100.100 -GOLANGCI_VERSION ?= 1.55.2 - -BIN_DIR ?= ./bin +# Go variables GOOS ?= $(shell go env GOOS) GOARCH ?= $(shell go env GOARCH) +# Output +TIME = `date +%H:%M:%S` +GREEN := $(shell printf "\033[32m") +RED := $(shell printf "\033[31m") +CNone := $(shell printf "\033[0m") +OK = echo ${TIME} ${GREEN}[ OK ]${CNone} +ERR = echo ${TIME} ${RED}[ ERR ]${CNone} "error:" + ##@ Help Targets help: ## Display this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[0m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -bin-dir: - test -d $(BIN_DIR) || mkdir $(BIN_DIR) - ##@ Static Analysis Targets + +check-diff: reviewable ## Execute branch is clean + git --no-pager diff + git diff --quiet || ($(ERR) please run 'make reviewable' to include all changes && false) + @$(OK) branch is clean + +reviewable: fmt vet lint generate ## Ensure code is ready for review + git submodule update --remote + go mod tidy + fmt: ## Run go fmt against code go fmt ./... + vet: ## Run go vet against code go vet ./... + lint: golangci-lint ## Run golangci-lint against code $(GOLANGCI_LINT) run +generate: + go generate ./... + ##@ Test Targets .PHONY: testacc testacc: ## Run acceptance tests TF_ACC=1 go test -v $(TESTARGS) -covermode=atomic -coverpkg=./... -coverprofile=profile.cov ./... -timeout 120m ##@ Development Targets + +DEV_PROVIDER_VERSION=100.100.100 dev-provider: ## Generate dev provider bash generate_dev_provider.sh $(DEV_PROVIDER_VERSION) # Tools Section +BIN_DIR ?= ./bin +bin-dir: + test -d $(BIN_DIR) || mkdir $(BIN_DIR) + +GOLANGCI_VERSION ?= 1.54.2 golangci-lint: bin-dir if ! test -f $(BIN_DIR)/golangci-lint-linux-amd64; then \ curl -LOs https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-linux-amd64.tar.gz; \ diff --git a/docs/resources/cluster_custom_cloud.md b/docs/resources/cluster_custom_cloud.md index 6d524cd6..163a85dc 100644 --- a/docs/resources/cluster_custom_cloud.md +++ b/docs/resources/cluster_custom_cloud.md @@ -48,7 +48,7 @@ description: |- } control_plane = true control_plane_as_worker = true - node_pool_config = templatefile("config_templates/master_pool_config.yaml", local.node_pool_config_variables) + node_pool_config = templatefile("config_templates/cp_pool_config.yaml", local.node_pool_config_variables) } machine_pool { diff --git a/examples/resources/spectrocloud_cluster_custom_cloud/config_templates/cloud_config.yaml b/examples/resources/spectrocloud_cluster_custom_cloud/config_templates/cloud_config.yaml index a5bfaea1..49275c43 100644 --- a/examples/resources/spectrocloud_cluster_custom_cloud/config_templates/cloud_config.yaml +++ b/examples/resources/spectrocloud_cluster_custom_cloud/config_templates/cloud_config.yaml @@ -51,7 +51,7 @@ spec: controlPlaneRef: apiVersion: controlplane.cluster.x-k8s.io/v1beta1 kind: KubeadmControlPlane - name: "master-pool" + name: "cp-pool" infrastructureRef: apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: NutanixCluster diff --git a/examples/resources/spectrocloud_cluster_custom_cloud/config_templates/master_pool_config.yaml b/examples/resources/spectrocloud_cluster_custom_cloud/config_templates/cp_pool_config.yaml similarity index 99% rename from examples/resources/spectrocloud_cluster_custom_cloud/config_templates/master_pool_config.yaml rename to examples/resources/spectrocloud_cluster_custom_cloud/config_templates/cp_pool_config.yaml index 2651bc69..baa48c81 100644 --- a/examples/resources/spectrocloud_cluster_custom_cloud/config_templates/master_pool_config.yaml +++ b/examples/resources/spectrocloud_cluster_custom_cloud/config_templates/cp_pool_config.yaml @@ -2,7 +2,7 @@ apiVersion: controlplane.cluster.x-k8s.io/v1beta1 kind: KubeadmControlPlane metadata: - name: ${MASTER_NODE_POOL_NAME} + name: ${CP_NODE_POOL_NAME} spec: kubeadmConfigSpec: clusterConfiguration: diff --git a/examples/resources/spectrocloud_cluster_custom_cloud/resource.tf b/examples/resources/spectrocloud_cluster_custom_cloud/resource.tf index dd0b5721..1ed54c7c 100644 --- a/examples/resources/spectrocloud_cluster_custom_cloud/resource.tf +++ b/examples/resources/spectrocloud_cluster_custom_cloud/resource.tf @@ -12,7 +12,7 @@ locals { } # Node Pool config variables node_pool_config_variables = { - MASTER_NODE_POOL_NAME = "master-pool" + CP_NODE_POOL_NAME = "cp-pool" CLUSTER_NAME = local.cloud_config_override_variables["CLUSTER_NAME"] CONTROL_PLANE_ENDPOINT_IP = local.cloud_config_override_variables["CONTROL_PLANE_ENDPOINT_IP"] NUTANIX_SSH_AUTHORIZED_KEY = "ssh -a test-test" @@ -71,7 +71,7 @@ resource "spectrocloud_cluster_custom_cloud" "cluster_nutanix" { machine_pool { control_plane = true control_plane_as_worker = true - node_pool_config = templatefile("config_templates/master_pool_config.yaml", local.node_pool_config_variables) + node_pool_config = templatefile("config_templates/cp_pool_config.yaml", local.node_pool_config_variables) } machine_pool { diff --git a/examples/resources/spectrocloud_cluster_tke/resource.tf b/examples/resources/spectrocloud_cluster_tke/resource.tf index 2f4f0301..1efd5cae 100644 --- a/examples/resources/spectrocloud_cluster_tke/resource.tf +++ b/examples/resources/spectrocloud_cluster_tke/resource.tf @@ -52,7 +52,7 @@ resource "spectrocloud_cluster_tke" "cluster" { ssh_key_name = var.tke_ssh_key_name region = var.tke_region vpc_id = var.tke_vpc_id - az_subnets = var.master_tke_subnets_map + az_subnets = var.cp_tke_subnets_map } machine_pool { diff --git a/examples/resources/spectrocloud_cluster_tke/terraform.template.tfvars b/examples/resources/spectrocloud_cluster_tke/terraform.template.tfvars index de4d0426..5446c8c8 100644 --- a/examples/resources/spectrocloud_cluster_tke/terraform.template.tfvars +++ b/examples/resources/spectrocloud_cluster_tke/terraform.template.tfvars @@ -7,7 +7,7 @@ sc_trace = false tke_ssh_key_name = "{enter Spectro Cloud ssh key for tke}" tke_region = "{enter region name for tke cluster}" tke_vpc_id = "{enter tke vpc id}" -master_tke_subnets_map = { +cp_tke_subnets_map = { "{enter subnet key}" : "{enter subnet id}" } worker_tke_subnets_map = { diff --git a/examples/resources/spectrocloud_cluster_tke/variables.tf b/examples/resources/spectrocloud_cluster_tke/variables.tf index a3d0766a..9f6a45d2 100644 --- a/examples/resources/spectrocloud_cluster_tke/variables.tf +++ b/examples/resources/spectrocloud_cluster_tke/variables.tf @@ -6,5 +6,5 @@ variable "sc_trace" {} variable "tke_ssh_key_name" {} variable "tke_region" {} variable "tke_vpc_id" {} -variable "master_tke_subnets_map" {} +variable "cp_tke_subnets_map" {} variable "worker_tke_subnets_map" {} diff --git a/spectrocloud/cluster_common_hash.go b/spectrocloud/cluster_common_hash.go index bb3190f4..1e73539b 100644 --- a/spectrocloud/cluster_common_hash.go +++ b/spectrocloud/cluster_common_hash.go @@ -181,7 +181,7 @@ func resourceMachinePoolEksHash(v interface{}) int { func resourceMachinePoolGkeHash(v interface{}) int { m := v.(map[string]interface{}) buf := CommonHash(m) - if _, ok := m["disk_size_gb"]; ok { + if _, ok := m["disk_size_gb"]; ok { buf.WriteString(fmt.Sprintf("%d-", m["disk_size_gb"].(int))) } buf.WriteString(fmt.Sprintf("%s-", m["instance_type"].(string))) diff --git a/spectrocloud/data_source_cloud_account_aws.go b/spectrocloud/data_source_cloud_account_aws.go index c7d7a088..af8da960 100644 --- a/spectrocloud/data_source_cloud_account_aws.go +++ b/spectrocloud/data_source_cloud_account_aws.go @@ -18,14 +18,14 @@ func dataSourceCloudAccountAws() *schema.Resource { Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeString, - Description: "ID of the AWS cloud account registered in Palette.", + Description: "ID of the AWS cloud account registered in Palette.", Optional: true, Computed: true, ExactlyOneOf: []string{"id", "name"}, }, "name": { Type: schema.TypeString, - Description: "Name of the AWS cloud account registered in Palette.", + Description: "Name of the AWS cloud account registered in Palette.", Optional: true, Computed: true, ExactlyOneOf: []string{"id", "name"}, diff --git a/spectrocloud/data_source_cloud_account_azure.go b/spectrocloud/data_source_cloud_account_azure.go index b9d5c3a7..54f9f49e 100644 --- a/spectrocloud/data_source_cloud_account_azure.go +++ b/spectrocloud/data_source_cloud_account_azure.go @@ -17,38 +17,38 @@ func dataSourceCloudAccountAzure() *schema.Resource { Schema: map[string]*schema.Schema{ "azure_tenant_id": { - Type: schema.TypeString, + Type: schema.TypeString, Description: "The tenant ID of the Azure cloud account registered in Palette.", - Computed: true, + Computed: true, }, "azure_client_id": { - Type: schema.TypeString, + Type: schema.TypeString, Description: "The unique client ID from Azure Management Portal.", - Computed: true, + Computed: true, }, "id": { Type: schema.TypeString, - Description: "ID of the Azure cloud account registered in Palette.", + Description: "ID of the Azure cloud account registered in Palette.", Optional: true, Computed: true, ExactlyOneOf: []string{"id", "name"}, }, "name": { Type: schema.TypeString, - Description: "Name of the Azure cloud account registered in Palette.", + Description: "Name of the Azure cloud account registered in Palette.", Optional: true, Computed: true, ExactlyOneOf: []string{"id", "name"}, }, "tenant_name": { Description: "The name of the Azure tenant.", - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, }, "disable_properties_request": { - Type: schema.TypeBool, + Type: schema.TypeBool, Description: "The status of the disable properties option.", - Computed: true, + Computed: true, }, }, } diff --git a/spectrocloud/data_source_cloud_account_gcp.go b/spectrocloud/data_source_cloud_account_gcp.go index 7769bd11..a4108a14 100644 --- a/spectrocloud/data_source_cloud_account_gcp.go +++ b/spectrocloud/data_source_cloud_account_gcp.go @@ -18,14 +18,14 @@ func dataSourceCloudAccountGcp() *schema.Resource { Schema: map[string]*schema.Schema{ "id": { Type: schema.TypeString, - Description: "ID of the GCP cloud account registered in Palette.", + Description: "ID of the GCP cloud account registered in Palette.", Optional: true, Computed: true, ExactlyOneOf: []string{"id", "name"}, }, "name": { Type: schema.TypeString, - Description: "Name of the GCP cloud account registered in Palette.", + Description: "Name of the GCP cloud account registered in Palette.", Optional: true, Computed: true, ExactlyOneOf: []string{"id", "name"}, diff --git a/spectrocloud/data_source_pack.go b/spectrocloud/data_source_pack.go index e6d18079..675b1910 100644 --- a/spectrocloud/data_source_pack.go +++ b/spectrocloud/data_source_pack.go @@ -20,54 +20,54 @@ func dataSourcePack() *schema.Resource { "filters": { Type: schema.TypeString, Optional: true, - Description: "Filters to apply when searching for a pack. This is a string of the form 'key1=value1' with 'AND', 'OR` operators. Refer to the Palette API [pack search API endpoint documentation](https://docs.spectrocloud.com/api/v1/v-1-packs-search/) for filter examples..", + Description: "Filters to apply when searching for a pack. This is a string of the form 'key1=value1' with 'AND', 'OR` operators. Refer to the Palette API [pack search API endpoint documentation](https://docs.spectrocloud.com/api/v1/v-1-packs-search/) for filter examples..", ConflictsWith: []string{"id", "cloud", "name", "version", "registry_uid"}, }, "id": { Type: schema.TypeString, Computed: true, Optional: true, - Description: "The UID of the pack returned.", + Description: "The UID of the pack returned.", ConflictsWith: []string{"filters", "cloud", "name", "version", "registry_uid"}, }, "name": { - Type: schema.TypeString, + Type: schema.TypeString, Description: "The name of the pack to search for.", - Computed: true, - Optional: true, + Computed: true, + Optional: true, }, "cloud": { - Type: schema.TypeSet, - Optional: true, - Computed: true, + Type: schema.TypeSet, + Optional: true, + Computed: true, Description: "Filter results by cloud type. If not provided, all cloud types are returned.", - Set: schema.HashString, + Set: schema.HashString, Elem: &schema.Schema{ Type: schema.TypeString, }, }, "version": { - Type: schema.TypeString, + Type: schema.TypeString, Description: "The version of the pack to search for.", - Computed: true, - Optional: true, + Computed: true, + Optional: true, }, "registry_uid": { - Type: schema.TypeString, + Type: schema.TypeString, Description: "The UID of the registry to search for the pack in. This is a required parameter starting from version 0.21.0.", - Computed: true, - Optional: true, + Computed: true, + Optional: true, }, "type": { - Type: schema.TypeString, + Type: schema.TypeString, Description: "The type of pack to search for. Supported values are `helm`, `manifest`, `container`, `operator-instance`.", - Computed: true, - Optional: true, + Computed: true, + Optional: true, }, "values": { - Type: schema.TypeString, + Type: schema.TypeString, Description: "The YAML values of the pack returned as string.", - Computed: true, + Computed: true, }, }, } diff --git a/spectrocloud/resource_cluster_aws_test.go b/spectrocloud/resource_cluster_aws_test.go index babb6d4f..bdc8e673 100644 --- a/spectrocloud/resource_cluster_aws_test.go +++ b/spectrocloud/resource_cluster_aws_test.go @@ -13,15 +13,15 @@ func TestFlattenMachinePoolConfigsAwsSubnetIds(t *testing.T) { addLabels["by"] = "Siva" addLabels["purpose"] = "unittest" - subnetIdsMaster := make(map[string]string) - subnetIdsMaster["us-east-2a"] = "subnet-031a7ff4ff5e7fb9a" + subnetIdsCP := make(map[string]string) + subnetIdsCP["us-east-2a"] = "subnet-031a7ff4ff5e7fb9a" subnetIdsWorker := make(map[string]string) subnetIdsWorker["us-east-2a"] = "subnet-08864975df862eb58" isControl := func(b bool) *bool { return &b }(true) machinePoolConfig = append(machinePoolConfig, &models.V1AwsMachinePoolConfig{ - Name: "master-pool", + Name: "cp-pool", IsControlPlane: isControl, InstanceType: "t3.large", Size: 1, @@ -31,7 +31,7 @@ func TestFlattenMachinePoolConfigsAwsSubnetIds(t *testing.T) { UpdateStrategy: &models.V1UpdateStrategy{ Type: "", }, - SubnetIds: subnetIdsMaster, + SubnetIds: subnetIdsCP, }) machinePoolConfig = append(machinePoolConfig, &models.V1AwsMachinePoolConfig{ Name: "worker-pool", @@ -46,7 +46,7 @@ func TestFlattenMachinePoolConfigsAwsSubnetIds(t *testing.T) { machinePools := flattenMachinePoolConfigsAws(machinePoolConfig) if len(machinePools) != 2 { t.Fail() - t.Logf("Machine pool for master and worker is not returned by func - FlattenMachinePoolConfigsAws") + t.Logf("Machine pool for control-plane and worker is not returned by func - FlattenMachinePoolConfigsAws") } else { for i := range machinePools { k := machinePools[i].(map[string]interface{}) @@ -66,7 +66,7 @@ func TestFlattenMachinePoolConfigsAwsSubnetIds(t *testing.T) { t.Errorf("Machine pool - additional labels is not matching got %v, wanted %v", addLabels, k["additional_labels"]) t.Fail() } - if k["name"] == "master-pool" { + if k["name"] == "cp-pool" { if k["control_plane_as_worker"].(bool) != machinePoolConfig[i].UseControlPlaneAsWorker { t.Errorf("Machine pool - control_plane_as_worker is not matching got %s, wanted %v", k["control_plane_as_worker"].(string), machinePoolConfig[i].UseControlPlaneAsWorker) t.Fail() @@ -75,8 +75,8 @@ func TestFlattenMachinePoolConfigsAwsSubnetIds(t *testing.T) { t.Errorf("Machine pool - disk_size_gb is not matching got %v, wanted %v", k["disk_size_gb"].(int), int(machinePoolConfig[i].RootDeviceSize)) t.Fail() } - if !validateMapString(subnetIdsMaster, k["az_subnets"].(map[string]string)) { - t.Errorf("Machine pool - additional labels is not matching got %v, wanted %v", subnetIdsMaster, k["az_subnets"]) + if !validateMapString(subnetIdsCP, k["az_subnets"].(map[string]string)) { + t.Errorf("Machine pool - additional labels is not matching got %v, wanted %v", subnetIdsCP, k["az_subnets"]) t.Fail() } @@ -101,7 +101,7 @@ func TestFlattenMachinePoolConfigsAwsAZ(t *testing.T) { isControl := func(b bool) *bool { return &b }(true) machinePoolConfig = append(machinePoolConfig, &models.V1AwsMachinePoolConfig{ - Name: "master", + Name: "cp", IsControlPlane: isControl, InstanceType: "t3.xlarge", Size: 1, @@ -126,7 +126,7 @@ func TestFlattenMachinePoolConfigsAwsAZ(t *testing.T) { machinePools := flattenMachinePoolConfigsAws(machinePoolConfig) if len(machinePools) != 2 { t.Fail() - t.Logf("Machine pool for master and worker is not returned by func - FlattenMachinePoolConfigsAws") + t.Logf("Machine pool for control-plane and worker is not returned by func - FlattenMachinePoolConfigsAws") } else { for i := range machinePools { k := machinePools[i].(map[string]interface{}) @@ -150,7 +150,7 @@ func TestFlattenMachinePoolConfigsAwsAZ(t *testing.T) { t.Errorf("Machine pool - AZS is not matching got %v, wanted %v", azs, k["azs"]) t.Fail() } - if k["name"] == "master-pool" { + if k["name"] == "cp-pool" { if k["control_plane_as_worker"].(bool) != machinePoolConfig[i].UseControlPlaneAsWorker { t.Errorf("Machine pool - control_plane_as_worker is not matching got %s, wanted %v", k["control_plane_as_worker"].(string), machinePoolConfig[i].UseControlPlaneAsWorker) t.Fail() diff --git a/spectrocloud/resource_cluster_azure.go b/spectrocloud/resource_cluster_azure.go index bcc0a403..cb771cb9 100644 --- a/spectrocloud/resource_cluster_azure.go +++ b/spectrocloud/resource_cluster_azure.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/spectrocloud/hapi/models" "github.com/spectrocloud/palette-sdk-go/client" ) @@ -354,7 +355,7 @@ func resourceClusterAzureCreate(ctx context.Context, d *schema.ResourceData, m i if err != nil { return diag.FromErr(err) } - diags = validateMasterPoolCount(cluster.Spec.Machinepoolconfig) + diags = validateCPPoolCount(cluster.Spec.Machinepoolconfig) if diags != nil { return diags } @@ -540,7 +541,7 @@ func resourceClusterAzureUpdate(ctx context.Context, d *schema.ResourceData, m i if err != nil { return diag.FromErr(err) } - diags = validateMasterPoolCount(cluster.Spec.Machinepoolconfig) + diags = validateCPPoolCount(cluster.Spec.Machinepoolconfig) if diags != nil { return diags } @@ -762,11 +763,11 @@ func toMachinePoolAzure(machinePool interface{}) (*models.V1AzureMachinePoolConf return mp, nil } -func validateMasterPoolCount(machinePool []*models.V1AzureMachinePoolConfigEntity) diag.Diagnostics { +func validateCPPoolCount(machinePool []*models.V1AzureMachinePoolConfigEntity) diag.Diagnostics { for _, machineConfig := range machinePool { if machineConfig.PoolConfig.IsControlPlane { if *machineConfig.PoolConfig.Size%2 == 0 { - return diag.FromErr(fmt.Errorf("The master node pool size should be in an odd number. But it set to an even number '%d' in node name '%s' ", *machineConfig.PoolConfig.Size, *machineConfig.PoolConfig.Name)) + return diag.FromErr(fmt.Errorf("The control-plane node pool size should be in an odd number. But it set to an even number '%d' in node name '%s' ", *machineConfig.PoolConfig.Size, *machineConfig.PoolConfig.Name)) } } } diff --git a/spectrocloud/resource_cluster_azure_test.go b/spectrocloud/resource_cluster_azure_test.go index 336b0035..3f84bc99 100644 --- a/spectrocloud/resource_cluster_azure_test.go +++ b/spectrocloud/resource_cluster_azure_test.go @@ -1,14 +1,16 @@ package spectrocloud import ( - "github.com/spectrocloud/gomi/pkg/ptr" "sort" "testing" + "github.com/spectrocloud/gomi/pkg/ptr" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/spectrocloud/hapi/models" "github.com/spectrocloud/palette-sdk-go/client" - "github.com/stretchr/testify/assert" "github.com/spectrocloud/terraform-provider-spectrocloud/types" ) @@ -132,17 +134,17 @@ func TestToStaticPlacement(t *testing.T) { assert.Equal(t, expected, c) } -func TestValidateMasterPoolCount(t *testing.T) { - // Test case 1: Even master pool size - masterConfig1 := &models.V1AzureMachinePoolConfigEntity{ +func TestValidateCPPoolCount(t *testing.T) { + // Test case 1: Even control-plane pool size + cpConfig1 := &models.V1AzureMachinePoolConfigEntity{ PoolConfig: &models.V1MachinePoolConfigEntity{ IsControlPlane: true, Size: types.Ptr(int32(4)), - Name: types.Ptr("master1"), + Name: types.Ptr("cp1"), }, } - // Test case 2: Non-master pool + // Test case 2: Non-cp pool workerConfig := &models.V1AzureMachinePoolConfigEntity{ PoolConfig: &models.V1MachinePoolConfigEntity{ IsControlPlane: false, @@ -152,7 +154,7 @@ func TestValidateMasterPoolCount(t *testing.T) { } // Test case 3: Non-control plane pool with odd size - nonMasterConfig := &models.V1AzureMachinePoolConfigEntity{ + nonCPConfig := &models.V1AzureMachinePoolConfigEntity{ PoolConfig: &models.V1MachinePoolConfigEntity{ IsControlPlane: false, Size: types.Ptr(int32(7)), @@ -161,13 +163,13 @@ func TestValidateMasterPoolCount(t *testing.T) { } machinePool := []*models.V1AzureMachinePoolConfigEntity{ - masterConfig1, + cpConfig1, workerConfig, - nonMasterConfig, + nonCPConfig, } // Run the function and capture the diagnostics - diagnostics := validateMasterPoolCount(machinePool) + diagnostics := validateCPPoolCount(machinePool) // Test case 1 should return an error, so diagnostics should not be nil assert.NotNil(t, diagnostics, "Test case 1 failed: Expected diagnostics to be non-nil") diff --git a/spectrocloud/resource_cluster_custom_cloud_test.go b/spectrocloud/resource_cluster_custom_cloud_test.go index 6513df41..1dd4610b 100644 --- a/spectrocloud/resource_cluster_custom_cloud_test.go +++ b/spectrocloud/resource_cluster_custom_cloud_test.go @@ -2,11 +2,13 @@ package spectrocloud import ( "context" + "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/spectrocloud/gomi/pkg/ptr" "github.com/spectrocloud/hapi/models" "github.com/spectrocloud/palette-sdk-go/client" - "testing" "github.com/stretchr/testify/assert" ) @@ -46,7 +48,7 @@ func TestFlattenCloudConfigCustom(t *testing.T) { mps = append(mps, &models.V1CustomMachinePoolConfig{ AdditionalLabels: nil, IsControlPlane: ptr.BoolPtr(true), - Name: "master-pool", + Name: "cp-pool", Size: 1, Taints: nil, UseControlPlaneAsWorker: true, @@ -230,7 +232,7 @@ func TestResourceClusterCustomCloudUpdate(t *testing.T) { mps = append(mps, &models.V1CustomMachinePoolConfig{ AdditionalLabels: nil, IsControlPlane: ptr.BoolPtr(true), - Name: "master-pool", + Name: "cp-pool", Size: 1, Taints: nil, UseControlPlaneAsWorker: true, diff --git a/spectrocloud/resource_cluster_edge_native_test.go b/spectrocloud/resource_cluster_edge_native_test.go index ddb2bbb1..f25da711 100644 --- a/spectrocloud/resource_cluster_edge_native_test.go +++ b/spectrocloud/resource_cluster_edge_native_test.go @@ -1,11 +1,13 @@ package spectrocloud import ( - "github.com/stretchr/testify/assert" "reflect" "testing" + "github.com/stretchr/testify/assert" + "github.com/google/go-cmp/cmp" + "github.com/spectrocloud/hapi/models" "github.com/spectrocloud/terraform-provider-spectrocloud/types" @@ -287,7 +289,7 @@ func TestToMachinePoolEdgeNative(t *testing.T) { t.Errorf("Expected %v, got %v", expected, result) } if !cmp.Equal(result.PoolConfig.Labels[0], "control-plane") { - t.Errorf("Unexpected result (-want +got):\n%s", cmp.Diff(result.PoolConfig.Labels[0], "master")) + t.Errorf("Unexpected result (-want +got):\n%s", cmp.Diff(result.PoolConfig.Labels[0], "control-plane")) } }) diff --git a/spectrocloud/resource_cluster_eks.go b/spectrocloud/resource_cluster_eks.go index 702f64a3..0df9c2f4 100644 --- a/spectrocloud/resource_cluster_eks.go +++ b/spectrocloud/resource_cluster_eks.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/spectrocloud/hapi/models" "github.com/spectrocloud/palette-sdk-go/client" ) @@ -479,7 +480,7 @@ func flattenClusterConfigsEKS(cloudConfig *models.V1EksCloudConfig) interface{} } for _, pool := range cloudConfig.Spec.MachinePoolConfig { - if pool.Name == "master-pool" { + if pool.Name == "cp-pool" { ret["az_subnets"] = pool.SubnetIds } } @@ -786,7 +787,7 @@ func toEksCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectro // Following same logic as UI for setting up control plane for managed cluster cpPool := map[string]interface{}{ "control_plane": true, - "name": "master-pool", + "name": "cp-pool", "az_subnets": cloudConfig["az_subnets"], "capacity_type": "spot", "count": 0, diff --git a/spectrocloud/resource_cluster_eks_flatten_test.go b/spectrocloud/resource_cluster_eks_flatten_test.go index 26ae2f19..e986b8c9 100644 --- a/spectrocloud/resource_cluster_eks_flatten_test.go +++ b/spectrocloud/resource_cluster_eks_flatten_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/spectrocloud/hapi/models" "github.com/spectrocloud/terraform-provider-spectrocloud/types" @@ -149,7 +150,7 @@ func TestFlattenClusterConfigsEKS(t *testing.T) { }, MachinePoolConfig: []*models.V1EksMachinePoolConfig{ { - Name: "master-pool", + Name: "cp-pool", SubnetIds: map[string]string{"subnet-12345678": "subnet-87654321"}, }, }, @@ -211,7 +212,7 @@ func TestFlattenClusterConfigsEKSPrivateCIDRS(t *testing.T) { }, MachinePoolConfig: []*models.V1EksMachinePoolConfig{ { - Name: "master-pool", + Name: "cp-pool", SubnetIds: map[string]string{"subnet-12345678": "subnet-87654321"}, }, }, diff --git a/spectrocloud/resource_cluster_libvirt.go b/spectrocloud/resource_cluster_libvirt.go index 354d7204..223e79bb 100644 --- a/spectrocloud/resource_cluster_libvirt.go +++ b/spectrocloud/resource_cluster_libvirt.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/spectrocloud/hapi/models" "github.com/spectrocloud/palette-sdk-go/client" ) @@ -784,9 +785,9 @@ func toMachinePoolLibvirt(machinePool interface{}) (*models.V1LibvirtMachinePool addDisks := getAdditionalDisks(ins) updateStrategyType := getUpdateStrategy(m) - if m["name"].(string) == "master-pool" && updateStrategyType == "RollingUpdateScaleIn" { - // If master pool has RollingUpdateScaleIn as an update strategy, return an error - return nil, fmt.Errorf("update strategy RollingUpdateScaleIn is not allowed for the 'master-pool' machine pool") + if m["name"].(string) == "cp-pool" && updateStrategyType == "RollingUpdateScaleIn" { + // If control-plane pool has RollingUpdateScaleIn as an update strategy, return an error + return nil, fmt.Errorf("update strategy RollingUpdateScaleIn is not allowed for the 'cp-pool' machine pool") } var xlstemplate string diff --git a/spectrocloud/resource_cluster_mass_test.go b/spectrocloud/resource_cluster_mass_test.go index b4ef5637..e3448c91 100644 --- a/spectrocloud/resource_cluster_mass_test.go +++ b/spectrocloud/resource_cluster_mass_test.go @@ -6,6 +6,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/spectrocloud/hapi/models" "github.com/spectrocloud/palette-sdk-go/client" @@ -186,7 +187,7 @@ func TestToMaasCluster(t *testing.T) { mpools := []interface{}{ map[string]interface{}{ "control_plane": true, - "name": "mass_mp_master", + "name": "mass_mp_cp", "count": 2, "update_strategy": "RollingUpdateScaleOut", "max": 3, diff --git a/spectrocloud/resource_cluster_tke.go b/spectrocloud/resource_cluster_tke.go index 314b1f3b..02f6a0ce 100644 --- a/spectrocloud/resource_cluster_tke.go +++ b/spectrocloud/resource_cluster_tke.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/spectrocloud/hapi/models" "github.com/spectrocloud/palette-sdk-go/client" ) @@ -558,7 +559,7 @@ func toTkeCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectro machinePoolConfigs := make([]*models.V1TencentMachinePoolConfigEntity, 0) /*cpPool := map[string]interface{}{ "control_plane": true, - "name": "master-pool", + "name": "cp-pool", "az_subnets": cloudConfig["az_subnets"], "instance_type": "S3.LARGE8", "disk_size_gb": 60, diff --git a/spectrocloud/resource_cluster_vsphere_test.go b/spectrocloud/resource_cluster_vsphere_test.go index e54b489c..6f70c5b6 100644 --- a/spectrocloud/resource_cluster_vsphere_test.go +++ b/spectrocloud/resource_cluster_vsphere_test.go @@ -63,9 +63,9 @@ func prepareClusterVsphereTestData() *schema.ResourceData { mPools := make([]map[string]interface{}, 0) - // Adding Master pool - masterPlacement := make([]interface{}, 0) - masterPlacement = append(masterPlacement, map[string]interface{}{ + // Adding control-plane pool + cpPlacement := make([]interface{}, 0) + cpPlacement = append(cpPlacement, map[string]interface{}{ "id": "", "cluster": "test cluster", "resource_pool": "Default", @@ -73,8 +73,8 @@ func prepareClusterVsphereTestData() *schema.ResourceData { "network": "VM Network", "static_ip_pool_id": "testpoolid", }) - masterInstance := make([]interface{}, 0) - masterInstance = append(masterInstance, map[string]interface{}{ + cpInstance := make([]interface{}, 0) + cpInstance = append(cpInstance, map[string]interface{}{ "disk_size_gb": 40, "memory_mb": 8192, "cpu": 4, @@ -82,10 +82,10 @@ func prepareClusterVsphereTestData() *schema.ResourceData { mPools = append(mPools, map[string]interface{}{ "control_plane": true, "control_plane_as_worker": true, - "name": "master-pool", + "name": "cp-pool", "count": 1, - "placement": masterPlacement, - "instance_type": masterInstance, + "placement": cpPlacement, + "instance_type": cpInstance, "node": []interface{}{}, }) @@ -160,29 +160,29 @@ func TestToVsphereCluster(t *testing.T) { assert.Equal(2, len(vSphereSchema.Spec.CloudConfig.SSHKeys)) assert.Equal(false, vSphereSchema.Spec.CloudConfig.StaticIP) - // Verifying Master pool attributes + // Verifying control-plane pool attributes assert.Equal(2, len(vSphereSchema.Spec.Machinepoolconfig)) - masterPoolIndex := 0 + cpPoolIndex := 0 workerPoolIndex := 1 - if *vSphereSchema.Spec.Machinepoolconfig[0].PoolConfig.Name == "master-pool" { - masterPoolIndex = 0 + if *vSphereSchema.Spec.Machinepoolconfig[0].PoolConfig.Name == "cp-pool" { + cpPoolIndex = 0 workerPoolIndex = 1 } else { - masterPoolIndex = 1 + cpPoolIndex = 1 workerPoolIndex = 0 } - assert.Equal("master-pool", *vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].PoolConfig.Name) - assert.Equal(true, vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].PoolConfig.IsControlPlane) - assert.Equal(int32(40), *vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].CloudConfig.InstanceType.DiskGiB) - assert.Equal(int64(8192), *vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].CloudConfig.InstanceType.MemoryMiB) - assert.Equal(int32(4), *vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].CloudConfig.InstanceType.NumCPUs) - assert.Equal("test cluster", vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].CloudConfig.Placements[0].Cluster) - assert.Equal("datastore55_2", vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].CloudConfig.Placements[0].Datastore) - assert.Equal("Default", vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].CloudConfig.Placements[0].ResourcePool) - assert.Equal("VM Network", *vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].CloudConfig.Placements[0].Network.NetworkName) - assert.Equal("testpoolid", vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].CloudConfig.Placements[0].Network.ParentPoolUID) - assert.Equal(true, vSphereSchema.Spec.Machinepoolconfig[masterPoolIndex].CloudConfig.Placements[0].Network.StaticIP) + assert.Equal("cp-pool", *vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].PoolConfig.Name) + assert.Equal(true, vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].PoolConfig.IsControlPlane) + assert.Equal(int32(40), *vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].CloudConfig.InstanceType.DiskGiB) + assert.Equal(int64(8192), *vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].CloudConfig.InstanceType.MemoryMiB) + assert.Equal(int32(4), *vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].CloudConfig.InstanceType.NumCPUs) + assert.Equal("test cluster", vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].CloudConfig.Placements[0].Cluster) + assert.Equal("datastore55_2", vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].CloudConfig.Placements[0].Datastore) + assert.Equal("Default", vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].CloudConfig.Placements[0].ResourcePool) + assert.Equal("VM Network", *vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].CloudConfig.Placements[0].Network.NetworkName) + assert.Equal("testpoolid", vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].CloudConfig.Placements[0].Network.ParentPoolUID) + assert.Equal(true, vSphereSchema.Spec.Machinepoolconfig[cpPoolIndex].CloudConfig.Placements[0].Network.StaticIP) // Verifying Worker pool attributes assert.Equal("worker-basic", *vSphereSchema.Spec.Machinepoolconfig[workerPoolIndex].PoolConfig.Name) diff --git a/templates/resources/cluster_custom_cloud.md.tmpl b/templates/resources/cluster_custom_cloud.md.tmpl index b590e8a9..dab13476 100644 --- a/templates/resources/cluster_custom_cloud.md.tmpl +++ b/templates/resources/cluster_custom_cloud.md.tmpl @@ -48,7 +48,7 @@ description: |- } control_plane = true control_plane_as_worker = true - node_pool_config = templatefile("config_templates/master_pool_config.yaml", local.node_pool_config_variables) + node_pool_config = templatefile("config_templates/cp_pool_config.yaml", local.node_pool_config_variables) } machine_pool {