diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e747e730..693eec61 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,39 +22,6 @@ env: CODE_COVERAGE_ARTIFACT_NAME: "code-coverage" jobs: - runner_test: - name: "Test STACKIT runner" - runs-on: stackit-docker - steps: - - name: Install needed tools - run: | - apt-get -y -qq update - apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget - - - name: Setup Go - uses: actions/setup-go@v6 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Install go tools - run: | - go install golang.org/x/tools/cmd/goimports@latest - go install github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework@latest - go install github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi@latest - - - name: Setup JAVA - uses: actions/setup-java@v5 - with: - distribution: 'temurin' # See 'Supported distributions' for available options - java-version: '21' - - - name: Checkout - uses: actions/checkout@v6 - - - name: Run build pkg directory - run: | - go run cmd/main.go build - publish_test: name: "Test readiness for publishing provider" needs: config @@ -137,67 +104,11 @@ jobs: --gpgPubKeyFile=public_key.pem \ --version=${VERSION} - testing: - name: CI run tests - runs-on: ubuntu-latest - needs: config - env: - TF_ACC_PROJECT_ID: ${{ vars.TF_ACC_PROJECT_ID }} - TF_ACC_REGION: ${{ vars.TF_ACC_REGION }} - TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL: ${{ vars.TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL }} - TF_ACC_SERVICE_ACCOUNT_FILE: "~/service_account.json" - steps: - - name: Checkout - uses: actions/checkout@v6 - - name: Build - uses: ./.github/actions/build - with: - go-version: ${{ env.GO_VERSION }} - - - name: Setup Terraform - uses: hashicorp/setup-terraform@v2 - with: - terraform_wrapper: false - - - name: Create service account json file - if: ${{ github.event_name == 'pull_request' }} - run: | - echo "${{ secrets.TF_ACC_SERVICE_ACCOUNT_JSON }}" >~/service_account.json - - - name: Run go mod tidy - if: ${{ github.event_name == 'pull_request' }} - run: go mod tidy - - - name: Testing - run: make test - - - name: Acceptance Testing - env: - TF_ACC: "1" - if: ${{ github.event_name == 'pull_request' }} - run: make test-acceptance-tf - - - name: Check coverage threshold - shell: bash - run: | - make coverage - COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//') - echo "Coverage: $COVERAGE%" - if (( $(echo "$COVERAGE < 80" | bc -l) )); then - echo "Coverage is below 80%" - # exit 1 - fi - - - name: Archive code coverage results - uses: actions/upload-artifact@v4 - with: - name: ${{ env.CODE_COVERAGE_ARTIFACT_NAME }} - path: "stackit/${{ env.CODE_COVERAGE_FILE_NAME }}" main: if: ${{ github.event_name != 'schedule' }} - name: CI run build and linting + name: CI runs-on: ubuntu-latest needs: config steps: @@ -226,37 +137,31 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v9 with: - version: v2.9 + version: v2.7 args: --config=golang-ci.yaml --allow-parallel-runners --timeout=5m - continue-on-error: true - - name: Linting + - name: Lint run: make lint - continue-on-error: true -# - name: Testing -# run: make test -# -# - name: Acceptance Testing -# if: ${{ github.event_name == 'pull_request' }} -# run: make test-acceptance-tf -# -# - name: Check coverage threshold -# shell: bash -# run: | -# make coverage -# COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//') -# echo "Coverage: $COVERAGE%" -# if (( $(echo "$COVERAGE < 80" | bc -l) )); then -# echo "Coverage is below 80%" -# # exit 1 -# fi + - name: Test + run: make test -# - name: Archive code coverage results -# uses: actions/upload-artifact@v4 -# with: -# name: ${{ env.CODE_COVERAGE_ARTIFACT_NAME }} -# path: "stackit/${{ env.CODE_COVERAGE_FILE_NAME }}" + - name: Check coverage threshold + shell: bash + run: | + make coverage + COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//') + echo "Coverage: $COVERAGE%" + if (( $(echo "$COVERAGE < 80" | bc -l) )); then + echo "Coverage is below 80%" + # exit 1 + fi + + - name: Archive code coverage results + uses: actions/upload-artifact@v4 + with: + name: ${{ env.CODE_COVERAGE_ARTIFACT_NAME }} + path: "stackit/${{ env.CODE_COVERAGE_FILE_NAME }}" config: if: ${{ github.event_name != 'schedule' }} diff --git a/.github/workflows/runnerstats.yaml b/.github/workflows/runnerstats.yaml deleted file mode 100644 index 08190d4c..00000000 --- a/.github/workflows/runnerstats.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: Runner stats - -on: - workflow_dispatch: - -jobs: - stats-own: - name: "Get own runner stats" - runs-on: ubuntu-latest - steps: - - name: Install needed tools - run: | - apt-get -y -qq update - apt-get -y -qq install inxi - - - name: Show stats - run: inxi -c 0 - - stats-stackit: - name: "Get STACKIT runner stats" - runs-on: stackit-docker - steps: - - name: Install needed tools - run: | - apt-get -y -qq update - apt-get -y -qq install inxi - - - name: Show stats - run: inxi -c 0 diff --git a/.gitignore b/.gitignore index 1dac2ea3..c588a0f1 100644 --- a/.gitignore +++ b/.gitignore @@ -46,5 +46,3 @@ dist pkg_gen /release/ -.env -**/.env diff --git a/Makefile b/Makefile index 680cf020..f678f099 100644 --- a/Makefile +++ b/Makefile @@ -12,10 +12,9 @@ project-tools: # LINT lint-golangci-lint: @echo "Linting with golangci-lint" - @go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint run --fix --config golang-ci.yaml + @$(SCRIPTS_BASE)/lint-golangci-lint.sh - -lint-tf: +lint-tf: @echo "Linting terraform files" @terraform fmt -check -diff -recursive @@ -24,7 +23,6 @@ lint: lint-golangci-lint lint-tf # DOCUMENTATION GENERATION generate-docs: @echo "Generating documentation with tfplugindocs" - @$(SCRIPTS_BASE)/tfplugindocs.sh build: @@ -39,12 +37,12 @@ fmt: .PHONY: test coverage test: @echo "Running tests for the terraform provider" - @cd $(ROOT_DIR)/stackit && go test -timeout 0 ./... -count=1 -coverprofile=../coverage.out && cd $(ROOT_DIR) + @cd $(ROOT_DIR)/stackit && go test ./... -count=1 -coverprofile=../coverage.out && cd $(ROOT_DIR) # Test coverage coverage: @echo ">> Creating test coverage report for the terraform provider" - @cd $(ROOT_DIR)/stackit && (go test -timeout 0 ./... -count=1 -coverprofile=../coverage.out || true) && cd $(ROOT_DIR) + @cd $(ROOT_DIR)/stackit && (go test ./... -count=1 -coverprofile=../coverage.out || true) && cd $(ROOT_DIR) @cd $(ROOT_DIR)/stackit && go tool cover -html=../coverage.out -o ../coverage.html && cd $(ROOT_DIR) test-acceptance-tf: diff --git a/cmd/cmd/build/build.go b/cmd/cmd/build/build.go index 7b11f214..c80401fa 100644 --- a/cmd/cmd/build/build.go +++ b/cmd/cmd/build/build.go @@ -60,7 +60,7 @@ func (b *Builder) Build() error { if !b.PackagesOnly { slog.Info(" ... Checking needed commands available") - err := checkCommands([]string{}) + err := checkCommands([]string{"tfplugingen-framework", "tfplugingen-openapi"}) if err != nil { return err } @@ -111,7 +111,7 @@ func (b *Builder) Build() error { } slog.Info("Creating OAS dir") - err = os.MkdirAll(path.Join(genDir, "oas"), 0o755) //nolint:gosec // this dir is not sensitive, so we can use 0755 + err = os.MkdirAll(path.Join(genDir, "oas"), 0755) if err != nil { return err } @@ -158,17 +158,7 @@ func (b *Builder) Build() error { if err = cmd.Wait(); err != nil { var exitErr *exec.ExitError if errors.As(err, &exitErr) { - slog.Error( - "cmd.Wait", - "code", - exitErr.ExitCode(), - "error", - err, - "stdout", - stdOut.String(), - "stderr", - stdErr.String(), - ) + slog.Error("cmd.Wait", "code", exitErr.ExitCode(), "error", err, "stdout", stdOut.String(), "stderr", stdErr.String()) return fmt.Errorf("%s", stdErr.String()) } if err != nil { @@ -202,11 +192,7 @@ func (b *Builder) Build() error { } slog.Info("Rearranging package directories") - //nolint:gosec // this dir is not sensitive, so we can use 0755 - err = os.MkdirAll( - path.Join(*root, "pkg_gen"), - 0o755, - ) + err = os.MkdirAll(path.Join(*root, "pkg_gen"), 0755) // noqa:gosec if err != nil { return err } @@ -216,20 +202,19 @@ func (b *Builder) Build() error { return err } for _, item := range items { - if !item.IsDir() { - continue - } - slog.Info(" -> package", "name", item.Name()) - tgtDir := path.Join(*root, "pkg_gen", item.Name()) - if fileExists(tgtDir) { - delErr := os.RemoveAll(tgtDir) - if delErr != nil { - return delErr + if item.IsDir() { + slog.Info(" -> package", "name", item.Name()) + tgtDir := path.Join(*root, "pkg_gen", item.Name()) + if fileExists(tgtDir) { + delErr := os.RemoveAll(tgtDir) + if delErr != nil { + return delErr + } + } + err = os.Rename(path.Join(srcDir, item.Name()), tgtDir) + if err != nil { + return err } - } - err = os.Rename(path.Join(srcDir, item.Name()), tgtDir) - if err != nil { - return err } } @@ -290,8 +275,8 @@ type templateData struct { Fields []string } -func fileExists(pathValue string) bool { - _, err := os.Stat(pathValue) +func fileExists(path string) bool { + _, err := os.Stat(path) if os.IsNotExist(err) { return false } @@ -327,22 +312,10 @@ func createBoilerplate(rootFolder, folder string) error { resourceName := res.Name() - dsFile := path.Join( - folder, - svc.Name(), - res.Name(), - "datasources_gen", - fmt.Sprintf("%s_data_source_gen.go", res.Name()), - ) + dsFile := path.Join(folder, svc.Name(), res.Name(), "datasources_gen", fmt.Sprintf("%s_data_source_gen.go", res.Name())) handleDS = fileExists(dsFile) - resFile := path.Join( - folder, - svc.Name(), - res.Name(), - "resources_gen", - fmt.Sprintf("%s_resource_gen.go", res.Name()), - ) + resFile := path.Join(folder, svc.Name(), res.Name(), "resources_gen", fmt.Sprintf("%s_resource_gen.go", res.Name())) handleRes = fileExists(resFile) dsGoFile := path.Join(folder, svc.Name(), res.Name(), "datasource.go") @@ -434,6 +407,7 @@ func createBoilerplate(rootFolder, folder string) error { if err != nil { return err } + } } } @@ -442,7 +416,7 @@ func createBoilerplate(rootFolder, folder string) error { } func ucfirst(s string) string { - if s == "" { + if len(s) == 0 { return "" } return strings.ToUpper(s[:1]) + s[1:] @@ -477,8 +451,8 @@ func writeTemplateToFile(tplName, tplFile, outFile string, data *templateData) e } func generateServiceFiles(rootDir, generatorDir string) error { - //nolint:gosec // this file is not sensitive, so we can use 0755 - err := os.MkdirAll(path.Join(rootDir, "generated", "specs"), 0o755) + // slog.Info("Generating specs folder") + err := os.MkdirAll(path.Join(rootDir, "generated", "specs"), 0755) if err != nil { return err } @@ -516,6 +490,7 @@ func generateServiceFiles(rootDir, generatorDir string) error { continue } + // slog.Info("Checking spec", "name", spec.Name()) r := regexp.MustCompile(`^(.*)_config.yml$`) matches := r.FindAllStringSubmatch(specFile.Name(), -1) if matches != nil { @@ -531,44 +506,27 @@ func generateServiceFiles(rootDir, generatorDir string) error { resource, ) - oasFile := path.Join( - generatorDir, - "oas", - fmt.Sprintf("%s%s.json", service.Name(), svcVersion.Name()), - ) + oasFile := path.Join(generatorDir, "oas", fmt.Sprintf("%s%s.json", service.Name(), svcVersion.Name())) if _, oasErr := os.Stat(oasFile); os.IsNotExist(oasErr) { - slog.Warn( - " could not find matching oas", - "svc", - service.Name(), - "version", - svcVersion.Name(), - ) + slog.Warn(" could not find matching oas", "svc", service.Name(), "version", svcVersion.Name()) continue } scName := fmt.Sprintf("%s%s", service.Name(), svcVersion.Name()) scName = strings.ReplaceAll(scName, "-", "") - //nolint:gosec // this file is not sensitive, so we can use 0755 - err = os.MkdirAll(path.Join(rootDir, "generated", "internal", "services", scName, resource), 0o755) + err = os.MkdirAll(path.Join(rootDir, "generated", "internal", "services", scName, resource), 0755) if err != nil { return err } - specJsonFile := path.Join( - rootDir, - "generated", - "specs", - fmt.Sprintf("%s_%s_spec.json", scName, resource), - ) + // slog.Info("Generating openapi spec json") + specJsonFile := path.Join(rootDir, "generated", "specs", fmt.Sprintf("%s_%s_spec.json", scName, resource)) var stdOut, stdErr bytes.Buffer - // nolint:gosec // #nosec this command is not using any untrusted input, so we can ignore gosec warning + // noqa:gosec cmd := exec.Command( - "go", - "run", - "github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi", + "tfplugingen-openapi", "generate", "--config", path.Join(rootDir, "service_specs", service.Name(), svcVersion.Name(), fileName), @@ -595,29 +553,11 @@ func generateServiceFiles(rootDir, generatorDir string) error { if err = cmd.Wait(); err != nil { var exitErr *exec.ExitError if errors.As(err, &exitErr) { - slog.Error( - "tfplugingen-openapi generate", - "code", - exitErr.ExitCode(), - "error", - err, - "stdout", - stdOut.String(), - "stderr", - stdErr.String(), - ) + slog.Error("tfplugingen-openapi generate", "code", exitErr.ExitCode(), "error", err, "stdout", stdOut.String(), "stderr", stdErr.String()) return fmt.Errorf("%s", stdErr.String()) } if err != nil { - slog.Error( - "tfplugingen-openapi generate", - "err", - err, - "stdout", - stdOut.String(), - "stderr", - stdErr.String(), - ) + slog.Error("tfplugingen-openapi generate", "err", err, "stdout", stdOut.String(), "stderr", stdErr.String()) return err } } @@ -625,26 +565,18 @@ func generateServiceFiles(rootDir, generatorDir string) error { slog.Warn(" command output", "stdout", stdOut.String(), "stderr", stdErr.String()) } - tgtFolder := path.Join( - rootDir, - "generated", - "internal", - "services", - scName, - resource, - "resources_gen", - ) - //nolint:gosec // this file is not sensitive, so we can use 0755 - err = os.MkdirAll(tgtFolder, 0o755) + // slog.Info("Creating terraform svc resource files folder") + tgtFolder := path.Join(rootDir, "generated", "internal", "services", scName, resource, "resources_gen") + err = os.MkdirAll(tgtFolder, 0755) if err != nil { return err } - // nolint:gosec // #nosec this command is not using any untrusted input, so we can ignore gosec warning + // slog.Info("Generating terraform svc resource files") + + // noqa:gosec cmd2 := exec.Command( - "go", - "run", - "github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework", + "tfplugingen-framework", "generate", "resources", "--input", @@ -665,53 +597,27 @@ func generateServiceFiles(rootDir, generatorDir string) error { if err = cmd2.Wait(); err != nil { var exitErr *exec.ExitError if errors.As(err, &exitErr) { - slog.Error( - "tfplugingen-framework generate resources", - "code", - exitErr.ExitCode(), - "error", - err, - "stdout", - stdOut.String(), - "stderr", - stdErr.String(), - ) + slog.Error("tfplugingen-framework generate resources", "code", exitErr.ExitCode(), "error", err, "stdout", stdOut.String(), "stderr", stdErr.String()) return fmt.Errorf("%s", stdErr.String()) } if err != nil { - slog.Error( - "tfplugingen-framework generate resources", - "err", - err, - "stdout", - stdOut.String(), - "stderr", - stdErr.String(), - ) + slog.Error("tfplugingen-framework generate resources", "err", err, "stdout", stdOut.String(), "stderr", stdErr.String()) return err } } - tgtFolder = path.Join( - rootDir, - "generated", - "internal", - "services", - scName, - resource, - "datasources_gen", - ) - //nolint:gosec // this directory is not sensitive, so we can use 0755 - err = os.MkdirAll(tgtFolder, 0o755) + // slog.Info("Creating terraform svc datasource files folder") + tgtFolder = path.Join(rootDir, "generated", "internal", "services", scName, resource, "datasources_gen") + err = os.MkdirAll(tgtFolder, 0755) if err != nil { return err } - // nolint:gosec // #nosec this command is not using any untrusted input, so we can ignore gosec warning + // slog.Info("Generating terraform svc resource files") + + // noqa:gosec cmd3 := exec.Command( - "go", - "run", - "github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework", + "tfplugingen-framework", "generate", "data-sources", "--input", @@ -733,29 +639,11 @@ func generateServiceFiles(rootDir, generatorDir string) error { if err = cmd3.Wait(); err != nil { var exitErr *exec.ExitError if errors.As(err, &exitErr) { - slog.Error( - "tfplugingen-framework generate data-sources", - "code", - exitErr.ExitCode(), - "error", - err, - "stdout", - stdOut.String(), - "stderr", - stdErr.String(), - ) + slog.Error("tfplugingen-framework generate data-sources", "code", exitErr.ExitCode(), "error", err, "stdout", stdOut.String(), "stderr", stdErr.String()) return fmt.Errorf("%s", stdErr.String()) } if err != nil { - slog.Error( - "tfplugingen-framework generate data-sources", - "err", - err, - "stdout", - stdOut.String(), - "stderr", - stdErr.String(), - ) + slog.Error("tfplugingen-framework generate data-sources", "err", err, "stdout", stdOut.String(), "stderr", stdErr.String()) return err } } @@ -786,10 +674,10 @@ func handleTfTagForDatasourceFile(filePath, service, resource string) error { if err != nil { return err } + defer f.Close() root, err := getRoot() if err != nil { - //nolint:gocritic // in this case, we want to log the error and exit, as we cannot proceed without the root directory log.Fatal(err) } @@ -797,6 +685,7 @@ func handleTfTagForDatasourceFile(filePath, service, resource string) error { if err != nil { return err } + defer tmp.Close() sc := bufio.NewScanner(f) for sc.Scan() { @@ -804,7 +693,7 @@ func handleTfTagForDatasourceFile(filePath, service, resource string) error { if err != nil { return err } - if _, err := tmp.WriteString(resLine + "\n"); err != nil { + if _, err := io.WriteString(tmp, resLine+"\n"); err != nil { return err } } @@ -820,7 +709,6 @@ func handleTfTagForDatasourceFile(filePath, service, resource string) error { return err } - //nolint:gosec // path traversal is not a concern here if err := os.Rename(tmp.Name(), filePath); err != nil { log.Fatal(err) } @@ -885,23 +773,13 @@ func copyFile(src, dst string) (int64, error) { if err != nil { return 0, err } - defer func(source *os.File) { - err := source.Close() - if err != nil { - slog.Error("copyFile", "err", err) - } - }(source) + defer source.Close() destination, err := os.Create(dst) if err != nil { return 0, err } - defer func(destination *os.File) { - err := destination.Close() - if err != nil { - slog.Error("copyFile", "err", err) - } - }(destination) + defer destination.Close() nBytes, err := io.Copy(destination, source) return nBytes, err } @@ -912,8 +790,10 @@ func getOnlyLatest(m map[string]version) (map[string]version, error) { item, ok := tmpMap[k] if !ok { tmpMap[k] = v - } else if item.major == v.major && item.minor < v.minor { - tmpMap[k] = v + } else { + if item.major == v.major && item.minor < v.minor { + tmpMap[k] = v + } } } return tmpMap, nil @@ -927,19 +807,18 @@ func getVersions(dir string) (map[string]version, error) { } for _, entry := range children { - if !entry.IsDir() { - continue - } - versions, err := os.ReadDir(path.Join(dir, "services", entry.Name())) - if err != nil { - return nil, err - } - m, err2 := extractVersions(entry.Name(), versions) - if err2 != nil { - return m, err2 - } - for k, v := range m { - res[k] = v + if entry.IsDir() { + versions, err := os.ReadDir(path.Join(dir, "services", entry.Name())) + if err != nil { + return nil, err + } + m, err2 := extractVersions(entry.Name(), versions) + if err2 != nil { + return m, err2 + } + for k, v := range m { + res[k] = v + } } } return res, nil @@ -948,21 +827,20 @@ func getVersions(dir string) (map[string]version, error) { func extractVersions(service string, versionDirs []os.DirEntry) (map[string]version, error) { res := make(map[string]version) for _, vDir := range versionDirs { - if !vDir.IsDir() { - continue - } - r := regexp.MustCompile(`v(\d+)([a-z]+)(\d*)`) - matches := r.FindAllStringSubmatch(vDir.Name(), -1) - if matches == nil { - continue - } - svc, ver, err := handleVersion(service, matches[0]) - if err != nil { - return nil, err - } + if vDir.IsDir() { + r := regexp.MustCompile(`v([0-9]+)([a-z]+)([0-9]*)`) + matches := r.FindAllStringSubmatch(vDir.Name(), -1) + if matches == nil { + continue + } + svc, ver, err := handleVersion(service, matches[0]) + if err != nil { + return nil, err + } - if svc != nil && ver != nil { - res[*svc] = *ver + if svc != nil && ver != nil { + res[*svc] = *ver + } } } return res, nil @@ -1049,25 +927,30 @@ func getTokens(fileName string) ([]string, error) { return nil, err } - ast.Inspect( - node, func(n ast.Node) bool { - // Suche nach Typ-Deklarationen (structs) - ts, ok := n.(*ast.TypeSpec) - if ok { - if strings.Contains(ts.Name.Name, "Model") { - ast.Inspect( - ts, func(sn ast.Node) bool { - tts, tok := sn.(*ast.Field) - if tok { - result = append(result, tts.Names[0].String()) - } - return true - }, - ) - } + ast.Inspect(node, func(n ast.Node) bool { + // Suche nach Typ-Deklarationen (structs) + ts, ok := n.(*ast.TypeSpec) + if ok { + if strings.Contains(ts.Name.Name, "Model") { + // fmt.Printf("found model: %s\n", ts.Name.Name) + ast.Inspect(ts, func(sn ast.Node) bool { + tts, tok := sn.(*ast.Field) + if tok { + // fmt.Printf(" found: %+v\n", tts.Names[0]) + // spew.Dump(tts.Type) + + result = append(result, tts.Names[0].String()) + + //fld, fldOk := tts.Type.(*ast.Ident) + //if fldOk { + // fmt.Printf("type: %+v\n", fld) + //} + } + return true + }) } - return true - }, - ) + } + return true + }) return result, nil } diff --git a/cmd/cmd/build/copy.go b/cmd/cmd/build/copy.go index e1243c05..ec0affe9 100644 --- a/cmd/cmd/build/copy.go +++ b/cmd/cmd/build/copy.go @@ -3,7 +3,6 @@ package build import ( "fmt" "io" - "log/slog" "os" "path/filepath" "syscall" @@ -75,24 +74,14 @@ func Copy(srcFile, dstFile string) error { return err } - defer func(out *os.File) { - err := out.Close() - if err != nil { - slog.Error("failed to close file", slog.Any("err", err)) - } - }(out) + defer out.Close() in, err := os.Open(srcFile) if err != nil { return err } - defer func(in *os.File) { - err := in.Close() - if err != nil { - slog.Error("error closing destination file", slog.Any("err", err)) - } - }(in) + defer in.Close() _, err = io.Copy(out, in) if err != nil { diff --git a/cmd/cmd/build/templates/resource_scaffold.gotmpl b/cmd/cmd/build/templates/resource_scaffold.gotmpl index 3fafc10c..8b612f9c 100644 --- a/cmd/cmd/build/templates/resource_scaffold.gotmpl +++ b/cmd/cmd/build/templates/resource_scaffold.gotmpl @@ -39,14 +39,11 @@ type {{.NameCamel}}Resource struct{ providerData core.ProviderData } -// resourceModel represents the Terraform resource state -type resourceModel = {{.PackageName}}.{{.NamePascal}}Model - type {{.NamePascal}}ResourceIdentityModel struct { ProjectID types.String `tfsdk:"project_id"` Region types.String `tfsdk:"region"` // TODO: implement further needed parts - {{.NamePascal}}ID types.String `tfsdk:"{{.NameSnake}}_id"` + {{.NamePascal}}ID types.String `tfsdk:"instance_id"` } // Metadata defines terraform resource name @@ -54,9 +51,6 @@ func (r *{{.NameCamel}}Resource) Metadata(ctx context.Context, req resource.Meta resp.TypeName = req.ProviderTypeName + "_{{.PackageName}}_{{.NameSnake}}" } -//go:embed planModifiers.yaml -var modifiersFileByte []byte - // Schema loads the schema from generated files and adds plan modifiers func (r *{{.NameCamel}}Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { schema = {{.PackageName}}ResGen.{{.NamePascal}}ResourceSchema(ctx) @@ -88,7 +82,6 @@ func (r *instanceResource) IdentitySchema(_ context.Context, _ resource.Identity "instance_id": identityschema.StringAttribute{ RequiredForImport: true, // can be defaulted by the provider configuration }, - // TODO: implement remaining schema parts }, } } @@ -167,6 +160,9 @@ func (r *{{.NameCamel}}Resource) ModifyPlan( } } +//go:embed planModifiers.yaml +var modifiersFileByte []byte + // Create creates a new resource func (r *{{.NameCamel}}Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data {{.PackageName}}ResGen.{{.NamePascal}}Model @@ -184,7 +180,6 @@ func (r *{{.NameCamel}}Resource) Create(ctx context.Context, req resource.Create region := data.Region.ValueString() ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "region", region) - // TODO: add remaining fields // TODO: Create API call logic /* diff --git a/cmd/cmd/buildCmd.go b/cmd/cmd/buildCmd.go index e3e8e7ae..8902132e 100644 --- a/cmd/cmd/buildCmd.go +++ b/cmd/cmd/buildCmd.go @@ -2,7 +2,6 @@ package cmd import ( "github.com/spf13/cobra" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/cmd/cmd/build" ) @@ -16,7 +15,7 @@ var buildCmd = &cobra.Command{ Use: "build", Short: "Build the necessary boilerplate", Long: `...`, - RunE: func(_ *cobra.Command, _ []string) error { + RunE: func(cmd *cobra.Command, args []string) error { b := build.Builder{ SkipClone: skipClone, SkipCleanup: skipCleanup, @@ -30,7 +29,7 @@ func NewBuildCmd() *cobra.Command { return buildCmd } -func init() { //nolint:gochecknoinits // This is the standard way to set up Cobra commands +func init() { // nolint: gochecknoinits buildCmd.Flags().BoolVarP(&skipCleanup, "skip-clean", "c", false, "Skip cleanup steps") buildCmd.Flags().BoolVarP(&skipClone, "skip-clone", "g", false, "Skip cloning from git") buildCmd.Flags().BoolVarP(&packagesOnly, "packages-only", "p", false, "Only generate packages") diff --git a/cmd/cmd/examplesCmd.go b/cmd/cmd/examplesCmd.go deleted file mode 100644 index a4c75962..00000000 --- a/cmd/cmd/examplesCmd.go +++ /dev/null @@ -1,114 +0,0 @@ -package cmd - -import ( - "fmt" - "os" - "path" - - "github.com/spf13/cobra" -) - -var examplesCmd = &cobra.Command{ - Use: "examples", - Short: "create examples", - Long: `...`, - RunE: func(_ *cobra.Command, _ []string) error { - // filePathStr := "stackit/internal/services/postgresflexalpha/database/datasources_gen/database_data_source_gen.go" - // - // src, err := os.ReadFile(filePathStr) - // if err != nil { - // return err - //} - // - // i := interp.New( - // interp.Options{ - // GoPath: "/home/henselinm/.asdf/installs/golang/1.25.6/packages", - // BuildTags: nil, - // Stdin: nil, - // Stdout: nil, - // Stderr: nil, - // Args: nil, - // Env: nil, - // SourcecodeFilesystem: nil, - // Unrestricted: false, - // }, - //) - // err = i.Use(i.Symbols("github.com/hashicorp/terraform-plugin-framework-validators")) - // if err != nil { - // return err - //} - // err = i.Use(stdlib.Symbols) - // if err != nil { - // return err - //} - // _, err = i.Eval(string(src)) - // if err != nil { - // return err - //} - // - // v, err := i.Eval("DatabaseDataSourceSchema") - // if err != nil { - // return err - //} - // - // bar := v.Interface().(func(string) string) - // - // r := bar("Kung") - // println(r) - // - // evalPath, err := i.EvalPath(filePathStr) - // if err != nil { - // return err - //} - // - // fmt.Printf("%+v\n", evalPath) - - // _, err = i.Eval(`import "fmt"`) - // if err != nil { - // return err - //} - // _, err = i.Eval(`func Hallo() { fmt.Println("Hi!") }`) - // if err != nil { - // return err - //} - - // v = i.Symbols("Hallo") - - // fmt.Println(v) - return workServices() - }, -} - -func workServices() error { - startPath := path.Join("stackit", "internal", "services") - - services, err := os.ReadDir(startPath) - if err != nil { - return err - } - - for _, entry := range services { - if !entry.IsDir() { - continue - } - resources, err := os.ReadDir(path.Join(startPath, entry.Name())) - if err != nil { - return err - } - for _, res := range resources { - if !res.IsDir() { - continue - } - fmt.Println("Gefunden:", startPath, "subdir", entry.Name(), "resource", res.Name()) - } - } - return nil -} - -func NewExamplesCmd() *cobra.Command { - return examplesCmd -} - -// func init() { // nolint: gochecknoinits -// examplesCmd.Flags().BoolVarP(&example, "example", "e", false, "example") -//} diff --git a/cmd/cmd/getFieldsCmd.go b/cmd/cmd/getFieldsCmd.go index 06fe9e66..f24db87d 100644 --- a/cmd/cmd/getFieldsCmd.go +++ b/cmd/cmd/getFieldsCmd.go @@ -24,7 +24,7 @@ var getFieldsCmd = &cobra.Command{ Use: "get-fields", Short: "get fields from file", Long: `...`, - PreRunE: func(_ *cobra.Command, _ []string) error { + PreRunE: func(cmd *cobra.Command, args []string) error { typeStr := "data_source" if resType != "resource" && resType != "datasource" { return fmt.Errorf("--type can only be resource or datasource") @@ -75,14 +75,14 @@ var getFieldsCmd = &cobra.Command{ filePath = p //// Enum check - // switch format { - // case "json", "yaml": + //switch format { + //case "json", "yaml": //default: // return fmt.Errorf("invalid --format: %s (want json|yaml)", format) //} return nil }, - RunE: func(_ *cobra.Command, _ []string) error { + RunE: func(cmd *cobra.Command, args []string) error { return getFields(filePath) }, } @@ -107,26 +107,31 @@ func getTokens(fileName string) ([]string, error) { return nil, err } - ast.Inspect( - node, func(n ast.Node) bool { - // Suche nach Typ-Deklarationen (structs) - ts, ok := n.(*ast.TypeSpec) - if ok { - if strings.Contains(ts.Name.Name, "Model") { - ast.Inspect( - ts, func(sn ast.Node) bool { - tts, tok := sn.(*ast.Field) - if tok { - result = append(result, tts.Names[0].String()) - } - return true - }, - ) - } + ast.Inspect(node, func(n ast.Node) bool { + // Suche nach Typ-Deklarationen (structs) + ts, ok := n.(*ast.TypeSpec) + if ok { + if strings.Contains(ts.Name.Name, "Model") { + // fmt.Printf("found model: %s\n", ts.Name.Name) + ast.Inspect(ts, func(sn ast.Node) bool { + tts, tok := sn.(*ast.Field) + if tok { + // fmt.Printf(" found: %+v\n", tts.Names[0]) + // spew.Dump(tts.Type) + + result = append(result, tts.Names[0].String()) + + //fld, fldOk := tts.Type.(*ast.Ident) + //if fldOk { + // fmt.Printf("type: %+v\n", fld) + //} + } + return true + }) } - return true - }, - ) + } + return true + }) return result, nil } @@ -134,15 +139,9 @@ func NewGetFieldsCmd() *cobra.Command { return getFieldsCmd } -func init() { //nolint:gochecknoinits //this is the only way to add the command to the rootCmd +func init() { // nolint: gochecknoinits getFieldsCmd.Flags().StringVarP(&inFile, "infile", "i", "", "input filename incl path") getFieldsCmd.Flags().StringVarP(&svcName, "service", "s", "", "service name") getFieldsCmd.Flags().StringVarP(&resName, "resource", "r", "", "resource name") - getFieldsCmd.Flags().StringVarP( - &resType, - "type", - "t", - "resource", - "resource type (data-source or resource [default])", - ) + getFieldsCmd.Flags().StringVarP(&resType, "type", "t", "resource", "resource type (data-source or resource [default])") } diff --git a/cmd/cmd/publish/architecture.go b/cmd/cmd/publish/architecture.go index 7316a03d..f77188c3 100644 --- a/cmd/cmd/publish/architecture.go +++ b/cmd/cmd/publish/architecture.go @@ -35,27 +35,36 @@ type GpgPublicKey struct { } func (p *Provider) CreateArchitectureFiles() error { + // var namespace, provider, distPath, repoName, version, gpgFingerprint, gpgPubKeyFile, domain string + log.Println("* Creating architecture files in target directories") + // filename = terraform-provider-[provider]_0.0.1_darwin_amd64.zip - provider_name + version + target + architecture + .zip + // prefix := fmt.Sprintf("v1/providers/%s/%s/%s/", namespace, provider, version) prefix := path.Join("v1", "providers", p.Namespace, p.Provider, p.Version) + // pathPrefix := fmt.Sprintf("release/%s", prefix) pathPrefix := path.Join("release", prefix) + // urlPrefix := fmt.Sprintf("https://%s/%s", domain, prefix) urlPrefix, err := url.JoinPath("https://", p.Domain, prefix) if err != nil { return fmt.Errorf("error creating base url: %w", err) } + // download url = https://example.com/v1/providers/namespace/provider/0.0.1/download/terraform-provider_0.0.1_darwin_amd64.zip downloadUrlPrefix, err := url.JoinPath(urlPrefix, "download") if err != nil { return fmt.Errorf("error crearting download url: %w", err) } downloadPathPrefix := path.Join(pathPrefix, "download") + // shasums url = https://example.com/v1/providers/namespace/provider/0.0.1/terraform-provider_0.0.1_SHA256SUMS shasumsUrl, err := url.JoinPath(urlPrefix, fmt.Sprintf("%s_%s_SHA256SUMS", p.RepoName, p.Version)) if err != nil { return fmt.Errorf("error creating shasums url: %w", err) } + // shasums_signature_url = https://example.com/v1/providers/namespace/provider/0.0.1/terraform-provider_0.0.1_SHA256SUMS.sig shasumsSigUrl := shasumsUrl + ".sig" gpgAsciiPub, err := p.ReadGpgFile() @@ -107,6 +116,33 @@ func (p *Provider) CreateArchitectureFiles() error { }, }, } + // var architectureTemplate = []byte(fmt.Sprintf(` + //{ + // "protocols": [ + // "4.0", + // "5.1", + // "6.0" + // ], + // "os": "%s", + // "arch": "%s", + // "filename": "%s", + // "download_url": "%s", + // "shasums_url": "%s", + // "shasums_signature_url": "%s", + // "shasum": "%s", + // "signing_keys": { + // "gpg_public_keys": [ + // { + // "key_id": "%s", + // "ascii_armor": "%s", + // "trust_signature": "", + // "source": "", + // "source_url": "" + // } + // ] + // } + //} + //`, target, arch, fileName, downloadUrl, shasumsUrl, shasumsSigUrl, shasum, gpgFingerprint, gpgAsciiPub)) log.Printf(" - Arch file: %s", archFileName) @@ -124,12 +160,8 @@ func WriteArchitectureFile(filePath string, arch Architecture) error { if err != nil { return fmt.Errorf("error encoding data: %w", err) } - //nolint:gosec // this file is not sensitive, so we can use os.ModePerm - err = os.WriteFile( - filePath, - jsonString, - os.ModePerm, - ) + + err = os.WriteFile(filePath, jsonString, os.ModePerm) if err != nil { return fmt.Errorf("error writing data: %w", err) } diff --git a/cmd/cmd/publish/provider.go b/cmd/cmd/publish/provider.go index 88849eb0..36d7af1d 100644 --- a/cmd/cmd/publish/provider.go +++ b/cmd/cmd/publish/provider.go @@ -161,12 +161,10 @@ func (p *Provider) createVersionsFile() error { target := fileNameSplit[2] arch := fileNameSplit[3] - version.Platforms = append( - version.Platforms, Platform{ - OS: target, - Arch: arch, - }, - ) + version.Platforms = append(version.Platforms, Platform{ + OS: target, + Arch: arch, + }) } data := Data{} @@ -208,19 +206,16 @@ func (p *Provider) CreateWellKnown() error { log.Println("* Creating .well-known directory") pathString := path.Join(p.RootPath, "release", ".well-known") - //nolint:gosec // this file is not sensitive, so we can use ModePerm err := os.MkdirAll(pathString, os.ModePerm) if err != nil && !errors.Is(err, fs.ErrExist) { return fmt.Errorf("error creating '%s' dir: %w", pathString, err) } log.Println(" - Writing to .well-known/terraform.json file") - - //nolint:gosec // this file is not sensitive, so we can use 0644 err = os.WriteFile( fmt.Sprintf("%s/terraform.json", pathString), []byte(`{"providers.v1": "/v1/providers/"}`), - 0o644, + 0644, ) if err != nil { return err @@ -229,10 +224,9 @@ func (p *Provider) CreateWellKnown() error { return nil } -func CreateDir(pathValue string) error { - log.Printf("* Creating %s directory", pathValue) - //nolint:gosec // this file is not sensitive, so we can use ModePerm - err := os.MkdirAll(pathValue, os.ModePerm) +func CreateDir(path string) error { + log.Printf("* Creating %s directory", path) + err := os.MkdirAll(path, os.ModePerm) if errors.Is(err, fs.ErrExist) { return nil } @@ -275,23 +269,13 @@ func CopyFile(src, dst string) (int64, error) { if err != nil { return 0, err } - defer func(source *os.File) { - err := source.Close() - if err != nil { - slog.Error("error closing source file", slog.Any("err", err)) - } - }(source) + defer source.Close() destination, err := os.Create(dst) if err != nil { return 0, err } - defer func(destination *os.File) { - err := destination.Close() - if err != nil { - slog.Error("error closing destination file", slog.Any("err", err)) - } - }(destination) + defer destination.Close() nBytes, err := io.Copy(destination, source) return nBytes, err } diff --git a/cmd/cmd/publish/templates/Caddyfile b/cmd/cmd/publish/templates/Caddyfile deleted file mode 100644 index 5663fbf8..00000000 --- a/cmd/cmd/publish/templates/Caddyfile +++ /dev/null @@ -1,38 +0,0 @@ -{ - log { - level debug - } - - - filesystem tf s3 { - bucket "terraform-provider-privatepreview" - region eu01 - endpoint https://object.storage.eu01.onstackit.cloud - use_path_style - } -} - -tfregistry.sysops.stackit.rocks { - encode zstd gzip - - handle_path /docs/* { - root /srv/www - templates - - @md { - file {path} - path *.md - } - - rewrite @md /markdown.html - - file_server { - browse - } - } - - file_server { - fs tf - browse - } -} diff --git a/cmd/cmd/publish/versions.go b/cmd/cmd/publish/versions.go index 5f75d45d..397afa15 100644 --- a/cmd/cmd/publish/versions.go +++ b/cmd/cmd/publish/versions.go @@ -35,12 +35,7 @@ func (d *Data) WriteToFile(filePath string) error { return fmt.Errorf("error encoding data: %w", err) } - //nolint:gosec // this file is not sensitive, so we can use os.ModePerm - err = os.WriteFile( - filePath, - jsonString, - os.ModePerm, - ) + err = os.WriteFile(filePath, jsonString, os.ModePerm) if err != nil { return fmt.Errorf("error writing data: %w", err) } @@ -91,13 +86,7 @@ func (d *Data) LoadFromUrl(uri string) error { if err != nil { return err } - defer func(name string) { - //nolint:gosec // The file path is generated by os.CreateTemp and is not user-controllable - err := os.Remove(name) - if err != nil { - slog.Error("failed to remove temporary file", slog.Any("err", err)) - } - }(file.Name()) // Clean up + defer os.Remove(file.Name()) // Clean up err = DownloadFile( u.String(), @@ -134,30 +123,20 @@ func (v *Version) AddProtocol(p string) error { // DownloadFile will download a url and store it in local filepath. // It writes to the destination file as it downloads it, without // loading the entire file into memory. -func DownloadFile(urlValue, filepath string) error { +func DownloadFile(url string, filepath string) error { // Create the file - //nolint:gosec // path traversal is not a concern here, as the filepath is generated by us and not user input out, err := os.Create(filepath) if err != nil { return err } - defer func(out *os.File) { - err := out.Close() - if err != nil { - slog.Error("failed to close file", slog.Any("err", err)) - } - }(out) + defer out.Close() // Get the data - - //nolint:gosec,bodyclose // this is a controlled URL, not user input - resp, err := http.Get(urlValue) + resp, err := http.Get(url) if err != nil { return err } - defer func(Body io.ReadCloser) { - _ = Body.Close() - }(resp.Body) + defer resp.Body.Close() // Write the body to file _, err = io.Copy(out, resp.Body) diff --git a/cmd/cmd/publishCmd.go b/cmd/cmd/publishCmd.go index a428d436..22e3efb9 100644 --- a/cmd/cmd/publishCmd.go +++ b/cmd/cmd/publishCmd.go @@ -10,7 +10,6 @@ import ( "path/filepath" "github.com/spf13/cobra" - publish2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/cmd/cmd/publish" ) @@ -29,32 +28,20 @@ var publishCmd = &cobra.Command{ Use: "publish", Short: "Publish terraform provider", Long: `...`, - RunE: func(_ *cobra.Command, _ []string) error { + RunE: func(_ *cobra.Command, args []string) error { return publish() }, } -func init() { //nolint:gochecknoinits //this is the standard way to set up cobra commands +func init() { // nolint: gochecknoinits publishCmd.Flags().StringVarP(&namespace, "namespace", "n", "", "Namespace for the Terraform registry.") publishCmd.Flags().StringVarP(&domain, "domain", "d", "", "Domain for the Terraform registry.") publishCmd.Flags().StringVarP(&providerName, "providerName", "p", "", "ProviderName for the Terraform registry.") publishCmd.Flags().StringVarP(&distPath, "distPath", "x", "dist", "Dist Path for the Terraform registry.") publishCmd.Flags().StringVarP(&repoName, "repoName", "r", "", "RepoName for the Terraform registry.") publishCmd.Flags().StringVarP(&version, "version", "v", "", "Version for the Terraform registry.") - publishCmd.Flags().StringVarP( - &gpgFingerprint, - "gpgFingerprint", - "f", - "", - "GPG Fingerprint for the Terraform registry.", - ) - publishCmd.Flags().StringVarP( - &gpgPubKeyFile, - "gpgPubKeyFile", - "k", - "", - "GPG PubKey file name for the Terraform registry.", - ) + publishCmd.Flags().StringVarP(&gpgFingerprint, "gpgFingerprint", "f", "", "GPG Fingerprint for the Terraform registry.") + publishCmd.Flags().StringVarP(&gpgPubKeyFile, "gpgPubKeyFile", "k", "", "GPG PubKey file name for the Terraform registry.") err := publishCmd.MarkFlagRequired("namespace") if err != nil { @@ -117,7 +104,6 @@ func publish() error { // Create release dir - only the contents of this need to be uploaded to S3 log.Printf("* Creating release directory") - //nolint:gosec // this directory is not sensitive, so we can use 0750 err = os.MkdirAll(path.Join(p.RootPath, "release"), os.ModePerm) if err != nil && !errors.Is(err, fs.ErrExist) { return fmt.Errorf("error creating '%s' dir: %w", path.Join(p.RootPath, "release"), err) diff --git a/cmd/main.go b/cmd/main.go index 19fb38e0..1b80b034 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -5,9 +5,8 @@ import ( "log/slog" "os" - "github.com/SladkyCitron/slogcolor" + "github.com/MatusOllah/slogcolor" cc "github.com/ivanpirog/coloredcobra" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/cmd/cmd" ) @@ -30,7 +29,6 @@ func main() { cmd.NewBuildCmd(), cmd.NewPublishCmd(), cmd.NewGetFieldsCmd(), - cmd.NewExamplesCmd(), ) err := rootCmd.Execute() diff --git a/docs/data-sources/postgresflexalpha_database.md b/docs/data-sources/postgresflexalpha_database.md new file mode 100644 index 00000000..95c115e3 --- /dev/null +++ b/docs/data-sources/postgresflexalpha_database.md @@ -0,0 +1,38 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_postgresflexalpha_database Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_postgresflexalpha_database (Data Source) + + + +## Example Usage + +```terraform +data "stackitprivatepreview_postgresflexalpha_database" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` + + +## Schema + +### Required + +- `database_id` (Number) The ID of the database. +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `id` (String) Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`,`database_id`\".", +- `name` (String) The name of the database. +- `owner` (String) The owner of the database. +- `tf_original_api_id` (Number) The id of the database. diff --git a/docs/data-sources/postgresflexalpha_flavor.md b/docs/data-sources/postgresflexalpha_flavor.md new file mode 100644 index 00000000..24c79829 --- /dev/null +++ b/docs/data-sources/postgresflexalpha_flavor.md @@ -0,0 +1,54 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_postgresflexalpha_flavor Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_postgresflexalpha_flavor (Data Source) + + + +## Example Usage + +```terraform +data "stackitprivatepreview_postgresflexalpha_flavor" "flavor" { + project_id = var.project_id + region = var.region + cpu = 4 + ram = 16 + node_type = "Single" + storage_class = "premium-perf2-stackit" +} +``` + + +## Schema + +### Required + +- `cpu` (Number) The cpu count of the instance. +- `node_type` (String) defines the nodeType it can be either single or replica +- `project_id` (String) The cpu count of the instance. +- `ram` (Number) The memory of the instance in Gibibyte. +- `region` (String) The flavor description. +- `storage_class` (String) The memory of the instance in Gibibyte. + +### Read-Only + +- `description` (String) The flavor description. +- `flavor_id` (String) The flavor id of the instance flavor. +- `id` (String) The terraform id of the instance flavor. +- `max_gb` (Number) maximum storage which can be ordered for the flavor in Gigabyte. +- `min_gb` (Number) minimum storage which is required to order in Gigabyte. +- `storage_classes` (Attributes List) (see [below for nested schema](#nestedatt--storage_classes)) + + +### Nested Schema for `storage_classes` + +Read-Only: + +- `class` (String) +- `max_io_per_sec` (Number) +- `max_through_in_mb` (Number) diff --git a/docs/data-sources/postgresflexalpha_flavors.md b/docs/data-sources/postgresflexalpha_flavors.md new file mode 100644 index 00000000..06645bb4 --- /dev/null +++ b/docs/data-sources/postgresflexalpha_flavors.md @@ -0,0 +1,68 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_postgresflexalpha_flavors Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_postgresflexalpha_flavors (Data Source) + + + + + + +## Schema + +### Required + +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Optional + +- `page` (Number) Number of the page of items list to be returned. +- `size` (Number) Number of items to be returned on each page. +- `sort` (String) Sorting of the flavors to be returned on each page. + +### Read-Only + +- `flavors` (Attributes List) List of flavors available for the project. (see [below for nested schema](#nestedatt--flavors)) +- `pagination` (Attributes) (see [below for nested schema](#nestedatt--pagination)) + + +### Nested Schema for `flavors` + +Read-Only: + +- `cpu` (Number) The cpu count of the instance. +- `description` (String) The flavor description. +- `max_gb` (Number) maximum storage which can be ordered for the flavor in Gigabyte. +- `memory` (Number) The memory of the instance in Gibibyte. +- `min_gb` (Number) minimum storage which is required to order in Gigabyte. +- `node_type` (String) defines the nodeType it can be either single or replica +- `storage_classes` (Attributes List) maximum storage which can be ordered for the flavor in Gigabyte. (see [below for nested schema](#nestedatt--flavors--storage_classes)) +- `tf_original_api_id` (String) The id of the instance flavor. + + +### Nested Schema for `flavors.storage_classes` + +Read-Only: + +- `class` (String) +- `max_io_per_sec` (Number) +- `max_through_in_mb` (Number) + + + + +### Nested Schema for `pagination` + +Read-Only: + +- `page` (Number) +- `size` (Number) +- `sort` (String) +- `total_pages` (Number) +- `total_rows` (Number) diff --git a/docs/data-sources/postgresflexalpha_instance.md b/docs/data-sources/postgresflexalpha_instance.md new file mode 100644 index 00000000..466745a6 --- /dev/null +++ b/docs/data-sources/postgresflexalpha_instance.md @@ -0,0 +1,87 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_postgresflexalpha_instance Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_postgresflexalpha_instance (Data Source) + + + +## Example Usage + +```terraform +data "stackitprivatepreview_postgresflexalpha_instance" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` + + +## Schema + +### Required + +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `acl` (List of String) List of IPV4 cidr. +- `backup_schedule` (String) The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule. +- `connection_info` (Attributes) The DNS name and port in the instance overview (see [below for nested schema](#nestedatt--connection_info)) +- `encryption` (Attributes) The configuration for instance's volume and backup storage encryption. + +⚠︝ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected. (see [below for nested schema](#nestedatt--encryption)) +- `flavor_id` (String) The id of the instance flavor. +- `is_deletable` (Boolean) Whether the instance can be deleted or not. +- `name` (String) The name of the instance. +- `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network)) +- `replicas` (Number) How many replicas the instance should have. +- `retention_days` (Number) How long backups are retained. The value can only be between 32 and 365 days. +- `status` (String) The current status of the instance. +- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage)) +- `tf_original_api_id` (String) The ID of the instance. +- `version` (String) The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters. + + +### Nested Schema for `connection_info` + +Read-Only: + +- `host` (String) The host of the instance. +- `port` (Number) The port of the instance. + + + +### Nested Schema for `encryption` + +Read-Only: + +- `kek_key_id` (String) The encryption-key key identifier +- `kek_key_ring_id` (String) The encryption-key keyring identifier +- `kek_key_version` (String) The encryption-key version +- `service_account` (String) + + + +### Nested Schema for `network` + +Read-Only: + +- `access_scope` (String) The access scope of the instance. It defines if the instance is public or airgapped. +- `acl` (List of String) List of IPV4 cidr. +- `instance_address` (String) +- `router_address` (String) + + + +### Nested Schema for `storage` + +Read-Only: + +- `performance_class` (String) The storage class for the storage. +- `size` (Number) The storage size in Gigabytes. diff --git a/docs/data-sources/postgresflexalpha_user.md b/docs/data-sources/postgresflexalpha_user.md new file mode 100644 index 00000000..c3553c7b --- /dev/null +++ b/docs/data-sources/postgresflexalpha_user.md @@ -0,0 +1,42 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_postgresflexalpha_user Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_postgresflexalpha_user (Data Source) + + + +## Example Usage + +```terraform +data "stackitprivatepreview_postgresflexalpha_user" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + user_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` + + +## Schema + +### Required + +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed +- `user_id` (Number) The ID of the user. + +### Optional + +- `id` (String) Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`,`user_id`\".", + +### Read-Only + +- `name` (String) The name of the user. +- `roles` (List of String) A list of user roles. +- `status` (String) The current status of the user. +- `tf_original_api_id` (Number) The ID of the user. diff --git a/docs/data-sources/sqlserverflexalpha_database.md b/docs/data-sources/sqlserverflexalpha_database.md new file mode 100644 index 00000000..20e8a653 --- /dev/null +++ b/docs/data-sources/sqlserverflexalpha_database.md @@ -0,0 +1,32 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexalpha_database Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexalpha_database (Data Source) + + + + + + +## Schema + +### Required + +- `database_name` (String) The name of the database. +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `collation_name` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint. +- `compatibility_level` (Number) CompatibilityLevel of the Database. +- `id` (String) Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`,`database_id`\".", +- `name` (String) The name of the database. +- `owner` (String) The owner of the database. +- `tf_original_api_id` (Number) The id of the database. diff --git a/docs/data-sources/sqlserverflexalpha_flavor.md b/docs/data-sources/sqlserverflexalpha_flavor.md new file mode 100644 index 00000000..0dfc1fd2 --- /dev/null +++ b/docs/data-sources/sqlserverflexalpha_flavor.md @@ -0,0 +1,54 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexalpha_flavor Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexalpha_flavor (Data Source) + + + +## Example Usage + +```terraform +data "stackitprivatepreview_sqlserverflexalpha_flavor" "flavor" { + project_id = var.project_id + region = var.region + cpu = 4 + ram = 16 + node_type = "Single" + storage_class = "premium-perf2-stackit" +} +``` + + +## Schema + +### Required + +- `cpu` (Number) The cpu count of the instance. +- `node_type` (String) defines the nodeType it can be either single or replica +- `project_id` (String) The cpu count of the instance. +- `ram` (Number) The memory of the instance in Gibibyte. +- `region` (String) The flavor description. +- `storage_class` (String) The memory of the instance in Gibibyte. + +### Read-Only + +- `description` (String) The flavor description. +- `flavor_id` (String) The flavor id of the instance flavor. +- `id` (String) The terraform id of the instance flavor. +- `max_gb` (Number) maximum storage which can be ordered for the flavor in Gigabyte. +- `min_gb` (Number) minimum storage which is required to order in Gigabyte. +- `storage_classes` (Attributes List) (see [below for nested schema](#nestedatt--storage_classes)) + + +### Nested Schema for `storage_classes` + +Read-Only: + +- `class` (String) +- `max_io_per_sec` (Number) +- `max_through_in_mb` (Number) diff --git a/docs/data-sources/sqlserverflexalpha_instance.md b/docs/data-sources/sqlserverflexalpha_instance.md new file mode 100644 index 00000000..f209c424 --- /dev/null +++ b/docs/data-sources/sqlserverflexalpha_instance.md @@ -0,0 +1,78 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexalpha_instance Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexalpha_instance (Data Source) + + + +## Example Usage + +```terraform +data "stackitprivatepreview_sqlserverflexalpha_instance" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` + + +## Schema + +### Required + +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `backup_schedule` (String) The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule. +- `edition` (String) Edition of the MSSQL server instance +- `encryption` (Attributes) this defines which key to use for storage encryption (see [below for nested schema](#nestedatt--encryption)) +- `flavor_id` (String) The id of the instance flavor. +- `id` (String) Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`\". +- `is_deletable` (Boolean) Whether the instance can be deleted or not. +- `name` (String) The name of the instance. +- `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network)) +- `replicas` (Number) How many replicas the instance should have. +- `retention_days` (Number) The days for how long the backup files should be stored before cleaned up. 30 to 365 +- `status` (String) +- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage)) +- `tf_original_api_id` (String) The ID of the instance. +- `version` (String) The sqlserver version used for the instance. + + +### Nested Schema for `encryption` + +Read-Only: + +- `kek_key_id` (String) The key identifier +- `kek_key_ring_id` (String) The keyring identifier +- `kek_key_version` (String) The key version +- `service_account` (String) + + + +### Nested Schema for `network` + +Read-Only: + +- `access_scope` (String) The network access scope of the instance + +⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected. +- `acl` (List of String) List of IPV4 cidr. +- `instance_address` (String) +- `router_address` (String) + + + +### Nested Schema for `storage` + +Read-Only: + +- `class` (String) The storage class for the storage. +- `size` (Number) The storage size in Gigabytes. diff --git a/docs/data-sources/sqlserverflexalpha_user.md b/docs/data-sources/sqlserverflexalpha_user.md new file mode 100644 index 00000000..b0b15341 --- /dev/null +++ b/docs/data-sources/sqlserverflexalpha_user.md @@ -0,0 +1,44 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexalpha_user Data Source - stackitprivatepreview" +subcategory: "" +description: |- + SQLServer Flex user data source schema. Must have a region specified in the provider configuration. +--- + +# stackitprivatepreview_sqlserverflexalpha_user (Data Source) + +SQLServer Flex user data source schema. Must have a `region` specified in the provider configuration. + +## Example Usage + +```terraform +data "stackitprivatepreview_sqlserverflexalpha_user" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + user_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` + + +## Schema + +### Required + +- `instance_id` (String) ID of the SQLServer Flex instance. +- `project_id` (String) STACKIT project ID to which the instance is associated. +- `user_id` (Number) User ID. + +### Optional + +- `region` (String) The resource region. If not defined, the provider region is used. + +### Read-Only + +- `default_database` (String) +- `host` (String) +- `id` (String) Terraform's internal data source. ID. It is structured as "`project_id`,`region`,`instance_id`,`user_id`". +- `port` (Number) +- `roles` (Set of String) Database access levels for the user. +- `status` (String) +- `username` (String) Username of the SQLServer Flex instance. diff --git a/docs/data-sources/sqlserverflexbeta_database.md b/docs/data-sources/sqlserverflexbeta_database.md new file mode 100644 index 00000000..9322049f --- /dev/null +++ b/docs/data-sources/sqlserverflexbeta_database.md @@ -0,0 +1,40 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexbeta_database Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexbeta_database (Data Source) + + + +## Example Usage + +```terraform +data "stackitprivatepreview_sqlserverflexbeta_database" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + database_name = "dbname" +} +``` + + +## Schema + +### Required + +- `database_name` (String) The name of the database. +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `collation_name` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint. +- `compatibility_level` (Number) CompatibilityLevel of the Database. +- `id` (String) The terraform internal identifier. +- `name` (String) The name of the database. +- `owner` (String) The owner of the database. +- `tf_original_api_id` (Number) The id of the database. diff --git a/docs/data-sources/sqlserverflexbeta_flavor.md b/docs/data-sources/sqlserverflexbeta_flavor.md new file mode 100644 index 00000000..4d2a32f3 --- /dev/null +++ b/docs/data-sources/sqlserverflexbeta_flavor.md @@ -0,0 +1,54 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexbeta_flavor Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexbeta_flavor (Data Source) + + + +## Example Usage + +```terraform +data "stackitprivatepreview_sqlserverflexbeta_flavor" "flavor" { + project_id = var.project_id + region = var.region + cpu = 4 + ram = 16 + node_type = "Single" + storage_class = "premium-perf2-stackit" +} +``` + + +## Schema + +### Required + +- `cpu` (Number) The cpu count of the instance. +- `node_type` (String) defines the nodeType it can be either single or HA +- `project_id` (String) The project ID of the flavor. +- `ram` (Number) The memory of the instance in Gibibyte. +- `region` (String) The region of the flavor. +- `storage_class` (String) The memory of the instance in Gibibyte. + +### Read-Only + +- `description` (String) The flavor description. +- `flavor_id` (String) The id of the instance flavor. +- `id` (String) The id of the instance flavor. +- `max_gb` (Number) maximum storage which can be ordered for the flavor in Gigabyte. +- `min_gb` (Number) minimum storage which is required to order in Gigabyte. +- `storage_classes` (Attributes List) maximum storage which can be ordered for the flavor in Gigabyte. (see [below for nested schema](#nestedatt--storage_classes)) + + +### Nested Schema for `storage_classes` + +Read-Only: + +- `class` (String) +- `max_io_per_sec` (Number) +- `max_through_in_mb` (Number) diff --git a/docs/data-sources/sqlserverflexbeta_instance.md b/docs/data-sources/sqlserverflexbeta_instance.md new file mode 100644 index 00000000..431f95f1 --- /dev/null +++ b/docs/data-sources/sqlserverflexbeta_instance.md @@ -0,0 +1,77 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexbeta_instance Data Source - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexbeta_instance (Data Source) + + + +## Example Usage + +```terraform +data "stackitprivatepreview_sqlserverflexbeta_instance" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +} +``` + + +## Schema + +### Required + +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `backup_schedule` (String) The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule. +- `edition` (String) Edition of the MSSQL server instance +- `encryption` (Attributes) this defines which key to use for storage encryption (see [below for nested schema](#nestedatt--encryption)) +- `flavor_id` (String) The id of the instance flavor. +- `is_deletable` (Boolean) Whether the instance can be deleted or not. +- `name` (String) The name of the instance. +- `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network)) +- `replicas` (Number) How many replicas the instance should have. +- `retention_days` (Number) The days for how long the backup files should be stored before cleaned up. 30 to 365 +- `status` (String) +- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage)) +- `tf_original_api_id` (String) The ID of the instance. +- `version` (String) The sqlserver version used for the instance. + + +### Nested Schema for `encryption` + +Read-Only: + +- `kek_key_id` (String) The key identifier +- `kek_key_ring_id` (String) The keyring identifier +- `kek_key_version` (String) The key version +- `service_account` (String) + + + +### Nested Schema for `network` + +Read-Only: + +- `access_scope` (String) The network access scope of the instance + +⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected. +- `acl` (List of String) List of IPV4 cidr. +- `instance_address` (String) +- `router_address` (String) + + + +### Nested Schema for `storage` + +Read-Only: + +- `class` (String) The storage class for the storage. +- `size` (Number) The storage size in Gigabytes. diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..84bc25b3 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,83 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview Provider" +description: |- + +--- + +# stackitprivatepreview Provider + + + +## Example Usage + +```terraform +provider "stackitprivatepreview" { + default_region = "eu01" +} + +provider "stackitprivatepreview" { + default_region = "eu01" + service_account_key_path = "service_account.json" +} + +# Authentication + +# Key flow +provider "stackitprivatepreview" { + default_region = "eu01" + service_account_key = var.service_account_key + private_key = var.private_key +} + +# Key flow (using path) +provider "stackitprivatepreview" { + default_region = "eu01" + service_account_key_path = var.service_account_key_path + private_key_path = var.private_key_path +} +``` + + +## Schema + +### Optional + +- `authorization_custom_endpoint` (String) Custom endpoint for the Membership service +- `cdn_custom_endpoint` (String) Custom endpoint for the CDN service +- `credentials_path` (String) Path of JSON from where the credentials are read. Takes precedence over the env var `STACKIT_CREDENTIALS_PATH`. Default value is `~/.stackit/credentials.json`. +- `default_region` (String) Region will be used as the default location for regional services. Not all services require a region, some are global +- `dns_custom_endpoint` (String) Custom endpoint for the DNS service +- `enable_beta_resources` (Boolean) Enable beta resources. Default is false. +- `experiments` (List of String) Enables experiments. These are unstable features without official support. More information can be found in the README. Available Experiments: iam, routing-tables, network +- `git_custom_endpoint` (String) Custom endpoint for the Git service +- `iaas_custom_endpoint` (String) Custom endpoint for the IaaS service +- `kms_custom_endpoint` (String) Custom endpoint for the KMS service +- `loadbalancer_custom_endpoint` (String) Custom endpoint for the Load Balancer service +- `logme_custom_endpoint` (String) Custom endpoint for the LogMe service +- `mariadb_custom_endpoint` (String) Custom endpoint for the MariaDB service +- `modelserving_custom_endpoint` (String) Custom endpoint for the AI Model Serving service +- `mongodbflex_custom_endpoint` (String) Custom endpoint for the MongoDB Flex service +- `objectstorage_custom_endpoint` (String) Custom endpoint for the Object Storage service +- `observability_custom_endpoint` (String) Custom endpoint for the Observability service +- `opensearch_custom_endpoint` (String) Custom endpoint for the OpenSearch service +- `postgresflex_custom_endpoint` (String) Custom endpoint for the PostgresFlex service +- `private_key` (String) Private RSA key used for authentication, relevant for the key flow. It takes precedence over the private key that is included in the service account key. +- `private_key_path` (String) Path for the private RSA key used for authentication, relevant for the key flow. It takes precedence over the private key that is included in the service account key. +- `rabbitmq_custom_endpoint` (String) Custom endpoint for the RabbitMQ service +- `redis_custom_endpoint` (String) Custom endpoint for the Redis service +- `region` (String, Deprecated) Region will be used as the default location for regional services. Not all services require a region, some are global +- `resourcemanager_custom_endpoint` (String) Custom endpoint for the Resource Manager service +- `scf_custom_endpoint` (String) Custom endpoint for the Cloud Foundry (SCF) service +- `secretsmanager_custom_endpoint` (String) Custom endpoint for the Secrets Manager service +- `server_backup_custom_endpoint` (String) Custom endpoint for the Server Backup service +- `server_update_custom_endpoint` (String) Custom endpoint for the Server Update service +- `service_account_custom_endpoint` (String) Custom endpoint for the Service Account service +- `service_account_email` (String, Deprecated) Service account email. It can also be set using the environment variable STACKIT_SERVICE_ACCOUNT_EMAIL. It is required if you want to use the resource manager project resource. +- `service_account_key` (String) Service account key used for authentication. If set, the key flow will be used to authenticate all operations. +- `service_account_key_path` (String) Path for the service account key used for authentication. If set, the key flow will be used to authenticate all operations. +- `service_account_token` (String, Deprecated) Token used for authentication. If set, the token flow will be used to authenticate all operations. +- `service_enablement_custom_endpoint` (String) Custom endpoint for the Service Enablement API +- `ske_custom_endpoint` (String) Custom endpoint for the Kubernetes Engine (SKE) service +- `sqlserverflex_custom_endpoint` (String) Custom endpoint for the SQL Server Flex service +- `token_custom_endpoint` (String) Custom endpoint for the token API, which is used to request access tokens when using the key flow diff --git a/docs/resources/postgresflexalpha_database.md b/docs/resources/postgresflexalpha_database.md new file mode 100644 index 00000000..7834287e --- /dev/null +++ b/docs/resources/postgresflexalpha_database.md @@ -0,0 +1,47 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_postgresflexalpha_database Resource - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_postgresflexalpha_database (Resource) + + + +## Example Usage + +```terraform +resource "stackitprivatepreview_postgresflexalpha_database" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + name = "mydb" + owner = "myusername" +} + +# Only use the import statement, if you want to import an existing postgresflex database +import { + to = stackitprivatepreview_postgresflexalpha_database.import-example + id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.postgres_database_id}" +} +``` + + +## Schema + +### Required + +- `name` (String) The name of the database. + +### Optional + +- `database_id` (Number) The ID of the database. +- `instance_id` (String) The ID of the instance. +- `owner` (String) The owner of the database. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `id` (Number) The id of the database. diff --git a/docs/resources/postgresflexalpha_instance.md b/docs/resources/postgresflexalpha_instance.md new file mode 100644 index 00000000..fb735ecc --- /dev/null +++ b/docs/resources/postgresflexalpha_instance.md @@ -0,0 +1,131 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_postgresflexalpha_instance Resource - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_postgresflexalpha_instance (Resource) + + + +## Example Usage + +```terraform +resource "stackitprivatepreview_postgresflexalpha_instance" "msh-instance-only" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + name = "example-instance" + acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] + backup_schedule = "0 0 * * *" + retention_days = 30 + flavor_id = "flavor.id" + replicas = 1 + storage = { + performance_class = "premium-perf2-stackit" + size = 10 + } + encryption = { + kek_key_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + kek_key_ring_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + kek_key_version = 1 + service_account = "service@account.email" + } + network = { + acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] + access_scope = "PUBLIC" + } + version = 17 +} + +# Only use the import statement, if you want to import an existing postgresflex instance +import { + to = stackitprivatepreview_postgresflexalpha_instance.import-example + id = "${var.project_id},${var.region},${var.postgres_instance_id}" +} + +import { + to = stackitprivatepreview_postgresflexalpha_instance.import-example + identity = { + project_id = var.project_id + region = var.region + instance_id = var.postgres_instance_id + } +} +``` + + +## Schema + +### Required + +- `backup_schedule` (String) The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule. +- `flavor_id` (String) The id of the instance flavor. +- `name` (String) The name of the instance. +- `network` (Attributes) The access configuration of the instance (see [below for nested schema](#nestedatt--network)) +- `replicas` (Number) How many replicas the instance should have. +- `retention_days` (Number) How long backups are retained. The value can only be between 32 and 365 days. +- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage)) +- `version` (String) The Postgres version used for the instance. See [Versions Endpoint](/documentation/postgres-flex-service/version/v3alpha1#tag/Version) for supported version parameters. + +### Optional + +- `encryption` (Attributes) The configuration for instance's volume and backup storage encryption. + +⚠︝ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected. (see [below for nested schema](#nestedatt--encryption)) +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `acl` (List of String) List of IPV4 cidr. +- `connection_info` (Attributes) The DNS name and port in the instance overview (see [below for nested schema](#nestedatt--connection_info)) +- `id` (String) The ID of the instance. +- `is_deletable` (Boolean) Whether the instance can be deleted or not. +- `status` (String) The current status of the instance. + + +### Nested Schema for `network` + +Required: + +- `acl` (List of String) List of IPV4 cidr. + +Optional: + +- `access_scope` (String) The access scope of the instance. It defines if the instance is public or airgapped. + +Read-Only: + +- `instance_address` (String) +- `router_address` (String) + + + +### Nested Schema for `storage` + +Required: + +- `performance_class` (String) The storage class for the storage. +- `size` (Number) The storage size in Gigabytes. + + + +### Nested Schema for `encryption` + +Required: + +- `kek_key_id` (String) The encryption-key key identifier +- `kek_key_ring_id` (String) The encryption-key keyring identifier +- `kek_key_version` (String) The encryption-key version +- `service_account` (String) + + + +### Nested Schema for `connection_info` + +Read-Only: + +- `host` (String) The host of the instance. +- `port` (Number) The port of the instance. diff --git a/docs/resources/postgresflexalpha_user.md b/docs/resources/postgresflexalpha_user.md new file mode 100644 index 00000000..2ebffe71 --- /dev/null +++ b/docs/resources/postgresflexalpha_user.md @@ -0,0 +1,50 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_postgresflexalpha_user Resource - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_postgresflexalpha_user (Resource) + + + +## Example Usage + +```terraform +resource "stackitprivatepreview_postgresflexalpha_user" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + username = "username" + roles = ["role"] +} + +# Only use the import statement, if you want to import an existing postgresflex user +import { + to = stackitprivatepreview_postgresflexalpha_user.import-example + id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.user_id}" +} +``` + + +## Schema + +### Required + +- `name` (String) The name of the user. + +### Optional + +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed +- `roles` (List of String) A list containing the user roles for the instance. +- `user_id` (Number) The ID of the user. + +### Read-Only + +- `connection_string` (String) The connection string for the user to the instance. +- `id` (Number) The ID of the user. +- `password` (String) The password for the user. +- `status` (String) The current status of the user. diff --git a/docs/resources/sqlserverflexalpha_database.md b/docs/resources/sqlserverflexalpha_database.md new file mode 100644 index 00000000..fd6ba0fd --- /dev/null +++ b/docs/resources/sqlserverflexalpha_database.md @@ -0,0 +1,36 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexalpha_database Resource - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexalpha_database (Resource) + + + + + + +## Schema + +### Required + +- `name` (String) The name of the database. +- `owner` (String) The owner of the database. + +### Optional + +- `collation` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint. +- `compatibility` (Number) CompatibilityLevel of the Database. +- `database_name` (String) The name of the database. +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `collation_name` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint. +- `compatibility_level` (Number) CompatibilityLevel of the Database. +- `id` (Number) The id of the database. diff --git a/docs/resources/sqlserverflexalpha_instance.md b/docs/resources/sqlserverflexalpha_instance.md new file mode 100644 index 00000000..95e33673 --- /dev/null +++ b/docs/resources/sqlserverflexalpha_instance.md @@ -0,0 +1,103 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexalpha_instance Resource - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexalpha_instance (Resource) + + + +## Example Usage + +```terraform +resource "stackitprivatepreview_sqlserverflexalpha_instance" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + name = "example-instance" + acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] + backup_schedule = "00 00 * * *" + flavor = { + cpu = 4 + ram = 16 + } + storage = { + class = "class" + size = 5 + } + version = 2022 +} + +# Only use the import statement, if you want to import an existing sqlserverflex instance +import { + to = stackitprivatepreview_sqlserverflexalpha_instance.import-example + id = "${var.project_id},${var.region},${var.sql_instance_id}" +} +``` + + +## Schema + +### Required + +- `backup_schedule` (String) The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule. +- `flavor_id` (String) The id of the instance flavor. +- `name` (String) The name of the instance. +- `network` (Attributes) the network configuration of the instance. (see [below for nested schema](#nestedatt--network)) +- `retention_days` (Number) The days for how long the backup files should be stored before cleaned up. 30 to 365 +- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage)) +- `version` (String) The sqlserver version used for the instance. + +### Optional + +- `encryption` (Attributes) this defines which key to use for storage encryption (see [below for nested schema](#nestedatt--encryption)) +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `edition` (String) Edition of the MSSQL server instance +- `id` (String) The ID of the instance. +- `is_deletable` (Boolean) Whether the instance can be deleted or not. +- `replicas` (Number) How many replicas the instance should have. +- `status` (String) + + +### Nested Schema for `network` + +Required: + +- `acl` (List of String) List of IPV4 cidr. + +Optional: + +- `access_scope` (String) The network access scope of the instance + +⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected. + +Read-Only: + +- `instance_address` (String) +- `router_address` (String) + + + +### Nested Schema for `storage` + +Required: + +- `class` (String) The storage class for the storage. +- `size` (Number) The storage size in Gigabytes. + + + +### Nested Schema for `encryption` + +Required: + +- `kek_key_id` (String) The key identifier +- `kek_key_ring_id` (String) The keyring identifier +- `kek_key_version` (String) The key version +- `service_account` (String) diff --git a/docs/resources/sqlserverflexalpha_user.md b/docs/resources/sqlserverflexalpha_user.md new file mode 100644 index 00000000..8c5f8702 --- /dev/null +++ b/docs/resources/sqlserverflexalpha_user.md @@ -0,0 +1,53 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexalpha_user Resource - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexalpha_user (Resource) + + + +## Example Usage + +```terraform +resource "stackitprivatepreview_sqlserverflexalpha_user" "example" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + username = "username" + roles = ["role"] +} + +# Only use the import statement, if you want to import an existing sqlserverflex user +import { + to = stackitprivatepreview_sqlserverflexalpha_user.import-example + id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}" +} +``` + + +## Schema + +### Required + +- `roles` (List of String) A list containing the user roles for the instance. +- `username` (String) The name of the user. + +### Optional + +- `default_database` (String) The default database for a user of the instance. +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed +- `user_id` (Number) The ID of the user. + +### Read-Only + +- `host` (String) The host of the instance in which the user belongs to. +- `id` (Number) The ID of the user. +- `password` (String) The password for the user. +- `port` (Number) The port of the instance in which the user belongs to. +- `status` (String) The current status of the user. +- `uri` (String) The connection string for the user to the instance. diff --git a/docs/resources/sqlserverflexbeta_database.md b/docs/resources/sqlserverflexbeta_database.md new file mode 100644 index 00000000..893433fe --- /dev/null +++ b/docs/resources/sqlserverflexbeta_database.md @@ -0,0 +1,36 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexbeta_database Resource - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexbeta_database (Resource) + + + + + + +## Schema + +### Required + +- `name` (String) The name of the database. +- `owner` (String) The owner of the database. + +### Optional + +- `collation` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint. +- `compatibility` (Number) CompatibilityLevel of the Database. +- `database_name` (String) The name of the database. +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `collation_name` (String) The collation of the database. This database collation should match the *collation_name* of one of the collations given by the **Get database collation list** endpoint. +- `compatibility_level` (Number) CompatibilityLevel of the Database. +- `id` (Number) The id of the database. diff --git a/docs/resources/sqlserverflexbeta_instance.md b/docs/resources/sqlserverflexbeta_instance.md new file mode 100644 index 00000000..20f5a9bc --- /dev/null +++ b/docs/resources/sqlserverflexbeta_instance.md @@ -0,0 +1,158 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "stackitprivatepreview_sqlserverflexbeta_instance Resource - stackitprivatepreview" +subcategory: "" +description: |- + +--- + +# stackitprivatepreview_sqlserverflexbeta_instance (Resource) + + + +## Example Usage + +```terraform +# without encryption and SNA +resource "stackitprivatepreview_sqlserverflexbeta_instance" "instance" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + name = "example-instance" + backup_schedule = "0 3 * * *" + retention_days = 31 + flavor_id = "flavor_id" + storage = { + class = "premium-perf2-stackit" + size = 50 + } + version = 2022 + network = { + acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] + access_scope = "SNA" + } +} + +# without encryption and PUBLIC +resource "stackitprivatepreview_sqlserverflexbeta_instance" "instance" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + name = "example-instance" + backup_schedule = "0 3 * * *" + retention_days = 31 + flavor_id = "flavor_id" + storage = { + class = "premium-perf2-stackit" + size = 50 + } + version = 2022 + network = { + acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] + access_scope = "PUBLIC" + } +} + +# with encryption and SNA +resource "stackitprivatepreview_sqlserverflexbeta_instance" "instance" { + project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + name = "example-instance" + backup_schedule = "0 3 * * *" + retention_days = 31 + flavor_id = "flavor_id" + storage = { + class = "premium-perf2-stackit" + size = 50 + } + version = 2022 + encryption = { + kek_key_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + kek_key_ring_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + kek_key_version = 1 + service_account = "service_account@email" + } + network = { + acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] + access_scope = "SNA" + } +} + + +# Only use the import statement, if you want to import an existing sqlserverflex instance +import { + to = stackitprivatepreview_sqlserverflexalpha_instance.import-example + id = "${var.project_id},${var.region},${var.sql_instance_id}" +} + +# import with identity +import { + to = stackitprivatepreview_sqlserverflexalpha_instance.import-example + identity = { + project_id = var.project_id + region = var.region + instance_id = var.sql_instance_id + } +} +``` + + +## Schema + +### Required + +- `backup_schedule` (String) The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule. +- `flavor_id` (String) The id of the instance flavor. +- `name` (String) The name of the instance. +- `network` (Attributes) the network configuration of the instance. (see [below for nested schema](#nestedatt--network)) +- `retention_days` (Number) The days for how long the backup files should be stored before cleaned up. 30 to 365 +- `storage` (Attributes) The object containing information about the storage size and class. (see [below for nested schema](#nestedatt--storage)) +- `version` (String) The sqlserver version used for the instance. + +### Optional + +- `encryption` (Attributes) this defines which key to use for storage encryption (see [below for nested schema](#nestedatt--encryption)) +- `instance_id` (String) The ID of the instance. +- `project_id` (String) The STACKIT project ID. +- `region` (String) The region which should be addressed + +### Read-Only + +- `edition` (String) Edition of the MSSQL server instance +- `id` (String) The ID of the instance. +- `is_deletable` (Boolean) Whether the instance can be deleted or not. +- `replicas` (Number) How many replicas the instance should have. +- `status` (String) + + +### Nested Schema for `network` + +Required: + +- `acl` (List of String) List of IPV4 cidr. + +Optional: + +- `access_scope` (String) The network access scope of the instance + +⚠️ **Note:** This feature is in private preview. Supplying this object is only permitted for enabled accounts. If your account does not have access, the request will be rejected. + +Read-Only: + +- `instance_address` (String) +- `router_address` (String) + + + +### Nested Schema for `storage` + +Required: + +- `class` (String) The storage class for the storage. +- `size` (Number) The storage size in Gigabytes. + + + +### Nested Schema for `encryption` + +Required: + +- `kek_key_id` (String) The key identifier +- `kek_key_ring_id` (String) The keyring identifier +- `kek_key_version` (String) The key version +- `service_account` (String) diff --git a/examples/resources/stackitprivatepreview_postgresflexalpha_database/resource.tf b/examples/resources/stackitprivatepreview_postgresflexalpha_database/resource.tf index ad0c051e..a013b9c6 100644 --- a/examples/resources/stackitprivatepreview_postgresflexalpha_database/resource.tf +++ b/examples/resources/stackitprivatepreview_postgresflexalpha_database/resource.tf @@ -9,14 +9,4 @@ resource "stackitprivatepreview_postgresflexalpha_database" "example" { import { to = stackitprivatepreview_postgresflexalpha_database.import-example id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.postgres_database_id}" -} - -import { - to = stackitprivatepreview_postgresflexalpha_database.import-example - identity = { - project_id = "project_id" - region = "region" - instance_id = "instance_id" - database_id = "database_id" - } -} +} \ No newline at end of file diff --git a/examples/resources/stackitprivatepreview_postgresflexalpha_instance/resource.tf b/examples/resources/stackitprivatepreview_postgresflexalpha_instance/resource.tf index b503f0ce..1f98284a 100644 --- a/examples/resources/stackitprivatepreview_postgresflexalpha_instance/resource.tf +++ b/examples/resources/stackitprivatepreview_postgresflexalpha_instance/resource.tf @@ -1,4 +1,4 @@ -resource "stackitprivatepreview_postgresflexalpha_instance" "example-instance" { +resource "stackitprivatepreview_postgresflexalpha_instance" "msh-instance-only" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "example-instance" acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] @@ -17,7 +17,7 @@ resource "stackitprivatepreview_postgresflexalpha_instance" "example-instance" { service_account = "service@account.email" } network = { - acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] + acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"] access_scope = "PUBLIC" } version = 17 diff --git a/examples/resources/stackitprivatepreview_postgresflexalpha_user/resource.tf b/examples/resources/stackitprivatepreview_postgresflexalpha_user/resource.tf index 695741c4..01469992 100644 --- a/examples/resources/stackitprivatepreview_postgresflexalpha_user/resource.tf +++ b/examples/resources/stackitprivatepreview_postgresflexalpha_user/resource.tf @@ -1,7 +1,7 @@ resource "stackitprivatepreview_postgresflexalpha_user" "example" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - name = "username" + name = "username" roles = ["role"] } @@ -9,14 +9,4 @@ resource "stackitprivatepreview_postgresflexalpha_user" "example" { import { to = stackitprivatepreview_postgresflexalpha_user.import-example id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.user_id}" -} - -import { - to = stackitprivatepreview_postgresflexalpha_user.import-example - identity = { - project_id = "project.id" - region = "region" - instance_id = "instance.id" - user_id = "user.id" - } -} +} \ No newline at end of file diff --git a/examples/resources/stackitprivatepreview_sqlserverflexalpha_database/resource.tf b/examples/resources/stackitprivatepreview_sqlserverflexalpha_database/resource.tf deleted file mode 100644 index b85cc22b..00000000 --- a/examples/resources/stackitprivatepreview_sqlserverflexalpha_database/resource.tf +++ /dev/null @@ -1,24 +0,0 @@ -resource "stackitprivatepreview_sqlserverflexalpha_database" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - collation = "" - compatibility = "160" - name = "" - owner = "" -} - -# Only use the import statement, if you want to import a existing sqlserverflex database -import { - to = stackitprivatepreview_sqlserverflexalpha_database.import-example - id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}" -} - -import { - to = stackitprivatepreview_sqlserverflexalpha_database.import-example - identity = { - project_id = "project.id" - region = "region" - instance_id = "instance.id" - database_id = "database.id" - } -} \ No newline at end of file diff --git a/examples/resources/stackitprivatepreview_sqlserverflexbeta_database/resource.tf b/examples/resources/stackitprivatepreview_sqlserverflexbeta_database/resource.tf deleted file mode 100644 index 83c52561..00000000 --- a/examples/resources/stackitprivatepreview_sqlserverflexbeta_database/resource.tf +++ /dev/null @@ -1,12 +0,0 @@ -resource "stackitprivatepreview_sqlserverflexalpha_user" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - username = "username" - roles = ["role"] -} - -# Only use the import statement, if you want to import an existing sqlserverflex user -import { - to = stackitprivatepreview_sqlserverflexalpha_user.import-example - id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}" -} \ No newline at end of file diff --git a/examples/resources/stackitprivatepreview_sqlserverflexbeta_user/resource.tf b/examples/resources/stackitprivatepreview_sqlserverflexbeta_user/resource.tf deleted file mode 100644 index 83c52561..00000000 --- a/examples/resources/stackitprivatepreview_sqlserverflexbeta_user/resource.tf +++ /dev/null @@ -1,12 +0,0 @@ -resource "stackitprivatepreview_sqlserverflexalpha_user" "example" { - project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" - username = "username" - roles = ["role"] -} - -# Only use the import statement, if you want to import an existing sqlserverflex user -import { - to = stackitprivatepreview_sqlserverflexalpha_user.import-example - id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}" -} \ No newline at end of file diff --git a/go.mod b/go.mod index d4cfe7c4..fc21ec9e 100644 --- a/go.mod +++ b/go.mod @@ -2,17 +2,10 @@ module tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stac go 1.25.6 - - require ( - github.com/SladkyCitron/slogcolor v1.8.0 - github.com/golang-jwt/jwt/v5 v5.3.1 - github.com/golangci/golangci-lint/v2 v2.10.1 + github.com/MatusOllah/slogcolor v1.7.0 github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 - github.com/hashicorp/terraform-plugin-codegen-framework v0.4.1 - github.com/hashicorp/terraform-plugin-codegen-openapi v0.3.0 - github.com/hashicorp/terraform-plugin-docs v0.24.0 github.com/hashicorp/terraform-plugin-framework v1.17.0 github.com/hashicorp/terraform-plugin-framework-validators v0.19.0 github.com/hashicorp/terraform-plugin-go v0.29.0 @@ -20,283 +13,75 @@ require ( github.com/hashicorp/terraform-plugin-testing v1.14.0 github.com/iancoleman/strcase v0.3.0 github.com/ivanpirog/coloredcobra v1.0.1 - github.com/jarcoal/httpmock v1.4.1 github.com/joho/godotenv v1.5.1 github.com/ldez/go-git-cmd-wrapper/v2 v2.9.1 github.com/spf13/cobra v1.10.2 - github.com/stackitcloud/stackit-sdk-go/core v0.21.1 + github.com/stackitcloud/stackit-sdk-go/core v0.21.0 github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha + github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.4.1 github.com/teambition/rrule-go v1.8.2 - golang.org/x/tools v0.42.0 gopkg.in/yaml.v3 v3.0.1 ) -require github.com/hashicorp/go-retryablehttp v0.7.8 // indirect +require ( + github.com/hashicorp/go-retryablehttp v0.7.8 // indirect + golang.org/x/telemetry v0.0.0-20260116145544-c6413dc483f5 // indirect +) require ( - 4d63.com/gocheckcompilerdirectives v1.3.0 // indirect - 4d63.com/gochecknoglobals v0.2.2 // indirect - codeberg.org/chavacava/garif v0.2.0 // indirect - codeberg.org/polyfloyd/go-errorlint v1.9.0 // indirect dario.cat/mergo v1.0.1 // indirect - dev.gaijin.team/go/exhaustruct/v4 v4.0.0 // indirect - dev.gaijin.team/go/golib v0.6.0 // indirect - github.com/4meepo/tagalign v1.4.3 // indirect - github.com/Abirdcfly/dupword v0.1.7 // indirect - github.com/AdminBenni/iota-mixing v1.0.0 // indirect - github.com/AlwxSin/noinlineerr v1.0.5 // indirect - github.com/Antonboom/errname v1.1.1 // indirect - github.com/Antonboom/nilnil v1.1.1 // indirect - github.com/Antonboom/testifylint v1.6.4 // indirect - github.com/BurntSushi/toml v1.6.0 // indirect - github.com/Djarvur/go-err113 v0.1.1 // indirect - github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect - github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.4.0 // indirect - github.com/Masterminds/sprig/v3 v3.2.3 // indirect - github.com/MirrexOne/unqueryvet v1.5.3 // indirect - github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect github.com/ProtonMail/go-crypto v1.3.0 // indirect github.com/agext/levenshtein v1.2.3 // indirect - github.com/alecthomas/chroma/v2 v2.23.1 // indirect - github.com/alecthomas/go-check-sumtype v0.3.1 // indirect - github.com/alexkohler/nakedret/v2 v2.0.6 // indirect - github.com/alexkohler/prealloc v1.0.2 // indirect - github.com/alfatraining/structtag v1.0.0 // indirect - github.com/alingse/asasalint v0.0.11 // indirect - github.com/alingse/nilnesserr v0.2.0 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/armon/go-radix v1.0.0 // indirect - github.com/ashanbrown/forbidigo/v2 v2.3.0 // indirect - github.com/ashanbrown/makezero/v2 v2.1.0 // indirect - github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/bahlo/generic-list-go v0.2.0 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/bkielbasa/cyclop v1.2.3 // indirect - github.com/blizzy78/varnamelen v0.8.0 // indirect - github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect - github.com/bombsimon/wsl/v4 v4.7.0 // indirect - github.com/bombsimon/wsl/v5 v5.6.0 // indirect - github.com/breml/bidichk v0.3.3 // indirect - github.com/breml/errchkjson v0.4.1 // indirect - github.com/buger/jsonparser v1.1.1 // indirect - github.com/butuzov/ireturn v0.4.0 // indirect - github.com/butuzov/mirror v1.3.0 // indirect - github.com/catenacyber/perfsprint v0.10.1 // indirect - github.com/ccojocar/zxcvbn-go v1.0.4 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/charithe/durationcheck v0.0.11 // indirect - github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect - github.com/charmbracelet/lipgloss v1.1.0 // indirect - github.com/charmbracelet/x/ansi v0.10.1 // indirect - github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect - github.com/charmbracelet/x/term v0.2.1 // indirect - github.com/ckaznocha/intrange v0.3.1 // indirect - github.com/cloudflare/circl v1.6.3 // indirect - github.com/curioswitch/go-reassign v0.3.0 // indirect - github.com/daixiang0/gci v0.13.7 // indirect - github.com/dave/dst v0.27.3 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/denis-tingaikin/go-header v0.5.0 // indirect - github.com/dlclark/regexp2 v1.11.5 // indirect - github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect - github.com/ettle/strcase v0.2.0 // indirect + github.com/cloudflare/circl v1.6.2 // indirect github.com/fatih/color v1.18.0 // indirect - github.com/fatih/structtag v1.2.0 // indirect - github.com/firefart/nonamedreturns v1.0.6 // indirect - github.com/fsnotify/fsnotify v1.5.4 // indirect - github.com/fzipp/gocyclo v0.6.0 // indirect - github.com/ghostiam/protogetter v0.3.20 // indirect - github.com/go-critic/go-critic v0.14.3 // indirect - github.com/go-toolsmith/astcast v1.1.0 // indirect - github.com/go-toolsmith/astcopy v1.1.0 // indirect - github.com/go-toolsmith/astequal v1.2.0 // indirect - github.com/go-toolsmith/astfmt v1.1.0 // indirect - github.com/go-toolsmith/astp v1.1.0 // indirect - github.com/go-toolsmith/strparse v1.1.0 // indirect - github.com/go-toolsmith/typep v1.1.0 // indirect - github.com/go-viper/mapstructure/v2 v2.5.0 // indirect - github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect - github.com/gobwas/glob v0.2.3 // indirect - github.com/godoc-lint/godoc-lint v0.11.2 // indirect - github.com/gofrs/flock v0.13.0 // indirect + github.com/golang-jwt/jwt/v5 v5.3.0 // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/golangci/asciicheck v0.5.0 // indirect - github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 // indirect - github.com/golangci/go-printf-func-name v0.1.1 // indirect - github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect - github.com/golangci/golines v0.15.0 // indirect - github.com/golangci/misspell v0.8.0 // indirect - github.com/golangci/plugin-module-register v0.1.2 // indirect - github.com/golangci/revgrep v0.8.0 // indirect - github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect - github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect - github.com/gordonklaus/ineffassign v0.2.0 // indirect - github.com/gostaticanalysis/analysisutil v0.7.1 // indirect - github.com/gostaticanalysis/comment v1.5.0 // indirect - github.com/gostaticanalysis/forcetypeassert v0.2.0 // indirect - github.com/gostaticanalysis/nilerr v0.1.2 // indirect - github.com/hashicorp/cli v1.1.7 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-cty v1.5.0 // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect - github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.7.0 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.8.0 // indirect - github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect - github.com/hashicorp/hc-install v0.9.3 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hashicorp/hc-install v0.9.2 // indirect github.com/hashicorp/hcl/v2 v2.24.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.25.0 // indirect + github.com/hashicorp/terraform-exec v0.24.0 // indirect github.com/hashicorp/terraform-json v0.27.2 // indirect - github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0 // indirect - github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.2 // indirect + github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 // indirect github.com/hashicorp/terraform-registry-address v0.4.0 // indirect github.com/hashicorp/terraform-svchost v0.2.0 // indirect github.com/hashicorp/yamux v0.1.2 // indirect - github.com/hexops/gotextdiff v1.0.3 // indirect - github.com/huandu/xstrings v1.4.0 // indirect - github.com/imdario/mergo v0.3.16 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jgautheron/goconst v1.8.2 // indirect - github.com/jingyugao/rowserrcheck v1.1.1 // indirect - github.com/jjti/go-spancheck v0.6.5 // indirect - github.com/julz/importas v0.2.0 // indirect - github.com/karamaru-alpha/copyloopvar v1.2.2 // indirect - github.com/kisielk/errcheck v1.9.0 // indirect - github.com/kkHAIKE/contextcheck v1.1.6 // indirect - github.com/kulti/thelper v0.7.1 // indirect - github.com/kunwardeep/paralleltest v1.0.15 // indirect - github.com/lasiar/canonicalheader v1.1.2 // indirect - github.com/ldez/exptostd v0.4.5 // indirect - github.com/ldez/gomoddirectives v0.8.0 // indirect - github.com/ldez/grignotin v0.10.1 // indirect - github.com/ldez/structtags v0.6.1 // indirect - github.com/ldez/tagliatelle v0.7.2 // indirect - github.com/ldez/usetesting v0.5.0 // indirect - github.com/leonklingele/grouper v1.1.2 // indirect - github.com/lucasb-eyer/go-colorful v1.2.0 // indirect - github.com/macabu/inamedparam v0.2.0 // indirect - github.com/magiconair/properties v1.8.6 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/manuelarte/embeddedstructfieldcheck v0.4.0 // indirect - github.com/manuelarte/funcorder v0.5.0 // indirect - github.com/maratori/testableexamples v1.0.1 // indirect - github.com/maratori/testpackage v1.1.2 // indirect - github.com/matoous/godox v1.1.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mgechev/revive v1.14.0 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/moricho/tparallel v0.3.2 // indirect - github.com/muesli/termenv v0.16.0 // indirect - github.com/nakabonne/nestif v0.3.1 // indirect - github.com/nishanths/exhaustive v0.12.0 // indirect - github.com/nishanths/predeclared v0.2.2 // indirect - github.com/nunnatsa/ginkgolinter v0.23.0 // indirect github.com/oklog/run v1.2.0 // indirect - github.com/pb33f/libopenapi v0.15.0 // indirect - github.com/pelletier/go-toml v1.9.5 // indirect - github.com/pelletier/go-toml/v2 v2.2.4 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/posener/complete v1.2.3 // indirect - github.com/prometheus/client_golang v1.12.1 // indirect - github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect - github.com/prometheus/procfs v0.7.3 // indirect - github.com/quasilyte/go-ruleguard v0.4.5 // indirect - github.com/quasilyte/go-ruleguard/dsl v0.3.23 // indirect - github.com/quasilyte/gogrep v0.5.0 // indirect - github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect - github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect - github.com/raeperd/recvcheck v0.2.0 // indirect - github.com/rivo/uniseg v0.4.7 // indirect - github.com/rogpeppe/go-internal v1.14.1 // indirect - github.com/ryancurrah/gomodguard v1.4.1 // indirect - github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect - github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect - github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect - github.com/sashamelentyev/interfacebloat v1.1.0 // indirect - github.com/sashamelentyev/usestdlibvars v1.29.0 // indirect - github.com/securego/gosec/v2 v2.23.0 // indirect - github.com/shopspring/decimal v1.3.1 // indirect - github.com/sirupsen/logrus v1.9.4 // indirect - github.com/sivchari/containedctx v1.0.3 // indirect - github.com/sonatard/noctx v0.4.0 // indirect - github.com/sourcegraph/go-diff v0.7.0 // indirect - github.com/spf13/afero v1.15.0 // indirect - github.com/spf13/cast v1.5.1 // indirect - github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.10 // indirect - github.com/spf13/viper v1.12.0 // indirect - github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect - github.com/stbenjam/no-sprintf-host-port v0.3.1 // indirect - github.com/stretchr/objx v0.5.2 // indirect github.com/stretchr/testify v1.11.1 // indirect - github.com/subosito/gotenv v1.4.1 // indirect - github.com/tetafro/godot v1.5.4 // indirect - github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 // indirect - github.com/timonwong/loggercheck v0.11.0 // indirect - github.com/tomarrell/wrapcheck/v2 v2.12.0 // indirect - github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect - github.com/ultraware/funlen v0.2.0 // indirect - github.com/ultraware/whitespace v0.2.0 // indirect - github.com/uudashr/gocognit v1.2.0 // indirect - github.com/uudashr/iface v1.4.1 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect - github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect - github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect - github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect - github.com/xeipuuv/gojsonschema v1.2.0 // indirect - github.com/xen0n/gosmopolitan v1.3.0 // indirect - github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect - github.com/yagipy/maintidx v1.0.0 // indirect - github.com/yeya24/promlinter v0.3.0 // indirect - github.com/ykadowak/zerologlint v0.1.5 // indirect - github.com/yuin/goldmark v1.7.7 // indirect - github.com/yuin/goldmark-meta v1.1.0 // indirect github.com/zclconf/go-cty v1.17.0 // indirect - gitlab.com/bosi/decorder v0.4.2 // indirect - go-simpler.org/musttag v0.14.0 // indirect - go-simpler.org/sloglint v0.11.1 // indirect - go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect - go.augendre.info/arangolint v0.4.0 // indirect - go.augendre.info/fatcontext v0.9.0 // indirect - go.uber.org/multierr v1.10.0 // indirect - go.uber.org/zap v1.27.0 // indirect - go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/crypto v0.48.0 // indirect - golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect - golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 // indirect - golang.org/x/mod v0.33.0 // indirect - golang.org/x/net v0.50.0 // indirect + golang.org/x/crypto v0.47.0 // indirect + golang.org/x/mod v0.32.0 // indirect + golang.org/x/net v0.49.0 // indirect golang.org/x/sync v0.19.0 // indirect - golang.org/x/sys v0.41.0 // indirect - golang.org/x/telemetry v0.0.0-20260209163413-e7419c687ee4 // indirect - golang.org/x/text v0.34.0 // indirect + golang.org/x/sys v0.40.0 // indirect + golang.org/x/text v0.33.0 // indirect + golang.org/x/tools v0.41.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 // indirect - google.golang.org/grpc v1.79.1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516 // indirect + google.golang.org/grpc v1.78.0 // indirect google.golang.org/protobuf v1.36.11 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - honnef.co/go/tools v0.7.0 // indirect - mvdan.cc/gofumpt v0.9.2 // indirect - mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15 // indirect ) + +tool golang.org/x/tools/cmd/goimports diff --git a/go.sum b/go.sum index 00f1e6ff..43e5e03e 100644 --- a/go.sum +++ b/go.sum @@ -1,399 +1,61 @@ -4d63.com/gocheckcompilerdirectives v1.3.0 h1:Ew5y5CtcAAQeTVKUVFrE7EwHMrTO6BggtEj8BZSjZ3A= -4d63.com/gocheckcompilerdirectives v1.3.0/go.mod h1:ofsJ4zx2QAuIP/NO/NAh1ig6R1Fb18/GI7RVMwz7kAY= -4d63.com/gochecknoglobals v0.2.2 h1:H1vdnwnMaZdQW/N+NrkT1SZMTBmcwHe9Vq8lJcYYTtU= -4d63.com/gochecknoglobals v0.2.2/go.mod h1:lLxwTQjL5eIesRbvnzIP3jZtG140FnTdz+AlMa+ogt0= -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -codeberg.org/chavacava/garif v0.2.0 h1:F0tVjhYbuOCnvNcU3YSpO6b3Waw6Bimy4K0mM8y6MfY= -codeberg.org/chavacava/garif v0.2.0/go.mod h1:P2BPbVbT4QcvLZrORc2T29szK3xEOlnl0GiPTJmEqBQ= -codeberg.org/polyfloyd/go-errorlint v1.9.0 h1:VkdEEmA1VBpH6ecQoMR4LdphVI3fA4RrCh2an7YmodI= -codeberg.org/polyfloyd/go-errorlint v1.9.0/go.mod h1:GPRRu2LzVijNn4YkrZYJfatQIdS+TrcK8rL5Xs24qw8= dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -dev.gaijin.team/go/exhaustruct/v4 v4.0.0 h1:873r7aNneqoBB3IaFIzhvt2RFYTuHgmMjoKfwODoI1Y= -dev.gaijin.team/go/exhaustruct/v4 v4.0.0/go.mod h1:aZ/k2o4Y05aMJtiux15x8iXaumE88YdiB0Ai4fXOzPI= -dev.gaijin.team/go/golib v0.6.0 h1:v6nnznFTs4bppib/NyU1PQxobwDHwCXXl15P7DV5Zgo= -dev.gaijin.team/go/golib v0.6.0/go.mod h1:uY1mShx8Z/aNHWDyAkZTkX+uCi5PdX7KsG1eDQa2AVE= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/4meepo/tagalign v1.4.3 h1:Bnu7jGWwbfpAie2vyl63Zup5KuRv21olsPIha53BJr8= -github.com/4meepo/tagalign v1.4.3/go.mod h1:00WwRjiuSbrRJnSVeGWPLp2epS5Q/l4UEy0apLLS37c= -github.com/Abirdcfly/dupword v0.1.7 h1:2j8sInznrje4I0CMisSL6ipEBkeJUJAmK1/lfoNGWrQ= -github.com/Abirdcfly/dupword v0.1.7/go.mod h1:K0DkBeOebJ4VyOICFdppB23Q0YMOgVafM0zYW0n9lF4= -github.com/AdminBenni/iota-mixing v1.0.0 h1:Os6lpjG2dp/AE5fYBPAA1zfa2qMdCAWwPMCgpwKq7wo= -github.com/AdminBenni/iota-mixing v1.0.0/go.mod h1:i4+tpAaB+qMVIV9OK3m4/DAynOd5bQFaOu+2AhtBCNY= -github.com/AlwxSin/noinlineerr v1.0.5 h1:RUjt63wk1AYWTXtVXbSqemlbVTb23JOSRiNsshj7TbY= -github.com/AlwxSin/noinlineerr v1.0.5/go.mod h1:+QgkkoYrMH7RHvcdxdlI7vYYEdgeoFOVjU9sUhw/rQc= -github.com/Antonboom/errname v1.1.1 h1:bllB7mlIbTVzO9jmSWVWLjxTEbGBVQ1Ff/ClQgtPw9Q= -github.com/Antonboom/errname v1.1.1/go.mod h1:gjhe24xoxXp0ScLtHzjiXp0Exi1RFLKJb0bVBtWKCWQ= -github.com/Antonboom/nilnil v1.1.1 h1:9Mdr6BYd8WHCDngQnNVV0b554xyisFioEKi30sksufQ= -github.com/Antonboom/nilnil v1.1.1/go.mod h1:yCyAmSw3doopbOWhJlVci+HuyNRuHJKIv6V2oYQa8II= -github.com/Antonboom/testifylint v1.6.4 h1:gs9fUEy+egzxkEbq9P4cpcMB6/G0DYdMeiFS87UiqmQ= -github.com/Antonboom/testifylint v1.6.4/go.mod h1:YO33FROXX2OoUfwjz8g+gUxQXio5i9qpVy7nXGbxDD4= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= -github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Djarvur/go-err113 v0.1.1 h1:eHfopDqXRwAi+YmCUas75ZE0+hoBHJ2GQNLYRSxao4g= -github.com/Djarvur/go-err113 v0.1.1/go.mod h1:IaWJdYFLg76t2ihfflPZnM1LIQszWOsFDh2hhhAVF6k= -github.com/Kunde21/markdownfmt/v3 v3.1.0 h1:KiZu9LKs+wFFBQKhrZJrFZwtLnCCWJahL+S+E/3VnM0= -github.com/Kunde21/markdownfmt/v3 v3.1.0/go.mod h1:tPXN1RTyOzJwhfHoon9wUr4HGYmWgVxSQN6VBJDkrVc= -github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= -github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= -github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= -github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= -github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= -github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= +github.com/MatusOllah/slogcolor v1.7.0 h1:Nrd7yBPv2EBEEBEwl7WEPRmMd1ozZzw2jm8SLMYDbKs= +github.com/MatusOllah/slogcolor v1.7.0/go.mod h1:5y1H50XuQIBvuYTJlmokWi+4FuPiJN5L7Z0jM4K4bYA= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/MirrexOne/unqueryvet v1.5.3 h1:LpT3rsH+IY3cQddWF9bg4C7jsbASdGnrOSofY8IPEiw= -github.com/MirrexOne/unqueryvet v1.5.3/go.mod h1:fs9Zq6eh1LRIhsDIsxf9PONVUjYdFHdtkHIgZdJnyPU= -github.com/OpenPeeDeeP/depguard/v2 v2.2.1 h1:vckeWVESWp6Qog7UZSARNqfu/cZqvki8zsuj3piCMx4= -github.com/OpenPeeDeeP/depguard/v2 v2.2.1/go.mod h1:q4DKzC4UcVaAvcfd41CZh0PWpGgzrVxUYBlgKNGquUo= github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw= github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE= -github.com/SladkyCitron/slogcolor v1.8.0 h1:ln4mUPfVhs7a/vZfjnKkz5YZ71Bg/KFWneS2hfFq6FM= -github.com/SladkyCitron/slogcolor v1.8.0/go.mod h1:ft8LEVIl4isUkebakhv+ngNXJjWBumnwhXfxTLApf3M= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= -github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/chroma/v2 v2.23.1 h1:nv2AVZdTyClGbVQkIzlDm/rnhk1E9bU9nXwmZ/Vk/iY= -github.com/alecthomas/chroma/v2 v2.23.1/go.mod h1:NqVhfBR0lte5Ouh3DcthuUCTUpDC9cxBOfyMbMQPs3o= -github.com/alecthomas/go-check-sumtype v0.3.1 h1:u9aUvbGINJxLVXiFvHUlPEaD7VDULsrxJb4Aq31NLkU= -github.com/alecthomas/go-check-sumtype v0.3.1/go.mod h1:A8TSiN3UPRw3laIgWEUOHHLPa6/r9MtoigdlP5h3K/E= -github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs= -github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alexkohler/nakedret/v2 v2.0.6 h1:ME3Qef1/KIKr3kWX3nti3hhgNxw6aqN5pZmQiFSsuzQ= -github.com/alexkohler/nakedret/v2 v2.0.6/go.mod h1:l3RKju/IzOMQHmsEvXwkqMDzHHvurNQfAgE1eVmT40Q= -github.com/alexkohler/prealloc v1.0.2 h1:MPo8cIkGkZytq7WNH9UHv3DIX1mPz1RatPXnZb0zHWQ= -github.com/alexkohler/prealloc v1.0.2/go.mod h1:fT39Jge3bQrfA7nPMDngUfvUbQGQeJyGQnR+913SCig= -github.com/alfatraining/structtag v1.0.0 h1:2qmcUqNcCoyVJ0up879K614L9PazjBSFruTB0GOFjCc= -github.com/alfatraining/structtag v1.0.0/go.mod h1:p3Xi5SwzTi+Ryj64DqjLWz7XurHxbGsq6y3ubePJPus= -github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw= -github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= -github.com/alingse/nilnesserr v0.2.0 h1:raLem5KG7EFVb4UIDAXgrv3N2JIaffeKNtcEXkEWd/w= -github.com/alingse/nilnesserr v0.2.0/go.mod h1:1xJPrXonEtX7wyTq8Dytns5P2hNzoWymVUIaKm4HNFg= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= -github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/ashanbrown/forbidigo/v2 v2.3.0 h1:OZZDOchCgsX5gvToVtEBoV2UWbFfI6RKQTir2UZzSxo= -github.com/ashanbrown/forbidigo/v2 v2.3.0/go.mod h1:5p6VmsG5/1xx3E785W9fouMxIOkvY2rRV9nMdWadd6c= -github.com/ashanbrown/makezero/v2 v2.1.0 h1:snuKYMbqosNokUKm+R6/+vOPs8yVAi46La7Ck6QYSaE= -github.com/ashanbrown/makezero/v2 v2.1.0/go.mod h1:aEGT/9q3S8DHeE57C88z2a6xydvgx8J5hgXIGWgo0MY= -github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= -github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= -github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= -github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bkielbasa/cyclop v1.2.3 h1:faIVMIGDIANuGPWH031CZJTi2ymOQBULs9H21HSMa5w= -github.com/bkielbasa/cyclop v1.2.3/go.mod h1:kHTwA9Q0uZqOADdupvcFJQtp/ksSnytRMe8ztxG8Fuo= -github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M= -github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= -github.com/bmatcuk/doublestar/v4 v4.9.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/avrEXE= -github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= -github.com/bombsimon/wsl/v4 v4.7.0 h1:1Ilm9JBPRczjyUs6hvOPKvd7VL1Q++PL8M0SXBDf+jQ= -github.com/bombsimon/wsl/v4 v4.7.0/go.mod h1:uV/+6BkffuzSAVYD+yGyld1AChO7/EuLrCF/8xTiapg= -github.com/bombsimon/wsl/v5 v5.6.0 h1:4z+/sBqC5vUmSp1O0mS+czxwH9+LKXtCWtHH9rZGQL8= -github.com/bombsimon/wsl/v5 v5.6.0/go.mod h1:Uqt2EfrMj2NV8UGoN1f1Y3m0NpUVCsUdrNCdet+8LvU= -github.com/breml/bidichk v0.3.3 h1:WSM67ztRusf1sMoqH6/c4OBCUlRVTKq+CbSeo0R17sE= -github.com/breml/bidichk v0.3.3/go.mod h1:ISbsut8OnjB367j5NseXEGGgO/th206dVa427kR8YTE= -github.com/breml/errchkjson v0.4.1 h1:keFSS8D7A2T0haP9kzZTi7o26r7kE3vymjZNeNDRDwg= -github.com/breml/errchkjson v0.4.1/go.mod h1:a23OvR6Qvcl7DG/Z4o0el6BRAjKnaReoPQFciAl9U3s= github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw= github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c= -github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= -github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/butuzov/ireturn v0.4.0 h1:+s76bF/PfeKEdbG8b54aCocxXmi0wvYdOVsWxVO7n8E= -github.com/butuzov/ireturn v0.4.0/go.mod h1:ghI0FrCmap8pDWZwfPisFD1vEc56VKH4NpQUxDHta70= -github.com/butuzov/mirror v1.3.0 h1:HdWCXzmwlQHdVhwvsfBb2Au0r3HyINry3bDWLYXiKoc= -github.com/butuzov/mirror v1.3.0/go.mod h1:AEij0Z8YMALaq4yQj9CPPVYOyJQyiexpQEQgihajRfI= -github.com/catenacyber/perfsprint v0.10.1 h1:u7Riei30bk46XsG8nknMhKLXG9BcXz3+3tl/WpKm0PQ= -github.com/catenacyber/perfsprint v0.10.1/go.mod h1:DJTGsi/Zufpuus6XPGJyKOTMELe347o6akPvWG9Zcsc= -github.com/ccojocar/zxcvbn-go v1.0.4 h1:FWnCIRMXPj43ukfX000kvBZvV6raSxakYr1nzyNrUcc= -github.com/ccojocar/zxcvbn-go v1.0.4/go.mod h1:3GxGX+rHmueTUMvm5ium7irpyjmm7ikxYFOSJB21Das= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/charithe/durationcheck v0.0.11 h1:g1/EX1eIiKS57NTWsYtHDZ/APfeXKhye1DidBcABctk= -github.com/charithe/durationcheck v0.0.11/go.mod h1:x5iZaixRNl8ctbM+3B2RrPG5t856TxRyVQEnbIEM2X4= -github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs= -github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk= -github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= -github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= -github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ= -github.com/charmbracelet/x/ansi v0.10.1/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE= -github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8= -github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs= -github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ= -github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/ckaznocha/intrange v0.3.1 h1:j1onQyXvHUsPWujDH6WIjhyH26gkRt/txNlV7LspvJs= -github.com/ckaznocha/intrange v0.3.1/go.mod h1:QVepyz1AkUoFQkpEqksSYpNpUo3c5W7nWh/s6SHIJJk= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8= -github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cloudflare/circl v1.6.2 h1:hL7VBpHHKzrV5WTfHCaBsgx/HGbBYlgrwvNXEVDYYsQ= +github.com/cloudflare/circl v1.6.2/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4= github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= -github.com/curioswitch/go-reassign v0.3.0 h1:dh3kpQHuADL3cobV/sSGETA8DOv457dwl+fbBAhrQPs= -github.com/curioswitch/go-reassign v0.3.0/go.mod h1:nApPCCTtqLJN/s8HfItCcKV0jIPwluBOvZP+dsJGA88= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= -github.com/daixiang0/gci v0.13.7 h1:+0bG5eK9vlI08J+J/NWGbWPTNiXPG4WhNLJOkSxWITQ= -github.com/daixiang0/gci v0.13.7/go.mod h1:812WVN6JLFY9S6Tv76twqmNqevN0pa3SX3nih0brVzQ= -github.com/dave/dst v0.27.3 h1:P1HPoMza3cMEquVf9kKy8yXsFirry4zEnWOdYPOoIzY= -github.com/dave/dst v0.27.3/go.mod h1:jHh6EOibnHgcUW3WjKHisiooEkYwqpHLBSX1iOBhEyc= -github.com/dave/jennifer v1.7.1 h1:B4jJJDHelWcDhlRQxWeo0Npa/pYKBLrirAQoTN45txo= -github.com/dave/jennifer v1.7.1/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denis-tingaikin/go-header v0.5.0 h1:SRdnP5ZKvcO9KKRP1KJrhFR3RrlGuD+42t4429eC9k8= -github.com/denis-tingaikin/go-header v0.5.0/go.mod h1:mMenU5bWrok6Wl2UsZjy+1okegmwQ3UgWl4V1D8gjlY= -github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= -github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960/go.mod h1:9HQzr9D/0PGwMEbC3d5AB7oi67+h4TsQqItC1GVYG58= -github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 h1:PRxIJD8XjimM5aTknUK9w6DHLDox2r2M3DI4i2pnd3w= -github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936/go.mod h1:ttYvX5qlB+mlV1okblJqcSMtR4c52UKxDiX9GRBS8+Q= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q= -github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= -github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= -github.com/firefart/nonamedreturns v1.0.6 h1:vmiBcKV/3EqKY3ZiPxCINmpS431OcE1S47AQUwhrg8E= -github.com/firefart/nonamedreturns v1.0.6/go.mod h1:R8NisJnSIpvPWheCq0mNRXJok6D8h7fagJTF8EMEwCo= -github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= -github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= -github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= -github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= -github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= -github.com/ghostiam/protogetter v0.3.20 h1:oW7OPFit2FxZOpmMRPP9FffU4uUpfeE/rEdE1f+MzD0= -github.com/ghostiam/protogetter v0.3.20/go.mod h1:FjIu5Yfs6FT391m+Fjp3fbAYJ6rkL/J6ySpZBfnODuI= -github.com/go-critic/go-critic v0.14.3 h1:5R1qH2iFeo4I/RJU8vTezdqs08Egi4u5p6vOESA0pog= -github.com/go-critic/go-critic v0.14.3/go.mod h1:xwntfW6SYAd7h1OqDzmN6hBX/JxsEKl5up/Y2bsxgVQ= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM= github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU= -github.com/go-git/go-git/v5 v5.16.5 h1:mdkuqblwr57kVfXri5TTH+nMFLNUxIj9Z7F5ykFbw5s= -github.com/go-git/go-git/v5 v5.16.5/go.mod h1:QOMLpNf1qxuSY4StA/ArOdfFR2TrKEjJiye2kel2m+M= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-git/go-git/v5 v5.14.0 h1:/MD3lCrGjCen5WfEAzKg00MJJffKhC8gzS80ycmCi60= +github.com/go-git/go-git/v5 v5.14.0/go.mod h1:Z5Xhoia5PcWA3NF8vRLURn9E5FRhSl7dGj9ItW3Wk5k= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= -github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= -github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-toolsmith/astcast v1.1.0 h1:+JN9xZV1A+Re+95pgnMgDboWNVnIMMQXwfBwLRPgSC8= -github.com/go-toolsmith/astcast v1.1.0/go.mod h1:qdcuFWeGGS2xX5bLM/c3U9lewg7+Zu4mr+xPwZIB4ZU= -github.com/go-toolsmith/astcopy v1.1.0 h1:YGwBN0WM+ekI/6SS6+52zLDEf8Yvp3n2seZITCUBt5s= -github.com/go-toolsmith/astcopy v1.1.0/go.mod h1:hXM6gan18VA1T/daUEHCFcYiW8Ai1tIwIzHY6srfEAw= -github.com/go-toolsmith/astequal v1.0.3/go.mod h1:9Ai4UglvtR+4up+bAD4+hCj7iTo4m/OXVTSLnCyTAx4= -github.com/go-toolsmith/astequal v1.1.0/go.mod h1:sedf7VIdCL22LD8qIvv7Nn9MuWJruQA/ysswh64lffQ= -github.com/go-toolsmith/astequal v1.2.0 h1:3Fs3CYZ1k9Vo4FzFhwwewC3CHISHDnVUPC4x0bI2+Cw= -github.com/go-toolsmith/astequal v1.2.0/go.mod h1:c8NZ3+kSFtFY/8lPso4v8LuJjdJiUFVnSuU3s0qrrDY= -github.com/go-toolsmith/astfmt v1.1.0 h1:iJVPDPp6/7AaeLJEruMsBUlOYCmvg0MoCfJprsOmcco= -github.com/go-toolsmith/astfmt v1.1.0/go.mod h1:OrcLlRwu0CuiIBp/8b5PYF9ktGVZUjlNMV634mhwuQ4= -github.com/go-toolsmith/astp v1.1.0 h1:dXPuCl6u2llURjdPLLDxJeZInAeZ0/eZwFJmqZMnpQA= -github.com/go-toolsmith/astp v1.1.0/go.mod h1:0T1xFGz9hicKs8Z5MfAqSUitoUYS30pDMsRVIDHs8CA= -github.com/go-toolsmith/pkgload v1.2.2 h1:0CtmHq/02QhxcF7E9N5LIFcYFsMR5rdovfqTtRKkgIk= -github.com/go-toolsmith/pkgload v1.2.2/go.mod h1:R2hxLNRKuAsiXCo2i5J6ZQPhnPMOVtU+f0arbFPWCus= -github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8= -github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQiyP2Bvw= -github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ= -github.com/go-toolsmith/typep v1.1.0 h1:fIRYDyF+JywLfqzyhdiHzRop/GQDxxNhLGQ6gFUNHus= -github.com/go-toolsmith/typep v1.1.0/go.mod h1:fVIw+7zjdsMxDA3ITWnH1yOiw1rnTQKCsF/sk2H/qig= -github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= -github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= -github.com/go-xmlfmt/xmlfmt v1.1.3 h1:t8Ey3Uy7jDSEisW2K3somuMKIpzktkWptA0iFCnRUWY= -github.com/go-xmlfmt/xmlfmt v1.1.3/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= -github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= -github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/godoc-lint/godoc-lint v0.11.2 h1:Bp0FkJWoSdNsBikdNgIcgtaoo+xz6I/Y9s5WSBQUeeM= -github.com/godoc-lint/godoc-lint v0.11.2/go.mod h1:iVpGdL1JCikNH2gGeAn3Hh+AgN5Gx/I/cxV+91L41jo= -github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw= -github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= -github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= +github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ= github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golangci/asciicheck v0.5.0 h1:jczN/BorERZwK8oiFBOGvlGPknhvq0bjnysTj4nUfo0= -github.com/golangci/asciicheck v0.5.0/go.mod h1:5RMNAInbNFw2krqN6ibBxN/zfRFa9S6tA1nPdM0l8qQ= -github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 h1:WUvBfQL6EW/40l6OmeSBYQJNSif4O11+bmWEz+C7FYw= -github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32/go.mod h1:NUw9Zr2Sy7+HxzdjIULge71wI6yEg1lWQr7Evcu8K0E= -github.com/golangci/go-printf-func-name v0.1.1 h1:hIYTFJqAGp1iwoIfsNTpoq1xZAarogrvjO9AfiW3B4U= -github.com/golangci/go-printf-func-name v0.1.1/go.mod h1:Es64MpWEZbh0UBtTAICOZiB+miW53w/K9Or/4QogJss= -github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d h1:viFft9sS/dxoYY0aiOTsLKO2aZQAPT4nlQCsimGcSGE= -github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d/go.mod h1:ivJ9QDg0XucIkmwhzCDsqcnxxlDStoTl89jDMIoNxKY= -github.com/golangci/golangci-lint/v2 v2.10.1 h1:flhw5Px6ojbLyEFzXvJn5B2HEdkkRlkhE1SnmCbQBiE= -github.com/golangci/golangci-lint/v2 v2.10.1/go.mod h1:dBsrOk6zj0vDhlTv+IiJGqkDokR24IVTS7W3EVfPTQY= -github.com/golangci/golines v0.15.0 h1:Qnph25g8Y1c5fdo1X7GaRDGgnMHgnxh4Gk4VfPTtRx0= -github.com/golangci/golines v0.15.0/go.mod h1:AZjXd23tbHMpowhtnGlj9KCNsysj72aeZVVHnVcZx10= -github.com/golangci/misspell v0.8.0 h1:qvxQhiE2/5z+BVRo1kwYA8yGz+lOlu5Jfvtx2b04Jbg= -github.com/golangci/misspell v0.8.0/go.mod h1:WZyyI2P3hxPY2UVHs3cS8YcllAeyfquQcKfdeE9AFVg= -github.com/golangci/plugin-module-register v0.1.2 h1:e5WM6PO6NIAEcij3B053CohVp3HIYbzSuP53UAYgOpg= -github.com/golangci/plugin-module-register v0.1.2/go.mod h1:1+QGTsKBvAIvPvoY/os+G5eoqxWn70HYDm2uvUyGuVw= -github.com/golangci/revgrep v0.8.0 h1:EZBctwbVd0aMeRnNUsFogoyayvKHyxlV3CdUA46FX2s= -github.com/golangci/revgrep v0.8.0/go.mod h1:U4R/s9dlXZsg8uJmaR1GrloUr14D7qDl8gi2iPXJH8k= -github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e h1:ai0EfmVYE2bRA5htgAG9r7s3tHsfjIhN98WshBTJ9jM= -github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e/go.mod h1:Vrn4B5oR9qRwM+f54koyeH3yzphlecwERs0el27Fr/s= -github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e h1:gD6P7NEo7Eqtt0ssnqSJNNndxe69DOQ24A5h7+i3KpM= -github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e/go.mod h1:h+wZwLjUTJnm/P2rwlbJdRPZXOzaT36/FwnPnY2inzc= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/vP9vJGqPwcdqsWjOt+V8J7+bTc= -github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/gordonklaus/ineffassign v0.2.0 h1:Uths4KnmwxNJNzq87fwQQDDnbNb7De00VOk9Nu0TySs= -github.com/gordonklaus/ineffassign v0.2.0/go.mod h1:TIpymnagPSexySzs7F9FnO1XFTy8IT3a59vmZp5Y9Lw= -github.com/gostaticanalysis/analysisutil v0.7.1 h1:ZMCjoue3DtDWQ5WyU16YbjbQEQ3VuzwxALrpYd+HeKk= -github.com/gostaticanalysis/analysisutil v0.7.1/go.mod h1:v21E3hY37WKMGSnbsw2S/ojApNWb6C1//mXO48CXbVc= -github.com/gostaticanalysis/comment v1.4.2/go.mod h1:KLUTGDv6HOCotCH8h2erHKmpci2ZoR8VPu34YA2uzdM= -github.com/gostaticanalysis/comment v1.5.0 h1:X82FLl+TswsUMpMh17srGRuKaaXprTaytmEpgnKIDu8= -github.com/gostaticanalysis/comment v1.5.0/go.mod h1:V6eb3gpCv9GNVqb6amXzEUX3jXLVK/AdA+IrAMSqvEc= -github.com/gostaticanalysis/forcetypeassert v0.2.0 h1:uSnWrrUEYDr86OCxWa4/Tp2jeYDlogZiZHzGkWFefTk= -github.com/gostaticanalysis/forcetypeassert v0.2.0/go.mod h1:M5iPavzE9pPqWyeiVXSFghQjljW1+l/Uke3PXHS6ILY= -github.com/gostaticanalysis/nilerr v0.1.2 h1:S6nk8a9N8g062nsx63kUkF6AzbHGw7zzyHMcpu52xQU= -github.com/gostaticanalysis/nilerr v0.1.2/go.mod h1:A19UHhoY3y8ahoL7YKz6sdjDtduwTSI4CsymaC2htPA= -github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M= -github.com/gostaticanalysis/testutil v0.5.0 h1:Dq4wT1DdTwTGCQQv3rl3IvD5Ld0E6HiY+3Zh0sUGqw8= -github.com/gostaticanalysis/testutil v0.5.0/go.mod h1:OLQSbuM6zw2EvCcXTz1lVq5unyoNft372msDY0nY5Hs= -github.com/hashicorp/cli v1.1.7 h1:/fZJ+hNdwfTSfsxMBa9WWMlfjUZbX8/LnUxgAd7lCVU= -github.com/hashicorp/cli v1.1.7/go.mod h1:e6Mfpga9OCT1vqzFuoGZiiF/KaG9CbUfO5s3ghU3YgU= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -406,9 +68,6 @@ github.com/hashicorp/go-cty v1.5.0 h1:EkQ/v+dDNUqnuVpmS5fPqyY71NXVgT5gf32+57xY8g github.com/hashicorp/go-cty v1.5.0/go.mod h1:lFUCG5kd8exDobgSfyj4ONE/dc822kiYMguVKdHGMLM= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-immutable-radix/v2 v2.1.0 h1:CUW5RYIcysz+D3B+l1mDeXrQ7fUvGGCwJfdASSzbrfo= -github.com/hashicorp/go-immutable-radix/v2 v2.1.0/go.mod h1:hgdqLXA4f6NIjRVisM1TJ9aOJVNRqKZj+xDGF6m7PBw= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.7.0 h1:YghfQH/0QmPNc/AZMTFE3ac8fipZyZECHdDPshfk+mA= @@ -418,33 +77,18 @@ github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3 github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.8.0 h1:KAkNb1HAiZd1ukkxDFGmokVZe1Xy9HG6NUp+bPle2i4= github.com/hashicorp/go-version v1.8.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= -github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= -github.com/hashicorp/hc-install v0.9.3 h1:1H4dgmgzxEVwT6E/d/vIL5ORGVKz9twRwDw+qA5Hyho= -github.com/hashicorp/hc-install v0.9.3/go.mod h1:FQlQ5I3I/X409N/J1U4pPeQQz1R3BoV0IysB7aiaQE0= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/hc-install v0.9.2 h1:v80EtNX4fCVHqzL9Lg/2xkp62bbvQMnvPQ0G+OmtO24= +github.com/hashicorp/hc-install v0.9.2/go.mod h1:XUqBQNnuT4RsxoxiM9ZaUk0NX8hi2h+Lb6/c0OZnC/I= github.com/hashicorp/hcl/v2 v2.24.0 h1:2QJdZ454DSsYGoaE6QheQZjtKZSUs9Nh2izTWiwQxvE= github.com/hashicorp/hcl/v2 v2.24.0/go.mod h1:oGoO1FIQYfn/AgyOhlg9qLC6/nOJPX3qGbkZpYAcqfM= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.25.0 h1:Bkt6m3VkJqYh+laFMrWIpy9KHYFITpOyzRMNI35rNaY= -github.com/hashicorp/terraform-exec v0.25.0/go.mod h1:dl9IwsCfklDU6I4wq9/StFDp7dNbH/h5AnfS1RmiUl8= +github.com/hashicorp/terraform-exec v0.24.0 h1:mL0xlk9H5g2bn0pPF6JQZk5YlByqSqrO5VoaNtAf8OE= +github.com/hashicorp/terraform-exec v0.24.0/go.mod h1:lluc/rDYfAhYdslLJQg3J0oDqo88oGQAdHR+wDqFvo4= github.com/hashicorp/terraform-json v0.27.2 h1:BwGuzM6iUPqf9JYM/Z4AF1OJ5VVJEEzoKST/tRDBJKU= github.com/hashicorp/terraform-json v0.27.2/go.mod h1:GzPLJ1PLdUG5xL6xn1OXWIjteQRT2CNT9o/6A9mi9hE= -github.com/hashicorp/terraform-plugin-codegen-framework v0.4.1 h1:eaI/3dsu2T5QAXbA+7N+B+UBj20GdtYnsRuYypKh3S4= -github.com/hashicorp/terraform-plugin-codegen-framework v0.4.1/go.mod h1:kpYM23L7NtcfaQdWAN0QFkV/lU0w16qJ2ddAPCI4zAg= -github.com/hashicorp/terraform-plugin-codegen-openapi v0.3.0 h1:IKpc337XKk50QyQPSxLrHwdqSo1E2XqCMxFkWsZcTvc= -github.com/hashicorp/terraform-plugin-codegen-openapi v0.3.0/go.mod h1:tT6wl80h7nsMBw+1yZRgJXi+Ys85PUai11weDqysvp4= -github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0 h1:91dQG1A/DxP6vRz9GiytDTrZTXDbhHPvmpYnAyWA/Vw= -github.com/hashicorp/terraform-plugin-codegen-spec v0.2.0/go.mod h1:fywrEKpordQypmAjz/HIfm2LuNVmyJ6KDe8XT9GdJxQ= -github.com/hashicorp/terraform-plugin-docs v0.24.0 h1:YNZYd+8cpYclQyXbl1EEngbld8w7/LPOm99GD5nikIU= -github.com/hashicorp/terraform-plugin-docs v0.24.0/go.mod h1:YLg+7LEwVmRuJc0EuCw0SPLxuQXw5mW8iJ5ml/kvi+o= github.com/hashicorp/terraform-plugin-framework v1.17.0 h1:JdX50CFrYcYFY31gkmitAEAzLKoBgsK+iaJjDC8OexY= github.com/hashicorp/terraform-plugin-framework v1.17.0/go.mod h1:4OUXKdHNosX+ys6rLgVlgklfxN3WHR5VHSOABeS/BM0= github.com/hashicorp/terraform-plugin-framework-validators v0.19.0 h1:Zz3iGgzxe/1XBkooZCewS0nJAaCFPFPHdNJd8FgE4Ow= @@ -453,8 +97,8 @@ github.com/hashicorp/terraform-plugin-go v0.29.0 h1:1nXKl/nSpaYIUBU1IG/EsDOX0vv+ github.com/hashicorp/terraform-plugin-go v0.29.0/go.mod h1:vYZbIyvxyy0FWSmDHChCqKvI40cFTDGSb3D8D70i9GM= github.com/hashicorp/terraform-plugin-log v0.10.0 h1:eu2kW6/QBVdN4P3Ju2WiB2W3ObjkAsyfBsL3Wh1fj3g= github.com/hashicorp/terraform-plugin-log v0.10.0/go.mod h1:/9RR5Cv2aAbrqcTSdNmY1NRHP4E3ekrXRGjqORpXyB0= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.2 h1:sy0Bc4A/GZNdmwpVX/Its9aIweCfY9fRfY1IgmXkOj8= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.2/go.mod h1:MQisArXYCowb/5q4lDS/BWp5KnXiZ4lxOIyrpKBpUBE= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 h1:mlAq/OrMlg04IuJT7NpefI1wwtdpWudnEmjuQs04t/4= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1/go.mod h1:GQhpKVvvuwzD79e8/NZ+xzj+ZpWovdPAe8nfV/skwNU= github.com/hashicorp/terraform-plugin-testing v1.14.0 h1:5t4VKrjOJ0rg0sVuSJ86dz5K7PHsMO6OKrHFzDBerWA= github.com/hashicorp/terraform-plugin-testing v1.14.0/go.mod h1:1qfWkecyYe1Do2EEOK/5/WnTyvC8wQucUkkhiGLg5nk= github.com/hashicorp/terraform-registry-address v0.4.0 h1:S1yCGomj30Sao4l5BMPjTGZmCNzuv7/GDTDX99E9gTk= @@ -463,62 +107,21 @@ github.com/hashicorp/terraform-svchost v0.2.0 h1:wVc2vMiodOHvNZcQw/3y9af1XSomgjG github.com/hashicorp/terraform-svchost v0.2.0/go.mod h1:/98rrS2yZsbppi4VGVCjwYmh8dqsKzISqK7Hli+0rcQ= github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8= github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns= -github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= -github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= -github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= -github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/ivanpirog/coloredcobra v1.0.1 h1:aURSdEmlR90/tSiWS0dMjdwOvCVUeYLfltLfbgNxrN4= github.com/ivanpirog/coloredcobra v1.0.1/go.mod h1:iho4nEKcnwZFiniGSdcgdvRgZNjxm+h20acv8vqmN6Q= -github.com/jarcoal/httpmock v1.4.1 h1:0Ju+VCFuARfFlhVXFc2HxlcQkfB+Xq12/EotHko+x2A= -github.com/jarcoal/httpmock v1.4.1/go.mod h1:ftW1xULwo+j0R0JJkJIIi7UKigZUXCLLanykgjwBXL0= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jgautheron/goconst v1.8.2 h1:y0XF7X8CikZ93fSNT6WBTb/NElBu9IjaY7CCYQrCMX4= -github.com/jgautheron/goconst v1.8.2/go.mod h1:A0oxgBCHy55NQn6sYpO7UdnA9p+h7cPtoOZUmvNIako= github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94= github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8= -github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs= -github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c= -github.com/jjti/go-spancheck v0.6.5 h1:lmi7pKxa37oKYIMScialXUK6hP3iY5F1gu+mLBPgYB8= -github.com/jjti/go-spancheck v0.6.5/go.mod h1:aEogkeatBrbYsyW6y5TgDfihCulDYciL1B7rG2vSsrU= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/julz/importas v0.2.0 h1:y+MJN/UdL63QbFJHws9BVC5RpA2iq0kpjrFajTGivjQ= -github.com/julz/importas v0.2.0/go.mod h1:pThlt589EnCYtMnmhmRYY/qn9lCf/frPOK+WMx3xiJY= -github.com/karamaru-alpha/copyloopvar v1.2.2 h1:yfNQvP9YaGQR7VaWLYcfZUlRP2eo2vhExWKxD/fP6q0= -github.com/karamaru-alpha/copyloopvar v1.2.2/go.mod h1:oY4rGZqZ879JkJMtX3RRkcXRkmUvH0x35ykgaKgsgJY= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/kisielk/errcheck v1.9.0 h1:9xt1zI9EBfcYBvdU1nVrzMzzUPUtPKs9bVSIM3TAb3M= -github.com/kisielk/errcheck v1.9.0/go.mod h1:kQxWMMVZgIkDq7U8xtG/n2juOjbLgZtedi0D+/VL/i8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kkHAIKE/contextcheck v1.1.6 h1:7HIyRcnyzxL9Lz06NGhiKvenXq7Zw6Q0UQu/ttjfJCE= -github.com/kkHAIKE/contextcheck v1.1.6/go.mod h1:3dDbMRNBFaq8HFXWC1JyvDSPm43CmE6IuHam8Wr0rkg= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -526,48 +129,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kulti/thelper v0.7.1 h1:fI8QITAoFVLx+y+vSyuLBP+rcVIB8jKooNSCT2EiI98= -github.com/kulti/thelper v0.7.1/go.mod h1:NsMjfQEy6sd+9Kfw8kCP61W1I0nerGSYSFnGaxQkcbs= -github.com/kunwardeep/paralleltest v1.0.15 h1:ZMk4Qt306tHIgKISHWFJAO1IDQJLc6uDyJMLyncOb6w= -github.com/kunwardeep/paralleltest v1.0.15/go.mod h1:di4moFqtfz3ToSKxhNjhOZL+696QtJGCFe132CbBLGk= -github.com/lasiar/canonicalheader v1.1.2 h1:vZ5uqwvDbyJCnMhmFYimgMZnJMjwljN5VGY0VKbMXb4= -github.com/lasiar/canonicalheader v1.1.2/go.mod h1:qJCeLFS0G/QlLQ506T+Fk/fWMa2VmBUiEI2cuMK4djI= -github.com/ldez/exptostd v0.4.5 h1:kv2ZGUVI6VwRfp/+bcQ6Nbx0ghFWcGIKInkG/oFn1aQ= -github.com/ldez/exptostd v0.4.5/go.mod h1:QRjHRMXJrCTIm9WxVNH6VW7oN7KrGSht69bIRwvdFsM= github.com/ldez/go-git-cmd-wrapper/v2 v2.9.1 h1:QJRB9Gs5i/h6TVJI6yl09Qm6rNooznRiKwIw+VIxd90= github.com/ldez/go-git-cmd-wrapper/v2 v2.9.1/go.mod h1:0eUeas7XtKDPKQbB0KijfaMPbuQ/cIprtoTRiwaUoFg= -github.com/ldez/gomoddirectives v0.8.0 h1:JqIuTtgvFC2RdH1s357vrE23WJF2cpDCPFgA/TWDGpk= -github.com/ldez/gomoddirectives v0.8.0/go.mod h1:jutzamvZR4XYJLr0d5Honycp4Gy6GEg2mS9+2YX3F1Q= -github.com/ldez/grignotin v0.10.1 h1:keYi9rYsgbvqAZGI1liek5c+jv9UUjbvdj3Tbn5fn4o= -github.com/ldez/grignotin v0.10.1/go.mod h1:UlDbXFCARrXbWGNGP3S5vsysNXAPhnSuBufpTEbwOas= -github.com/ldez/structtags v0.6.1 h1:bUooFLbXx41tW8SvkfwfFkkjPYvFFs59AAMgVg6DUBk= -github.com/ldez/structtags v0.6.1/go.mod h1:YDxVSgDy/MON6ariaxLF2X09bh19qL7MtGBN5MrvbdY= -github.com/ldez/tagliatelle v0.7.2 h1:KuOlL70/fu9paxuxbeqlicJnCspCRjH0x8FW+NfgYUk= -github.com/ldez/tagliatelle v0.7.2/go.mod h1:PtGgm163ZplJfZMZ2sf5nhUT170rSuPgBimoyYtdaSI= -github.com/ldez/usetesting v0.5.0 h1:3/QtzZObBKLy1F4F8jLuKJiKBjjVFi1IavpoWbmqLwc= -github.com/ldez/usetesting v0.5.0/go.mod h1:Spnb4Qppf8JTuRgblLrEWb7IE6rDmUpGvxY3iRrzvDQ= -github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY= -github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA= -github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= -github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= -github.com/macabu/inamedparam v0.2.0 h1:VyPYpOc10nkhI2qeNUdh3Zket4fcZjEWe35poddBCpE= -github.com/macabu/inamedparam v0.2.0/go.mod h1:+Pee9/YfGe5LJ62pYXqB89lJ+0k5bsR8Wgz/C0Zlq3U= -github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= -github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/manuelarte/embeddedstructfieldcheck v0.4.0 h1:3mAIyaGRtjK6EO9E73JlXLtiy7ha80b2ZVGyacxgfww= -github.com/manuelarte/embeddedstructfieldcheck v0.4.0/go.mod h1:z8dFSyXqp+fC6NLDSljRJeNQJJDWnY7RoWFzV3PC6UM= -github.com/manuelarte/funcorder v0.5.0 h1:llMuHXXbg7tD0i/LNw8vGnkDTHFpTnWqKPI85Rknc+8= -github.com/manuelarte/funcorder v0.5.0/go.mod h1:Yt3CiUQthSBMBxjShjdXMexmzpP8YGvGLjrxJNkO2hA= -github.com/maratori/testableexamples v1.0.1 h1:HfOQXs+XgfeRBJ+Wz0XfH+FHnoY9TVqL6Fcevpzy4q8= -github.com/maratori/testableexamples v1.0.1/go.mod h1:XE2F/nQs7B9N08JgyRmdGjYVGqxWwClLPCGSQhXQSrQ= -github.com/maratori/testpackage v1.1.2 h1:ffDSh+AgqluCLMXhM19f/cpvQAKygKAJXFl9aUjmbqs= -github.com/maratori/testpackage v1.1.2/go.mod h1:8F24GdVDFW5Ew43Et02jamrVMNXLUNaOynhDssITGfc= -github.com/matoous/godox v1.1.0 h1:W5mqwbyWrwZv6OQ5Z1a/DHGMOvXYCBP3+Ht7KMoJhq4= -github.com/matoous/godox v1.1.0/go.mod h1:jgE/3fUXiTurkdHOLT5WEkThTSuE7yxHv5iWPa80afs= -github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= -github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= @@ -576,227 +139,49 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/maxatome/go-testdeep v1.14.0 h1:rRlLv1+kI8eOI3OaBXZwb3O7xY3exRzdW5QyX48g9wI= -github.com/maxatome/go-testdeep v1.14.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM= -github.com/mgechev/revive v1.14.0 h1:CC2Ulb3kV7JFYt+izwORoS3VT/+Plb8BvslI/l1yZsc= -github.com/mgechev/revive v1.14.0/go.mod h1:MvnujelCZBZCaoDv5B3foPo6WWgULSSFxvfxp7GsPfo= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/moricho/tparallel v0.3.2 h1:odr8aZVFA3NZrNybggMkYO3rgPRcqjeQUlBBFVxKHTI= -github.com/moricho/tparallel v0.3.2/go.mod h1:OQ+K3b4Ln3l2TZveGCywybl68glfLEwFGqvnjok8b+U= -github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= -github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nakabonne/nestif v0.3.1 h1:wm28nZjhQY5HyYPx+weN3Q65k6ilSBxDb8v5S81B81U= -github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE= -github.com/nishanths/exhaustive v0.12.0 h1:vIY9sALmw6T/yxiASewa4TQcFsVYZQQRUQJhKRf3Swg= -github.com/nishanths/exhaustive v0.12.0/go.mod h1:mEZ95wPIZW+x8kC4TgC+9YCUgiST7ecevsVDTgc2obs= -github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= -github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= -github.com/nunnatsa/ginkgolinter v0.23.0 h1:x3o4DGYOWbBMP/VdNQKgSj+25aJKx2Pe6lHr8gBcgf8= -github.com/nunnatsa/ginkgolinter v0.23.0/go.mod h1:9qN1+0akwXEccwV1CAcCDfcoBlWXHB+ML9884pL4SZ4= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/run v1.2.0 h1:O8x3yXwah4A73hJdlrwo/2X6J62gE5qTMusH0dvz60E= github.com/oklog/run v1.2.0/go.mod h1:mgDbKRSwPhJfesJ4PntqFUbKQRZ50NgmZTSPlFA0YFk= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.28.1 h1:S4hj+HbZp40fNKuLUQOYLDgZLwNUVn19N3Atb98NCyI= -github.com/onsi/ginkgo/v2 v2.28.1/go.mod h1:CLtbVInNckU3/+gC8LzkGUb9oF+e8W8TdUsxPwvdOgE= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= -github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28= -github.com/onsi/gomega v1.39.1/go.mod h1:hL6yVALoTOxeWudERyfppUcZXjMwIMLnuSfruD2lcfg= -github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= -github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= -github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= -github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= -github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= -github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= -github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/pb33f/libopenapi v0.15.0 h1:AoBYIY3HXqDDF8O9kcudlqWaRFZZJmgtueE649oHzIw= -github.com/pb33f/libopenapi v0.15.0/go.mod h1:m+4Pwri31UvcnZjuP8M7TlbR906DXJmMvYsbis234xg= -github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= -github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= -github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4= github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/quasilyte/go-ruleguard v0.4.5 h1:AGY0tiOT5hJX9BTdx/xBdoCubQUAE2grkqY2lSwvZcA= -github.com/quasilyte/go-ruleguard v0.4.5/go.mod h1:Vl05zJ538vcEEwu16V/Hdu7IYZWyKSwIy4c88Ro1kRE= -github.com/quasilyte/go-ruleguard/dsl v0.3.23 h1:lxjt5B6ZCiBeeNO8/oQsegE6fLeCzuMRoVWSkXC4uvY= -github.com/quasilyte/go-ruleguard/dsl v0.3.23/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= -github.com/quasilyte/gogrep v0.5.0 h1:eTKODPXbI8ffJMN+W2aE0+oL0z/nh8/5eNdiO34SOAo= -github.com/quasilyte/gogrep v0.5.0/go.mod h1:Cm9lpz9NZjEoL1tgZ2OgeUKPIxL1meE7eo60Z6Sk+Ng= -github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 h1:TCg2WBOl980XxGFEZSS6KlBGIV0diGdySzxATTWoqaU= -github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= -github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4lu7Gd+PU1fV2/qnDNfzT635KRSObncs= -github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= -github.com/raeperd/recvcheck v0.2.0 h1:GnU+NsbiCqdC2XX5+vMZzP+jAJC5fht7rcVTAhX74UI= -github.com/raeperd/recvcheck v0.2.0/go.mod h1:n04eYkwIR0JbgD73wT8wL4JjPC3wm0nFtzBnWNocnYU= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= -github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryancurrah/gomodguard v1.4.1 h1:eWC8eUMNZ/wM/PWuZBv7JxxqT5fiIKSIyTvjb7Elr+g= -github.com/ryancurrah/gomodguard v1.4.1/go.mod h1:qnMJwV1hX9m+YJseXEBhd2s90+1Xn6x9dLz11ualI1I= -github.com/ryanrolds/sqlclosecheck v0.5.1 h1:dibWW826u0P8jNLsLN+En7+RqWWTYrjCB9fJfSfdyCU= -github.com/ryanrolds/sqlclosecheck v0.5.1/go.mod h1:2g3dUjoS6AL4huFdv6wn55WpLIDjY7ZgUR4J8HOO/XQ= -github.com/sanposhiho/wastedassign/v2 v2.1.0 h1:crurBF7fJKIORrV85u9UUpePDYGWnwvv3+A96WvwXT0= -github.com/sanposhiho/wastedassign/v2 v2.1.0/go.mod h1:+oSmSC+9bQ+VUAxA66nBb0Z7N8CK7mscKTDYC6aIek4= -github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ= -github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= -github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw= -github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ= -github.com/sashamelentyev/usestdlibvars v1.29.0 h1:8J0MoRrw4/NAXtjQqTHrbW9NN+3iMf7Knkq057v4XOQ= -github.com/sashamelentyev/usestdlibvars v1.29.0/go.mod h1:8PpnjHMk5VdeWlVb4wCdrB8PNbLqZ3wBZTZWkrpZZL8= -github.com/securego/gosec/v2 v2.23.0 h1:h4TtF64qFzvnkqvsHC/knT7YC5fqyOCItlVR8+ptEBo= -github.com/securego/gosec/v2 v2.23.0/go.mod h1:qRHEgXLFuYUDkI2T7W7NJAmOkxVhkR0x9xyHOIcMNZ0= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= -github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= -github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= -github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w= -github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g= -github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+Wwfd0XE= -github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4= github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8= github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY= -github.com/sonatard/noctx v0.4.0 h1:7MC/5Gg4SQ4lhLYR6mvOP6mQVSxCrdyiExo7atBs27o= -github.com/sonatard/noctx v0.4.0/go.mod h1:64XdbzFb18XL4LporKXp8poqZtPKbCrqQ402CV+kJas= -github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0= -github.com/sourcegraph/go-diff v0.7.0/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= -github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= -github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= -github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= -github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= -github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= -github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0= -github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= -github.com/stackitcloud/stackit-sdk-go/core v0.21.1 h1:Y/PcAgM7DPYMNqum0MLv4n1mF9ieuevzcCIZYQfm3Ts= -github.com/stackitcloud/stackit-sdk-go/core v0.21.1/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI= +github.com/stackitcloud/stackit-sdk-go/core v0.21.0 h1:QXZqiaO7U/4IpTkJfzt4dt6QxJzG2uUS12mBnHpYNik= +github.com/stackitcloud/stackit-sdk-go/core v0.21.0/go.mod h1:fqto7M82ynGhEnpZU6VkQKYWYoFG5goC076JWXTUPRQ= github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha h1:ugpMOMUZGB0yXsWcfe97F7GCdjlexbjFuGD8ZeyMSts= github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.23-alpha/go.mod h1:v5VGvTxLcCdJJmblbhqYalt/MFHcElDfYoy15CMhaWs= -github.com/stbenjam/no-sprintf-host-port v0.3.1 h1:AyX7+dxI4IdLBPtDbsGAyqiTSLpCP9hWRrXQDU4Cm/g= -github.com/stbenjam/no-sprintf-host-port v0.3.1/go.mod h1:ODbZesTCHMVKthBHskvUUexdcNHAQRXk9NpSsL8p/HQ= +github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.4.1 h1:6MJdy1xmdE+uOo/F8mR5HSldjPSHpdhwuqS3u9m2EWQ= +github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.4.1/go.mod h1:XLr3ZfrT1g8ZZMm7A6RXOPBuhBkikdUN2o/+/Y+Hu+g= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= -github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/teambition/rrule-go v1.8.2 h1:lIjpjvWTj9fFUZCmuoVDrKVOtdiyzbzc93qTmRVe/J8= github.com/teambition/rrule-go v1.8.2/go.mod h1:Ieq5AbrKGciP1V//Wq8ktsTXwSwJHDD5mD/wLBGl3p4= -github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= -github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= -github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= -github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= -github.com/tetafro/godot v1.5.4 h1:u1ww+gqpRLiIA16yF2PV1CV1n/X3zhyezbNXC3E14Sg= -github.com/tetafro/godot v1.5.4/go.mod h1:eOkMrVQurDui411nBY2FA05EYH01r14LuWY/NrVDVcU= -github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 h1:9LPGD+jzxMlnk5r6+hJnar67cgpDIz/iyD+rfl5r2Vk= -github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460= -github.com/timonwong/loggercheck v0.11.0 h1:jdaMpYBl+Uq9mWPXv1r8jc5fC3gyXx4/WGwTnnNKn4M= -github.com/timonwong/loggercheck v0.11.0/go.mod h1:HEAWU8djynujaAVX7QI65Myb8qgfcZ1uKbdpg3ZzKl8= -github.com/tomarrell/wrapcheck/v2 v2.12.0 h1:H/qQ1aNWz/eeIhxKAFvkfIA+N7YDvq6TWVFL27Of9is= -github.com/tomarrell/wrapcheck/v2 v2.12.0/go.mod h1:AQhQuZd0p7b6rfW+vUwHm5OMCGgp63moQ9Qr/0BpIWo= -github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= -github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= -github.com/ultraware/funlen v0.2.0 h1:gCHmCn+d2/1SemTdYMiKLAHFYxTYz7z9VIDRaTGyLkI= -github.com/ultraware/funlen v0.2.0/go.mod h1:ZE0q4TsJ8T1SQcjmkhN/w+MceuatI6pBFSxxyteHIJA= -github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSWoFa+g= -github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= -github.com/uudashr/gocognit v1.2.0 h1:3BU9aMr1xbhPlvJLSydKwdLN3tEUUrzPSSM8S4hDYRA= -github.com/uudashr/gocognit v1.2.0/go.mod h1:k/DdKPI6XBZO1q7HgoV2juESI2/Ofj9AcHPZhBBdrTU= -github.com/uudashr/iface v1.4.1 h1:J16Xl1wyNX9ofhpHmQ9h9gk5rnv2A6lX/2+APLTo0zU= -github.com/uudashr/iface v1.4.1/go.mod h1:pbeBPlbuU2qkNDn0mmfrxP2X+wjPMIQAy+r1MBXSXtg= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -804,483 +189,95 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk= -github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ= -github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= -github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= -github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xen0n/gosmopolitan v1.3.0 h1:zAZI1zefvo7gcpbCOrPSHJZJYA9ZgLfJqtKzZ5pHqQM= -github.com/xen0n/gosmopolitan v1.3.0/go.mod h1:rckfr5T6o4lBtM1ga7mLGKZmLxswUoH1zxHgNXOsEt4= -github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= -github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= -github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM= -github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk= -github.com/yeya24/promlinter v0.3.0 h1:JVDbMp08lVCP7Y6NP3qHroGAO6z2yGKQtS5JsjqtoFs= -github.com/yeya24/promlinter v0.3.0/go.mod h1:cDfJQQYv9uYciW60QT0eeHlFodotkYZlL+YcPQN+mW4= -github.com/ykadowak/zerologlint v0.1.5 h1:Gy/fMz1dFQN9JZTPjv1hxEk+sRWm05row04Yoolgdiw= -github.com/ykadowak/zerologlint v0.1.5/go.mod h1:KaUskqF3e/v59oPmdq1U1DnKcuHokl2/K1U4pmIELKg= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yuin/goldmark v1.7.7 h1:5m9rrB1sW3JUMToKFQfb+FGt1U7r57IHu5GrYrG2nqU= -github.com/yuin/goldmark v1.7.7/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= -github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= -github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= github.com/zclconf/go-cty v1.17.0 h1:seZvECve6XX4tmnvRzWtJNHdscMtYEx5R7bnnVyd/d0= github.com/zclconf/go-cty v1.17.0/go.mod h1:wqFzcImaLTI6A5HfsRwB0nj5n0MRZFwmey8YoFPPs3U= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= -gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo= -gitlab.com/bosi/decorder v0.4.2/go.mod h1:muuhHoaJkA9QLcYHq4Mj8FJUwDZ+EirSHRiaTcTf6T8= -go-simpler.org/assert v0.9.0 h1:PfpmcSvL7yAnWyChSjOz6Sp6m9j5lyK8Ok9pEL31YkQ= -go-simpler.org/assert v0.9.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28= -go-simpler.org/musttag v0.14.0 h1:XGySZATqQYSEV3/YTy+iX+aofbZZllJaqwFWs+RTtSo= -go-simpler.org/musttag v0.14.0/go.mod h1:uP8EymctQjJ4Z1kUnjX0u2l60WfUdQxCwSNKzE1JEOE= -go-simpler.org/sloglint v0.11.1 h1:xRbPepLT/MHPTCA6TS/wNfZrDzkGvCCqUv4Bdwc3H7s= -go-simpler.org/sloglint v0.11.1/go.mod h1:2PowwiCOK8mjiF+0KGifVOT8ZsCNiFzvfyJeJOIt8MQ= -go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw= -go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU= -go.augendre.info/arangolint v0.4.0 h1:xSCZjRoS93nXazBSg5d0OGCi9APPLNMmmLrC995tR50= -go.augendre.info/arangolint v0.4.0/go.mod h1:l+f/b4plABuFISuKnTGD4RioXiCCgghv2xqst/xOvAA= -go.augendre.info/fatcontext v0.9.0 h1:Gt5jGD4Zcj8CDMVzjOJITlSb9cEch54hjRRlN3qDojE= -go.augendre.info/fatcontext v0.9.0/go.mod h1:L94brOAT1OOUNue6ph/2HnwxoNlds9aXDF2FcUntbNw= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= -go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48= -go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8= -go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0= -go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs= -go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18= -go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE= -go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8= -go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew= -go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI= -go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= -go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= +go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= +go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= +go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= +go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= +go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= +go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= +go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= +go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= +go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts= -golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o= -golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8= -golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 h1:qWFG1Dj7TBjOjOvhEOkmyGPVoquqUKnIU0lEVLp8xyk= -golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358/go.mod h1:4Mzdyp/6jzw9auFDJ3OMF5qksa7UvPnzKqTVGcb04ms= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8= +golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8= -golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= +golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= -golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60= -golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= +golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k= -golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/telemetry v0.0.0-20260209163413-e7419c687ee4 h1:bTLqdHv7xrGlFbvf5/TXNxy/iUwwdkjhqQTJDjW7aj0= -golang.org/x/telemetry v0.0.0-20260209163413-e7419c687ee4/go.mod h1:g5NllXBEermZrmR51cJDQxmJUHUOfRAaNyWBM+R+548= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/telemetry v0.0.0-20260116145544-c6413dc483f5 h1:i0p03B68+xC1kD2QUO8JzDTPXCzhN56OLJ+IhHY8U3A= +golang.org/x/telemetry v0.0.0-20260116145544-c6413dc483f5/go.mod h1:b7fPSJ0pKZ3ccUh8gnTONJxhn3c/PS6tyzQvyqw4iA8= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= -golang.org/x/term v0.40.0 h1:36e4zGLqU4yhjlmxEaagx2KuYbJq3EwY8K943ZsHcvg= -golang.org/x/term v0.40.0/go.mod h1:w2P8uVp06p2iyKKuvXIm7N/y0UCRt3UfJTfZ7oOpglM= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY= +golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= -golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200724022722-7017fd6b1305/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.1-0.20210205202024-ef80cdb6ec6d/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= -golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= -golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= -golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k= -golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0= -golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= -golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= -golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= -golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= +golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc= +golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 h1:mWPCjDEyshlQYzBpMNHaEof6UX1PmHcaUODUywQ0uac= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.79.1 h1:zGhSi45ODB9/p3VAawt9a+O/MULLl9dpizzNNpq7flY= -google.golang.org/grpc v1.79.1/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516 h1:sNrWoksmOyF5bvJUcnmbeAmQi8baNhqg5IWaI3llQqU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ= +google.golang.org/grpc v1.78.0 h1:K1XZG/yGDJnzMdd/uZHAkVqJE+xIDOcmdSFZkBUicNc= +google.golang.org/grpc v1.78.0/go.mod h1:I47qjTo4OKbMkjA/aOOwxDIiPSBofUtQUI5EfpWvW7U= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.7.0 h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU= -honnef.co/go/tools v0.7.0/go.mod h1:pm29oPxeP3P82ISxZDgIYeOaf9ta6Pi0EWvCFoLG2vc= -mvdan.cc/gofumpt v0.9.2 h1:zsEMWL8SVKGHNztrx6uZrXdp7AX8r421Vvp23sz7ik4= -mvdan.cc/gofumpt v0.9.2/go.mod h1:iB7Hn+ai8lPvofHd9ZFGVg2GOr8sBUw1QUWjNbmIL/s= -mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15 h1:ssMzja7PDPJV8FStj7hq9IKiuiKhgz9ErWw+m68e7DI= -mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15/go.mod h1:4M5MMXl2kW6fivUT6yRGpLLPNfuGtU2Z0cPvFquGDYU= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/golang-ci.yaml b/golang-ci.yaml index 11f74066..b3f00eb7 100644 --- a/golang-ci.yaml +++ b/golang-ci.yaml @@ -2,13 +2,6 @@ version: "2" run: concurrency: 4 -output: - formats: - text: - print-linter-name: true - print-issued-lines: true - colors: true - path: stdout linters: enable: - bodyclose @@ -31,11 +24,6 @@ linters: rules: main: list-mode: lax - allow: - - tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview - - github.com/hashicorp/terraform-plugin-framework - - github.com/hashicorp/terraform-plugin-log - - github.com/stackitcloud/stackit-sdk-go deny: - pkg: github.com/stretchr/testify desc: Do not use a testing framework @@ -75,18 +63,13 @@ linters: - name: empty-lines - name: early-return exclusions: - paths: - - stackit-sdk-generator/ - - generated/ - - pkg_gen/ generated: lax - warn-unused: true - # Excluding configuration per-path, per-linter, per-text and per-source. - rules: - # Exclude some linters from running on tests files. - - path: _test\.go - linters: - - gochecknoinits + paths: + - third_party$ + - builtin$ + - examples$ + - tools/copy.go + - tools/main.go formatters: enable: - gofmt @@ -94,4 +77,10 @@ formatters: settings: goimports: local-prefixes: - - tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview \ No newline at end of file + - github.com/freiheit-com/nmww + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/internal/testutils/activateMocks.go b/internal/testutils/activateMocks.go deleted file mode 100644 index c8f7dd05..00000000 --- a/internal/testutils/activateMocks.go +++ /dev/null @@ -1,39 +0,0 @@ -package testutils - -import ( - "fmt" - "net/http" - "path/filepath" - "regexp" - "runtime" - "strings" - - "github.com/jarcoal/httpmock" -) - -func TestName() string { - pc, _, _, _ := runtime.Caller(1) - nameFull := runtime.FuncForPC(pc).Name() - nameEnd := filepath.Ext(nameFull) - name := strings.TrimPrefix(nameEnd, ".") - return name -} - -func ActivateEnvironmentHttpMocks() { - httpmock.RegisterNoResponder( - func(req *http.Request) (*http.Response, error) { - return nil, fmt.Errorf("no responder found for %s %s, please check your http mocks", req.Method, req.URL) - }, - ) - - httpmock.RegisterRegexpResponder( - "GET", - regexp.MustCompile(`^https://api\.bap\.microsoft\.com/providers/Microsoft\.BusinessAppPlatform/locations/(europe|unitedstates)/environmentLanguages\?api-version=2023-06-01$`), - func(_ *http.Request) (*http.Response, error) { - return httpmock.NewStringResponse( - http.StatusOK, - httpmock.File("../../services/languages/tests/datasource/Validate_Read/get_languages.json").String(), - ), nil - }, - ) -} diff --git a/internal/testutils/functions.go b/internal/testutils/functions.go index 3e748941..0006751a 100644 --- a/internal/testutils/functions.go +++ b/internal/testutils/functions.go @@ -88,7 +88,7 @@ func CleanupTemporaryHome(tempHomePath string, t *testing.T) { } func ucFirst(s string) string { - if s == "" { + if len(s) == 0 { return "" } return strings.ToUpper(s[:1]) + s[1:] diff --git a/internal/testutils/testutils.go b/internal/testutils/testutils.go index 933dab0e..c35c332c 100644 --- a/internal/testutils/testutils.go +++ b/internal/testutils/testutils.go @@ -113,7 +113,7 @@ func GetTestProjectServiceAccountJson(path string) string { return token } -// func GetTestProjectServiceAccountToken(path string) string { +//func GetTestProjectServiceAccountToken(path string) string { // var err error // token, tokenSet := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN") // if !tokenSet || token == "" { @@ -125,7 +125,7 @@ func GetTestProjectServiceAccountJson(path string) string { // return token //} // -// func readTestTokenFromCredentialsFile(path string) (string, error) { +//func readTestTokenFromCredentialsFile(path string) (string, error) { // if path == "" { // customPath, customPathSet := os.LookupEnv("STACKIT_CREDENTIALS_PATH") // if !customPathSet || customPath == "" { diff --git a/main.go b/main.go index ab603dd6..6d7793da 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "log" "github.com/hashicorp/terraform-plugin-framework/providerserver" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit" ) diff --git a/sample/postgres/postresql.tf b/sample/postgres/postresql.tf index 531b17e2..fa2f49e8 100644 --- a/sample/postgres/postresql.tf +++ b/sample/postgres/postresql.tf @@ -65,15 +65,15 @@ resource "stackitprivatepreview_postgresflexalpha_instance" "msh-sna-pe-example2 resource "stackitprivatepreview_postgresflexalpha_user" "ptlsdbadminuser" { project_id = var.project_id instance_id = stackitprivatepreview_postgresflexalpha_instance.msh-sna-pe-example.instance_id - name = var.db_admin_username - roles = ["createdb", "login", "login"] + username = var.db_admin_username + roles = ["createdb", "login"] # roles = ["createdb", "login", "createrole"] } resource "stackitprivatepreview_postgresflexalpha_user" "ptlsdbadminuser2" { project_id = var.project_id instance_id = stackitprivatepreview_postgresflexalpha_instance.msh-sna-pe-example2.instance_id - name = var.db_admin_username + username = var.db_admin_username roles = ["createdb", "login"] # roles = ["createdb", "login", "createrole"] } @@ -81,7 +81,7 @@ resource "stackitprivatepreview_postgresflexalpha_user" "ptlsdbadminuser2" { resource "stackitprivatepreview_postgresflexalpha_user" "ptlsdbuser" { project_id = var.project_id instance_id = stackitprivatepreview_postgresflexalpha_instance.msh-sna-pe-example.instance_id - name = var.db_name + username = var.db_username roles = ["login"] # roles = ["createdb", "login", "createrole"] } diff --git a/sample/sqlserver/flavor.tf b/sample/sqlserver/flavor.tf index c491cc09..216c8f1e 100644 --- a/sample/sqlserver/flavor.tf +++ b/sample/sqlserver/flavor.tf @@ -1,5 +1,5 @@ -data "stackitprivatepreview_sqlserverflexbeta_flavor" "sqlserver_flavor" { +data "stackitprivatepreview_sqlserverflexalpha_flavor" "sqlserver_flavor" { project_id = var.project_id region = "eu01" cpu = 4 @@ -9,5 +9,5 @@ data "stackitprivatepreview_sqlserverflexbeta_flavor" "sqlserver_flavor" { } output "sqlserver_flavor" { - value = data.stackitprivatepreview_sqlserverflexbeta_flavor.sqlserver_flavor.flavor_id + value = data.stackitprivatepreview_sqlserverflexalpha_flavor.sqlserver_flavor.flavor_id } diff --git a/sample/sqlserver/sqlserver.tf b/sample/sqlserver/sqlserver.tf index d18f499c..bf6a88d1 100644 --- a/sample/sqlserver/sqlserver.tf +++ b/sample/sqlserver/sqlserver.tf @@ -18,15 +18,15 @@ # value = stackit_kms_key.key.key_id # } -resource "stackitprivatepreview_sqlserverflexbeta_instance" "msh-beta-sna-001" { +resource "stackitprivatepreview_sqlserverflexalpha_instance" "msh-sna-001" { project_id = var.project_id - name = "msh-beta-sna-001" + name = "msh-sna-001" backup_schedule = "0 3 * * *" retention_days = 31 - flavor_id = data.stackitprivatepreview_sqlserverflexbeta_flavor.sqlserver_flavor.flavor_id + flavor_id = data.stackitprivatepreview_sqlserverflexalpha_flavor.sqlserver_flavor.flavor_id storage = { class = "premium-perf2-stackit" - size = 10 + size = 50 } version = 2022 encryption = { @@ -34,11 +34,9 @@ resource "stackitprivatepreview_sqlserverflexbeta_instance" "msh-beta-sna-001" { #keyring_id = stackit_kms_keyring.keyring.keyring_id #key_version = 1 # key with scope public - # kek_key_id = "fe039bcf-8d7b-431a-801d-9e81371a6b7b" - kek_key_id = "c6878f92-ce55-4b79-8236-ba9d001d7967" # msh-k-001 + kek_key_id = "fe039bcf-8d7b-431a-801d-9e81371a6b7b" # key_id = var.key_id - # kek_key_ring_id = var.keyring_id - kek_key_ring_id = "0dea3f5f-9947-4dda-a9d3-18418832cefe" # msh-kr-sna01 + kek_key_ring_id = var.keyring_id kek_key_version = var.key_version service_account = var.sa_email } @@ -48,16 +46,83 @@ resource "stackitprivatepreview_sqlserverflexbeta_instance" "msh-beta-sna-001" { } } -resource "stackitprivatepreview_sqlserverflexbeta_user" "betauser" { - project_id = var.project_id - instance_id = stackitprivatepreview_sqlserverflexbeta_instance.msh-beta-sna-001.instance_id - username = "betauser" - roles = ["##STACKIT_DatabaseManager##", "##STACKIT_LoginManager##"] +resource "stackitprivatepreview_sqlserverflexalpha_instance" "msh-sna-101" { + project_id = var.project_id + name = "msh-sna-101" + backup_schedule = "0 3 * * *" + retention_days = 31 + flavor_id = data.stackitprivatepreview_sqlserverflexalpha_flavor.sqlserver_flavor.flavor_id + storage = { + class = "premium-perf2-stackit" + size = 50 + } + version = 2022 + encryption = { + #key_id = stackit_kms_key.key.key_id + #keyring_id = stackit_kms_keyring.keyring.keyring_id + #key_version = 1 + # key with scope public + kek_key_id = "fe039bcf-8d7b-431a-801d-9e81371a6b7b" + # key_id = var.key_id + kek_key_ring_id = var.keyring_id + kek_key_version = var.key_version + service_account = var.sa_email + } + network = { + acl = ["0.0.0.0/0", "193.148.160.0/19"] + access_scope = "SNA" + } } -resource "stackitprivatepreview_sqlserverflexbeta_database" "betadb" { - project_id = var.project_id - instance_id = stackitprivatepreview_sqlserverflexbeta_instance.msh-beta-sna-001.instance_id - name = "mshtest002" - owner = stackitprivatepreview_sqlserverflexbeta_user.betauser.username +resource "stackitprivatepreview_sqlserverflexalpha_instance" "msh-nosna-001" { + project_id = var.project_id + name = "msh-nosna-001" + backup_schedule = "0 3 * * *" + retention_days = 31 + flavor_id = data.stackitprivatepreview_sqlserverflexalpha_flavor.sqlserver_flavor.flavor_id + storage = { + class = "premium-perf2-stackit" + size = 50 + } + version = 2022 + # encryption = { + # #key_id = stackit_kms_key.key.key_id + # #keyring_id = stackit_kms_keyring.keyring.keyring_id + # #key_version = 1 + # #key_id = var.key_id + # # key with scope public + # key_id = "fe039bcf-8d7b-431a-801d-9e81371a6b7b" + # keyring_id = var.keyring_id + # key_version = var.key_version + # service_account = var.sa_email + # } + network = { + acl = ["0.0.0.0/0", "193.148.160.0/19"] + access_scope = "PUBLIC" + } } + +# data "stackitprivatepreview_sqlserverflexalpha_instance" "test" { +# project_id = var.project_id +# instance_id = var.instance_id +# region = "eu01" +# } + +# output "test" { +# value = data.stackitprivatepreview_sqlserverflexalpha_instance.test +# } + +# resource "stackitprivatepreview_sqlserverflexalpha_user" "ptlsdbadminuser" { +# project_id = var.project_id +# instance_id = stackitprivatepreview_sqlserverflexalpha_instance.sqlsrv.instance_id +# username = var.db_admin_username +# roles = ["##STACKIT_LoginManager##", "##STACKIT_DatabaseManager##"] +# } + +# resource "stackitprivatepreview_sqlserverflexalpha_user" "ptlsdbuser" { +# project_id = var.project_id +# instance_id = stackitprivatepreview_sqlserverflexalpha_instance.sqlsrv.instance_id +# username = var.db_username +# roles = ["##STACKIT_LoginManager##"] +# } + diff --git a/scripts/lint-golangci-lint.sh b/scripts/lint-golangci-lint.sh new file mode 100755 index 00000000..0a883589 --- /dev/null +++ b/scripts/lint-golangci-lint.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# This script lints the SDK modules and the internal examples +# Pre-requisites: golangci-lint +set -eo pipefail + +ROOT_DIR=$(git rev-parse --show-toplevel) +GOLANG_CI_YAML_PATH="${ROOT_DIR}/golang-ci.yaml" +GOLANG_CI_ARGS="--allow-parallel-runners --timeout=5m --config=${GOLANG_CI_YAML_PATH}" + +if type -p golangci-lint >/dev/null; then + : +else + echo "golangci-lint not installed, unable to proceed." + exit 1 +fi + +cd ${ROOT_DIR} +golangci-lint run ${GOLANG_CI_ARGS} diff --git a/scripts/project.sh b/scripts/project.sh index 68585774..1d570c6a 100755 --- a/scripts/project.sh +++ b/scripts/project.sh @@ -17,7 +17,11 @@ elif [ "$action" = "tools" ]; then go mod download - go install golang.org/x/tools/cmd/goimports@v0.42.0 + # go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0 + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2 + + # go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.21.0 + go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.24.0 else echo "Invalid action: '$action', please use $0 help for help" fi diff --git a/scripts/tfplugindocs.sh b/scripts/tfplugindocs.sh index e77b6a98..6f9d5d1b 100755 --- a/scripts/tfplugindocs.sh +++ b/scripts/tfplugindocs.sh @@ -14,5 +14,5 @@ fi mkdir -p ${ROOT_DIR}/docs echo ">> Generating documentation" -go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate \ +tfplugindocs generate \ --provider-name "stackitprivatepreview" diff --git a/stackit/internal/conversion/conversion.go b/stackit/internal/conversion/conversion.go index 48871213..cd4c3bfa 100644 --- a/stackit/internal/conversion/conversion.go +++ b/stackit/internal/conversion/conversion.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" ) diff --git a/stackit/internal/conversion/conversion_test.go b/stackit/internal/conversion/conversion_test.go index ac5f4535..5e6c2445 100644 --- a/stackit/internal/conversion/conversion_test.go +++ b/stackit/internal/conversion/conversion_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-framework/diag" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "github.com/google/go-cmp/cmp" diff --git a/stackit/internal/core/core.go b/stackit/internal/core/core.go index 3680ae65..d3ea252c 100644 --- a/stackit/internal/core/core.go +++ b/stackit/internal/core/core.go @@ -32,7 +32,7 @@ const ( type EphemeralProviderData struct { ProviderData - PrivateKey string //nolint:gosec //this is a placeholder and not used in this code + PrivateKey string PrivateKeyPath string ServiceAccountKey string ServiceAccountKeyPath string @@ -105,13 +105,11 @@ func DiagsToError(diags diag.Diagnostics) error { diagsError := diags.Errors() diagsStrings := make([]string, 0) for _, diagnostic := range diagsError { - diagsStrings = append( - diagsStrings, fmt.Sprintf( - "(%s) %s", - diagnostic.Summary(), - diagnostic.Detail(), - ), - ) + diagsStrings = append(diagsStrings, fmt.Sprintf( + "(%s) %s", + diagnostic.Summary(), + diagnostic.Detail(), + )) } return fmt.Errorf("%s", strings.Join(diagsStrings, ";")) } @@ -138,22 +136,14 @@ func LogAndAddWarning(ctx context.Context, diags *diag.Diagnostics, summary, det func LogAndAddWarningBeta(ctx context.Context, diags *diag.Diagnostics, name string, resourceType ResourceType) { warnTitle := fmt.Sprintf("The %s %q is in beta", resourceType, name) - warnContent := fmt.Sprintf( - "The %s %q is in beta and may be subject to breaking changes in the future. Use with caution.", - resourceType, - name, - ) + warnContent := fmt.Sprintf("The %s %q is in beta and may be subject to breaking changes in the future. Use with caution.", resourceType, name) tflog.Warn(ctx, fmt.Sprintf("%s | %s", warnTitle, warnContent)) diags.AddWarning(warnTitle, warnContent) } func LogAndAddErrorBeta(ctx context.Context, diags *diag.Diagnostics, name string, resourceType ResourceType) { errTitle := fmt.Sprintf("The %s %q is in beta and beta is not enabled", resourceType, name) - errContent := fmt.Sprintf( - `The %s %q is in beta and the beta functionality is currently not enabled. To enable it, set the environment variable STACKIT_TF_ENABLE_BETA_RESOURCES to "true" or set the "enable_beta_resources" provider field to true.`, - resourceType, - name, - ) + errContent := fmt.Sprintf(`The %s %q is in beta and the beta functionality is currently not enabled. To enable it, set the environment variable STACKIT_TF_ENABLE_BETA_RESOURCES to "true" or set the "enable_beta_resources" provider field to true.`, resourceType, name) tflog.Error(ctx, fmt.Sprintf("%s | %s", errTitle, errContent)) diags.AddError(errTitle, errContent) } @@ -171,10 +161,8 @@ func LogResponse(ctx context.Context) context.Context { traceId := runtime.GetTraceId(ctx) ctx = tflog.SetField(ctx, "x-trace-id", traceId) - tflog.Info( - ctx, "response data", map[string]interface{}{ - "x-trace-id": traceId, - }, - ) + tflog.Info(ctx, "response data", map[string]interface{}{ + "x-trace-id": traceId, + }) return ctx } diff --git a/stackit/internal/core/retry_round_tripper.go b/stackit/internal/core/retry_round_tripper.go deleted file mode 100644 index 568be431..00000000 --- a/stackit/internal/core/retry_round_tripper.go +++ /dev/null @@ -1,237 +0,0 @@ -package core - -import ( - "context" - "crypto/rand" - "errors" - "fmt" - "math/big" - "net/http" - "time" - - "github.com/hashicorp/terraform-plugin-log/tflog" -) - -const ( - // backoffMultiplier is the factor by which the delay is multiplied for exponential backoff. - backoffMultiplier = 2 - // jitterFactor is the divisor used to calculate jitter (e.g., half of the base delay). - jitterFactor = 2 -) - -var ( - // ErrRequestFailedAfterRetries is returned when a request fails after all retry attempts. - ErrRequestFailedAfterRetries = errors.New("request failed after all retry attempts") -) - -// RetryRoundTripper implements an http.RoundTripper that adds automatic retry logic for failed requests. -type RetryRoundTripper struct { - next http.RoundTripper - maxRetries int - initialDelay time.Duration - maxDelay time.Duration - perTryTimeout time.Duration -} - -// NewRetryRoundTripper creates a new instance of the RetryRoundTripper with the specified configuration. -func NewRetryRoundTripper( - next http.RoundTripper, - maxRetries int, - initialDelay, maxDelay, perTryTimeout time.Duration, -) *RetryRoundTripper { - return &RetryRoundTripper{ - next: next, - maxRetries: maxRetries, - initialDelay: initialDelay, - maxDelay: maxDelay, - perTryTimeout: perTryTimeout, - } -} - -// RoundTrip executes the request and retries on failure. -func (rrt *RetryRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { - resp, err := rrt.executeRequest(req) - if !rrt.shouldRetry(resp, err) { - if err != nil { - return resp, fmt.Errorf("initial request failed, not retrying: %w", err) - } - - return resp, nil - } - - return rrt.retryLoop(req, resp, err) -} - -// executeRequest performs a single HTTP request with a per-try timeout. -func (rrt *RetryRoundTripper) executeRequest(req *http.Request) (*http.Response, error) { - ctx, cancel := context.WithTimeout(req.Context(), rrt.perTryTimeout) - defer cancel() - - resp, err := rrt.next.RoundTrip(req.WithContext(ctx)) - if err != nil { - if errors.Is(err, context.DeadlineExceeded) { - return resp, fmt.Errorf("per-try timeout of %v exceeded: %w", rrt.perTryTimeout, err) - } - - return resp, fmt.Errorf("http roundtrip failed: %w", err) - } - - return resp, nil -} - -// retryLoop handles the retry logic for a failed request. -func (rrt *RetryRoundTripper) retryLoop( - req *http.Request, - initialResp *http.Response, - initialErr error, -) (*http.Response, error) { - var ( - lastErr = initialErr - resp = initialResp - currentDelay = rrt.initialDelay - ) - - ctx := req.Context() - - for attempt := 1; attempt <= rrt.maxRetries; attempt++ { - rrt.logRetryAttempt(ctx, attempt, currentDelay, lastErr) - - waitDuration := rrt.calculateWaitDurationWithJitter(ctx, currentDelay) - if err := rrt.waitForDelay(ctx, waitDuration); err != nil { - return nil, err // Context was canceled during wait. - } - - // Exponential backoff for the next potential retry. - currentDelay = rrt.updateCurrentDelay(currentDelay) - - // Retry attempt. - resp, lastErr = rrt.executeRequest(req) - if !rrt.shouldRetry(resp, lastErr) { - if lastErr != nil { - return resp, fmt.Errorf("request failed on retry attempt %d: %w", attempt, lastErr) - } - - return resp, nil - } - } - - return nil, rrt.handleFinalError(ctx, resp, lastErr) -} - -// logRetryAttempt logs the details of a retry attempt. -func (rrt *RetryRoundTripper) logRetryAttempt( - ctx context.Context, - attempt int, - delay time.Duration, - err error, -) { - tflog.Info( - ctx, "Request failed, retrying...", map[string]interface{}{ - "attempt": attempt, - "max_attempts": rrt.maxRetries, - "delay": delay, - "error": err, - }, - ) -} - -// updateCurrentDelay calculates the next delay for exponential backoff. -func (rrt *RetryRoundTripper) updateCurrentDelay(currentDelay time.Duration) time.Duration { - currentDelay *= backoffMultiplier - if currentDelay > rrt.maxDelay { - return rrt.maxDelay - } - - return currentDelay -} - -// handleFinalError constructs and returns the final error after all retries have been exhausted. -func (rrt *RetryRoundTripper) handleFinalError( - ctx context.Context, - resp *http.Response, - lastErr error, -) error { - if resp != nil { - if err := resp.Body.Close(); err != nil { - tflog.Warn( - ctx, "Failed to close response body", map[string]interface{}{ - "error": err.Error(), - }, - ) - } - } - - if lastErr != nil { - return fmt.Errorf("%w: %w", ErrRequestFailedAfterRetries, lastErr) - } - - // This case occurs if shouldRetry was true due to a retryable status code, - // but all retries failed with similar status codes. - if resp != nil { - return fmt.Errorf( - "%w: last retry attempt failed with status code %d", - ErrRequestFailedAfterRetries, - resp.StatusCode, - ) - } - - return fmt.Errorf("%w: no response received", ErrRequestFailedAfterRetries) -} - -// shouldRetry determines if a request should be retried based on the response or an error. -func (rrt *RetryRoundTripper) shouldRetry(resp *http.Response, err error) bool { - if err != nil { - return true - } - - if resp != nil { - if resp.StatusCode == http.StatusBadGateway || - resp.StatusCode == http.StatusServiceUnavailable || - resp.StatusCode == http.StatusGatewayTimeout { - return true - } - } - - return false -} - -// calculateWaitDurationWithJitter calculates the backoff duration for the next retry, -// adding a random jitter to prevent thundering herd issues. -func (rrt *RetryRoundTripper) calculateWaitDurationWithJitter( - ctx context.Context, - baseDelay time.Duration, -) time.Duration { - if baseDelay <= 0 { - return 0 - } - - maxJitter := int64(baseDelay / jitterFactor) - if maxJitter <= 0 { - return baseDelay - } - - random, err := rand.Int(rand.Reader, big.NewInt(maxJitter)) - if err != nil { - tflog.Warn( - ctx, "Failed to generate random jitter, proceeding without it.", map[string]interface{}{ - "error": err.Error(), - }, - ) - - return baseDelay - } - - jitter := time.Duration(random.Int64()) - - return baseDelay + jitter -} - -// waitForDelay pauses execution for a given duration or until the context is canceled. -func (rrt *RetryRoundTripper) waitForDelay(ctx context.Context, delay time.Duration) error { - select { - case <-ctx.Done(): - return fmt.Errorf("context canceled during backoff wait: %w", ctx.Err()) - case <-time.After(delay): - return nil - } -} diff --git a/stackit/internal/core/retry_round_tripper_test.go b/stackit/internal/core/retry_round_tripper_test.go deleted file mode 100644 index ac84db8b..00000000 --- a/stackit/internal/core/retry_round_tripper_test.go +++ /dev/null @@ -1,252 +0,0 @@ -package core - -import ( - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "strings" - "sync/atomic" - "testing" - "time" -) - -type mockRoundTripper struct { - roundTripFunc func(req *http.Request) (*http.Response, error) - callCount int32 -} - -func (m *mockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { - atomic.AddInt32(&m.callCount, 1) - - return m.roundTripFunc(req) -} - -func (m *mockRoundTripper) CallCount() int32 { - return atomic.LoadInt32(&m.callCount) -} - -func TestRetryRoundTripper_RoundTrip(t *testing.T) { - t.Parallel() - - testRetryConfig := func(next http.RoundTripper) *RetryRoundTripper { - return NewRetryRoundTripper( - next, - 3, - 1*time.Millisecond, - 10*time.Millisecond, - 50*time.Millisecond, - ) - } - - noRetryTests := []struct { - name string - mockStatusCode int - expectedStatusCode int - }{ - { - name: "should succeed on the first try", - mockStatusCode: http.StatusOK, - expectedStatusCode: http.StatusOK, - }, - { - name: "should not retry on a non-retryable status code like 400", - mockStatusCode: http.StatusBadRequest, - expectedStatusCode: http.StatusBadRequest, - }, - } - - for _, testCase := range noRetryTests { - t.Run( - testCase.name, func(t *testing.T) { - t.Parallel() - - mock := &mockRoundTripper{ - roundTripFunc: func(req *http.Request) (*http.Response, error) { - return &http.Response{ - StatusCode: testCase.mockStatusCode, - Body: io.NopCloser(nil), - Request: req, - }, nil - }, - } - tripper := testRetryConfig(mock) - req := httptest.NewRequest(http.MethodGet, "/", http.NoBody) - - resp, err := tripper.RoundTrip(req) - if resp != nil { - defer func() { - if closeErr := resp.Body.Close(); closeErr != nil { - t.Errorf("failed to close response body: %v", closeErr) - } - }() - } - - if err != nil { - t.Fatalf("expected no error, got %v", err) - } - if resp.StatusCode != testCase.expectedStatusCode { - t.Fatalf("expected status code %d, got %d", testCase.expectedStatusCode, resp.StatusCode) - } - if mock.CallCount() != 1 { - t.Fatalf("expected 1 call, got %d", mock.CallCount()) - } - }, - ) - } - - t.Run( - "should retry on retryable status code (503) and eventually fail", func(t *testing.T) { - t.Parallel() - - mock := &mockRoundTripper{ - roundTripFunc: func(req *http.Request) (*http.Response, error) { - return &http.Response{ - StatusCode: http.StatusServiceUnavailable, - Body: io.NopCloser(nil), - Request: req, - }, nil - }, - } - tripper := testRetryConfig(mock) - req := httptest.NewRequest(http.MethodGet, "/", http.NoBody) - - resp, err := tripper.RoundTrip(req) - if resp != nil { - defer func() { - if closeErr := resp.Body.Close(); closeErr != nil { - t.Errorf("failed to close response body: %v", closeErr) - } - }() - } - - if err == nil { - t.Fatal("expected an error, but got nil") - } - expectedErrorMsg := "last retry attempt failed with status code 503" - if !strings.Contains(err.Error(), expectedErrorMsg) { - t.Fatalf("expected error to contain %q, got %q", expectedErrorMsg, err.Error()) - } - if mock.CallCount() != 4 { // 1 initial + 3 retries - t.Fatalf("expected 4 calls, got %d", mock.CallCount()) - } - }, - ) - - t.Run( - "should succeed after one retry", func(t *testing.T) { - t.Parallel() - - mock := &mockRoundTripper{} - mock.roundTripFunc = func(req *http.Request) (*http.Response, error) { - if mock.CallCount() < 2 { - return &http.Response{ - StatusCode: http.StatusServiceUnavailable, - Body: io.NopCloser(nil), - Request: req, - }, nil - } - - return &http.Response{ - StatusCode: http.StatusOK, - Body: io.NopCloser(nil), - Request: req, - }, nil - } - tripper := testRetryConfig(mock) - req := httptest.NewRequest(http.MethodGet, "/", http.NoBody) - - resp, err := tripper.RoundTrip(req) - if resp != nil { - defer func() { - if closeErr := resp.Body.Close(); closeErr != nil { - t.Errorf("failed to close response body: %v", closeErr) - } - }() - } - - if err != nil { - t.Fatalf("expected no error, got %v", err) - } - if resp.StatusCode != http.StatusOK { - t.Fatalf("expected status code %d, got %d", http.StatusOK, resp.StatusCode) - } - if mock.CallCount() != 2 { - t.Fatalf("expected 2 calls, got %d", mock.CallCount()) - } - }, - ) - - t.Run( - "should retry on network error", func(t *testing.T) { - t.Parallel() - - mockErr := errors.New("simulated network error") - - mock := &mockRoundTripper{ - roundTripFunc: func(_ *http.Request) (*http.Response, error) { - return nil, mockErr - }, - } - tripper := testRetryConfig(mock) - req := httptest.NewRequest(http.MethodGet, "/", http.NoBody) - - resp, err := tripper.RoundTrip(req) - if resp != nil { - defer func() { - if closeErr := resp.Body.Close(); closeErr != nil { - t.Errorf("failed to close response body: %v", closeErr) - } - }() - } - - if !errors.Is(err, mockErr) { - t.Fatalf("expected error to be %v, got %v", mockErr, err) - } - if mock.CallCount() != 4 { // 1 initial + 3 retries - t.Fatalf("expected 4 calls, got %d", mock.CallCount()) - } - }, - ) - - t.Run( - "should abort retries if the main context is canceled", func(t *testing.T) { - t.Parallel() - - mock := &mockRoundTripper{ - roundTripFunc: func(req *http.Request) (*http.Response, error) { - select { - case <-time.After(100 * time.Millisecond): - return nil, errors.New("this should not be returned") - case <-req.Context().Done(): - return nil, req.Context().Err() - } - }, - } - tripper := testRetryConfig(mock) - baseCtx := context.Background() - - ctx, cancel := context.WithTimeout(baseCtx, 20*time.Millisecond) - defer cancel() - - req := httptest.NewRequest(http.MethodGet, "/", http.NoBody).WithContext(ctx) - - resp, err := tripper.RoundTrip(req) - if resp != nil { - defer func() { - if closeErr := resp.Body.Close(); closeErr != nil { - t.Errorf("failed to close response body: %v", closeErr) - } - }() - } - - if !errors.Is(err, context.DeadlineExceeded) { - t.Fatalf("expected error to be context.DeadlineExceeded, got %v", err) - } - if mock.CallCount() != 1 { - t.Fatalf("expected 1 call, got %d", mock.CallCount()) - } - }, - ) -} diff --git a/stackit/internal/features/beta.go b/stackit/internal/features/beta.go index ab74e554..781ac8c0 100644 --- a/stackit/internal/features/beta.go +++ b/stackit/internal/features/beta.go @@ -9,7 +9,6 @@ import ( "strings" "github.com/hashicorp/terraform-plugin-framework/diag" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" ) diff --git a/stackit/internal/features/beta_test.go b/stackit/internal/features/beta_test.go index 366158f8..83fb2f99 100644 --- a/stackit/internal/features/beta_test.go +++ b/stackit/internal/features/beta_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-framework/diag" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" ) diff --git a/stackit/internal/features/experiments.go b/stackit/internal/features/experiments.go index 2230a7b5..b68399ed 100644 --- a/stackit/internal/features/experiments.go +++ b/stackit/internal/features/experiments.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-log/tflog" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" ) diff --git a/stackit/internal/features/experiments_test.go b/stackit/internal/features/experiments_test.go index 771a8444..06423a4f 100644 --- a/stackit/internal/features/experiments_test.go +++ b/stackit/internal/features/experiments_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-framework/diag" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" ) diff --git a/stackit/internal/services/postgresflexalpha/database/datasource.go b/stackit/internal/services/postgresflexalpha/database/datasource.go index ead08493..4a89be17 100644 --- a/stackit/internal/services/postgresflexalpha/database/datasource.go +++ b/stackit/internal/services/postgresflexalpha/database/datasource.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" postgresflexalpha2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database/datasources_gen" @@ -73,6 +72,7 @@ func (r *databaseDataSource) Configure( // Schema defines the schema for the data source. func (r *databaseDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + s := postgresflexalpha2.DatabaseDataSourceSchema(ctx) s.Attributes["id"] = schema.StringAttribute{ Description: "Terraform's internal resource ID. It is structured as \\\"`project_id`,`region`,`instance_id`," + diff --git a/stackit/internal/services/postgresflexalpha/database/functions_test.go b/stackit/internal/services/postgresflexalpha/database/functions_test.go index 4c921b14..9f0b47fd 100644 --- a/stackit/internal/services/postgresflexalpha/database/functions_test.go +++ b/stackit/internal/services/postgresflexalpha/database/functions_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/stackitcloud/stackit-sdk-go/core/utils" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" ) diff --git a/stackit/internal/services/postgresflexalpha/database/mapper.go b/stackit/internal/services/postgresflexalpha/database/mapper.go index 89140267..9e38fe3f 100644 --- a/stackit/internal/services/postgresflexalpha/database/mapper.go +++ b/stackit/internal/services/postgresflexalpha/database/mapper.go @@ -5,7 +5,6 @@ import ( "strconv" "github.com/hashicorp/terraform-plugin-framework/types" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" ) diff --git a/stackit/internal/services/postgresflexalpha/database/mapper_test.go b/stackit/internal/services/postgresflexalpha/database/mapper_test.go index 16fd0ce6..97212237 100644 --- a/stackit/internal/services/postgresflexalpha/database/mapper_test.go +++ b/stackit/internal/services/postgresflexalpha/database/mapper_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/utils" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" datasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database/datasources_gen" ) @@ -133,7 +132,7 @@ func TestMapFields(t *testing.T) { func TestMapResourceFields(t *testing.T) { type given struct { - source *postgresflexalpha.GetDatabaseResponse + source *postgresflexalpha.ListDatabase model *resourceModel } type expected struct { @@ -149,10 +148,10 @@ func TestMapResourceFields(t *testing.T) { { name: "should map fields correctly", given: given{ - source: &postgresflexalpha.GetDatabaseResponse{ + source: &postgresflexalpha.ListDatabase{ Id: utils.Ptr(int64(1)), Name: utils.Ptr("my-db"), - Owner: utils.Ptr("my-owner"), + Owner: utils.Ptr("\"my-owner\""), }, model: &resourceModel{}, }, diff --git a/stackit/internal/services/postgresflexalpha/database/resource.go b/stackit/internal/services/postgresflexalpha/database/resource.go index 2b12c281..530bb98c 100644 --- a/stackit/internal/services/postgresflexalpha/database/resource.go +++ b/stackit/internal/services/postgresflexalpha/database/resource.go @@ -3,6 +3,7 @@ package postgresflexalpha import ( "context" _ "embed" + "errors" "fmt" "math" "strconv" @@ -14,7 +15,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/identityschema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" @@ -32,6 +32,9 @@ var ( _ resource.ResourceWithModifyPlan = &databaseResource{} _ resource.ResourceWithIdentity = &databaseResource{} + // Define errors + errDatabaseNotFound = errors.New("database not found") + // Error message constants extractErrorSummary = "extracting failed" extractErrorMessage = "Extracting identity data: %v" @@ -168,7 +171,6 @@ func (r *databaseResource) Create( req resource.CreateRequest, resp *resource.CreateResponse, ) { // nolint:gocritic // function signature required by Terraform - const funcErrorSummary = "[database CREATE] error" var model resourceModel diags := req.Plan.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -179,7 +181,7 @@ func (r *databaseResource) Create( ctx = core.InitProviderContext(ctx) projectId := model.ProjectId.ValueString() - region := model.Region.ValueString() + region := model.InstanceId.ValueString() instanceId := model.InstanceId.ValueString() ctx = tflog.SetField(ctx, "project_id", projectId) @@ -192,7 +194,7 @@ func (r *databaseResource) Create( core.LogAndAddError( ctx, &resp.Diagnostics, - funcErrorSummary, + "Error creating database", fmt.Sprintf("Creating API payload: %v", err), ) return @@ -205,7 +207,7 @@ func (r *databaseResource) Create( instanceId, ).CreateDatabaseRequestPayload(*payload).Execute() if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, funcErrorSummary, fmt.Sprintf("Calling API: %v", err)) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating database", fmt.Sprintf("Calling API: %v", err)) return } @@ -213,7 +215,7 @@ func (r *databaseResource) Create( core.LogAndAddError( ctx, &resp.Diagnostics, - funcErrorSummary, + "Error creating database", "API didn't return database Id. A database might have been created", ) return @@ -234,7 +236,7 @@ func (r *databaseResource) Create( return } - database, err := postgresflexalpha3.GetDatabaseByIdWaitHandler(ctx, r.client, projectId, instanceId, region, databaseId). + database, err := postgresflexalpha3.GetDatabaseByIdWaitHandler(ctx, r.client, projectId, region, instanceId, databaseId). SetTimeout(15 * time.Minute). SetSleepBeforeWait(15 * time.Second). WaitWithContext(ctx) @@ -242,7 +244,7 @@ func (r *databaseResource) Create( core.LogAndAddError( ctx, &resp.Diagnostics, - funcErrorSummary, + "Error creating database", fmt.Sprintf("Getting database details after creation: %v", err), ) return @@ -254,8 +256,8 @@ func (r *databaseResource) Create( core.LogAndAddError( ctx, &resp.Diagnostics, - funcErrorSummary, - fmt.Sprintf("map resource fields: %v", err), + "Error creating database", + fmt.Sprintf("Processing API payload: %v", err), ) return } @@ -281,19 +283,31 @@ func (r *databaseResource) Read( return } + // Read identity data + var identityData DatabaseResourceIdentityModel + resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...) + if resp.Diagnostics.HasError() { + return + } + ctx = core.InitProviderContext(ctx) - projectId := model.ProjectId.ValueString() - instanceId := model.InstanceId.ValueString() - region := model.Region.ValueString() - databaseId := model.DatabaseId.ValueInt64() + projectId, instanceId, region, databaseId, errExt := r.extractIdentityData(model, identityData) + if errExt != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + extractErrorSummary, + fmt.Sprintf(extractErrorMessage, errExt), + ) + } ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "instance_id", instanceId) ctx = tflog.SetField(ctx, "region", region) ctx = tflog.SetField(ctx, "database_id", databaseId) - databaseResp, err := postgresflexalpha3.GetDatabaseByIdWaitHandler(ctx, r.client, projectId, instanceId, region, databaseId). + databaseResp, err := postgresflexalpha3.GetDatabaseByIdWaitHandler(ctx, r.client, projectId, region, instanceId, databaseId). SetTimeout(15 * time.Minute). SetSleepBeforeWait(15 * time.Second). WaitWithContext(ctx) @@ -321,7 +335,6 @@ func (r *databaseResource) Read( return } - // TODO: use values from api to identify drift // Save identity into Terraform state identity := DatabaseResourceIdentityModel{ ProjectID: types.StringValue(projectId), @@ -356,18 +369,30 @@ func (r *databaseResource) Update( return } + // Read identity data + var identityData DatabaseResourceIdentityModel + resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...) + if resp.Diagnostics.HasError() { + return + } + ctx = core.InitProviderContext(ctx) - projectId := model.ProjectId.ValueString() - instanceId := model.InstanceId.ValueString() - region := model.Region.ValueString() - databaseId64 := model.DatabaseId.ValueInt64() + projectId, instanceId, region, databaseId64, errExt := r.extractIdentityData(model, identityData) + if errExt != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + extractErrorSummary, + fmt.Sprintf(extractErrorMessage, errExt), + ) + } if databaseId64 > math.MaxInt32 { core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (databaseId)") return } - databaseId := int32(databaseId64) // nolint:gosec // check is performed above + databaseId := int32(databaseId64) ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "instance_id", instanceId) @@ -414,7 +439,7 @@ func (r *databaseResource) Update( ctx = core.LogResponse(ctx) - databaseResp, err := postgresflexalpha3.GetDatabaseByIdWaitHandler(ctx, r.client, projectId, instanceId, region, databaseId64). + databaseResp, err := postgresflexalpha3.GetDatabaseByIdWaitHandler(ctx, r.client, projectId, region, instanceId, databaseId64). SetTimeout(15 * time.Minute). SetSleepBeforeWait(15 * time.Second). WaitWithContext(ctx) @@ -479,7 +504,7 @@ func (r *databaseResource) Delete( ctx = core.InitProviderContext(ctx) - projectId, region, instanceId, databaseId64, errExt := r.extractIdentityData(model, identityData) + projectId, instanceId, region, databaseId64, errExt := r.extractIdentityData(model, identityData) if errExt != nil { core.LogAndAddError( ctx, @@ -493,7 +518,7 @@ func (r *databaseResource) Delete( core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (databaseId)") return } - databaseId := int32(databaseId64) // nolint:gosec // check is performed above + databaseId := int32(databaseId64) ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "instance_id", instanceId) ctx = tflog.SetField(ctx, "region", region) @@ -517,9 +542,11 @@ func (r *databaseResource) ImportState( req resource.ImportStateRequest, resp *resource.ImportStateResponse, ) { + ctx = core.InitProviderContext(ctx) if req.ID != "" { + idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" { diff --git a/stackit/internal/services/postgresflexalpha/flavor/datasource.go b/stackit/internal/services/postgresflexalpha/flavor/datasource.go index 52c6b779..dc660dd3 100644 --- a/stackit/internal/services/postgresflexalpha/flavor/datasource.go +++ b/stackit/internal/services/postgresflexalpha/flavor/datasource.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" postgresflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavors/datasources_gen" @@ -17,7 +16,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-log/tflog" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" ) diff --git a/stackit/internal/services/postgresflexalpha/flavor/functions_test.go b/stackit/internal/services/postgresflexalpha/flavor/functions_test.go index bb7180c1..90590716 100644 --- a/stackit/internal/services/postgresflexalpha/flavor/functions_test.go +++ b/stackit/internal/services/postgresflexalpha/flavor/functions_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/stackitcloud/stackit-sdk-go/core/utils" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" ) diff --git a/stackit/internal/services/postgresflexalpha/flavors/datasource.go b/stackit/internal/services/postgresflexalpha/flavors/datasource.go index df8fddac..44483018 100644 --- a/stackit/internal/services/postgresflexalpha/flavors/datasource.go +++ b/stackit/internal/services/postgresflexalpha/flavors/datasource.go @@ -5,7 +5,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-log/tflog" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" diff --git a/stackit/internal/services/postgresflexalpha/instance/datasource.go b/stackit/internal/services/postgresflexalpha/instance/datasource.go index 6a4296a4..95f7904b 100644 --- a/stackit/internal/services/postgresflexalpha/instance/datasource.go +++ b/stackit/internal/services/postgresflexalpha/instance/datasource.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/hashicorp/terraform-plugin-framework/types" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" postgresflexalpha2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance/datasources_gen" @@ -14,7 +13,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-log/tflog" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" ) diff --git a/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go b/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go index 844d494e..047d0176 100644 --- a/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go +++ b/stackit/internal/services/postgresflexalpha/instance/datasources_gen/instance_data_source_gen.go @@ -33,27 +33,15 @@ func InstanceDataSourceSchema(ctx context.Context) schema.Schema { }, "connection_info": schema.SingleNestedAttribute{ Attributes: map[string]schema.Attribute{ - "write": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "host": schema.StringAttribute{ - Computed: true, - Description: "The host of the instance.", - MarkdownDescription: "The host of the instance.", - }, - "port": schema.Int64Attribute{ - Computed: true, - Description: "The port of the instance.", - MarkdownDescription: "The port of the instance.", - }, - }, - CustomType: WriteType{ - ObjectType: types.ObjectType{ - AttrTypes: WriteValue{}.AttributeTypes(ctx), - }, - }, + "host": schema.StringAttribute{ Computed: true, - Description: "The DNS name and port in the instance overview", - MarkdownDescription: "The DNS name and port in the instance overview", + Description: "The host of the instance.", + MarkdownDescription: "The host of the instance.", + }, + "port": schema.Int64Attribute{ + Computed: true, + Description: "The port of the instance.", + MarkdownDescription: "The port of the instance.", }, }, CustomType: ConnectionInfoType{ @@ -62,8 +50,8 @@ func InstanceDataSourceSchema(ctx context.Context) schema.Schema { }, }, Computed: true, - Description: "The connection information of the instance", - MarkdownDescription: "The connection information of the instance", + Description: "The DNS name and port in the instance overview", + MarkdownDescription: "The DNS name and port in the instance overview", }, "encryption": schema.SingleNestedAttribute{ Attributes: map[string]schema.Attribute{ @@ -255,22 +243,40 @@ func (t ConnectionInfoType) ValueFromObject(ctx context.Context, in basetypes.Ob attributes := in.Attributes() - writeAttribute, ok := attributes["write"] + hostAttribute, ok := attributes["host"] if !ok { diags.AddError( "Attribute Missing", - `write is missing from object`) + `host is missing from object`) return nil, diags } - writeVal, ok := writeAttribute.(basetypes.ObjectValue) + hostVal, ok := hostAttribute.(basetypes.StringValue) if !ok { diags.AddError( "Attribute Wrong Type", - fmt.Sprintf(`write expected to be basetypes.ObjectValue, was: %T`, writeAttribute)) + fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute)) + } + + portAttribute, ok := attributes["port"] + + if !ok { + diags.AddError( + "Attribute Missing", + `port is missing from object`) + + return nil, diags + } + + portVal, ok := portAttribute.(basetypes.Int64Value) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute)) } if diags.HasError() { @@ -278,7 +284,8 @@ func (t ConnectionInfoType) ValueFromObject(ctx context.Context, in basetypes.Ob } return ConnectionInfoValue{ - Write: writeVal, + Host: hostVal, + Port: portVal, state: attr.ValueStateKnown, }, diags } @@ -346,22 +353,40 @@ func NewConnectionInfoValue(attributeTypes map[string]attr.Type, attributes map[ return NewConnectionInfoValueUnknown(), diags } - writeAttribute, ok := attributes["write"] + hostAttribute, ok := attributes["host"] if !ok { diags.AddError( "Attribute Missing", - `write is missing from object`) + `host is missing from object`) return NewConnectionInfoValueUnknown(), diags } - writeVal, ok := writeAttribute.(basetypes.ObjectValue) + hostVal, ok := hostAttribute.(basetypes.StringValue) if !ok { diags.AddError( "Attribute Wrong Type", - fmt.Sprintf(`write expected to be basetypes.ObjectValue, was: %T`, writeAttribute)) + fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute)) + } + + portAttribute, ok := attributes["port"] + + if !ok { + diags.AddError( + "Attribute Missing", + `port is missing from object`) + + return NewConnectionInfoValueUnknown(), diags + } + + portVal, ok := portAttribute.(basetypes.Int64Value) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute)) } if diags.HasError() { @@ -369,7 +394,8 @@ func NewConnectionInfoValue(attributeTypes map[string]attr.Type, attributes map[ } return ConnectionInfoValue{ - Write: writeVal, + Host: hostVal, + Port: portVal, state: attr.ValueStateKnown, }, diags } @@ -442,401 +468,12 @@ func (t ConnectionInfoType) ValueType(ctx context.Context) attr.Value { var _ basetypes.ObjectValuable = ConnectionInfoValue{} type ConnectionInfoValue struct { - Write basetypes.ObjectValue `tfsdk:"write"` - state attr.ValueState -} - -func (v ConnectionInfoValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { - attrTypes := make(map[string]tftypes.Type, 1) - - var val tftypes.Value - var err error - - attrTypes["write"] = basetypes.ObjectType{ - AttrTypes: WriteValue{}.AttributeTypes(ctx), - }.TerraformType(ctx) - - objectType := tftypes.Object{AttributeTypes: attrTypes} - - switch v.state { - case attr.ValueStateKnown: - vals := make(map[string]tftypes.Value, 1) - - val, err = v.Write.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["write"] = val - - if err := tftypes.ValidateValue(objectType, vals); err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - return tftypes.NewValue(objectType, vals), nil - case attr.ValueStateNull: - return tftypes.NewValue(objectType, nil), nil - case attr.ValueStateUnknown: - return tftypes.NewValue(objectType, tftypes.UnknownValue), nil - default: - panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state)) - } -} - -func (v ConnectionInfoValue) IsNull() bool { - return v.state == attr.ValueStateNull -} - -func (v ConnectionInfoValue) IsUnknown() bool { - return v.state == attr.ValueStateUnknown -} - -func (v ConnectionInfoValue) String() string { - return "ConnectionInfoValue" -} - -func (v ConnectionInfoValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { - var diags diag.Diagnostics - - var write basetypes.ObjectValue - - if v.Write.IsNull() { - write = types.ObjectNull( - WriteValue{}.AttributeTypes(ctx), - ) - } - - if v.Write.IsUnknown() { - write = types.ObjectUnknown( - WriteValue{}.AttributeTypes(ctx), - ) - } - - if !v.Write.IsNull() && !v.Write.IsUnknown() { - write = types.ObjectValueMust( - WriteValue{}.AttributeTypes(ctx), - v.Write.Attributes(), - ) - } - - attributeTypes := map[string]attr.Type{ - "write": basetypes.ObjectType{ - AttrTypes: WriteValue{}.AttributeTypes(ctx), - }, - } - - if v.IsNull() { - return types.ObjectNull(attributeTypes), diags - } - - if v.IsUnknown() { - return types.ObjectUnknown(attributeTypes), diags - } - - objVal, diags := types.ObjectValue( - attributeTypes, - map[string]attr.Value{ - "write": write, - }) - - return objVal, diags -} - -func (v ConnectionInfoValue) Equal(o attr.Value) bool { - other, ok := o.(ConnectionInfoValue) - - if !ok { - return false - } - - if v.state != other.state { - return false - } - - if v.state != attr.ValueStateKnown { - return true - } - - if !v.Write.Equal(other.Write) { - return false - } - - return true -} - -func (v ConnectionInfoValue) Type(ctx context.Context) attr.Type { - return ConnectionInfoType{ - basetypes.ObjectType{ - AttrTypes: v.AttributeTypes(ctx), - }, - } -} - -func (v ConnectionInfoValue) AttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "write": basetypes.ObjectType{ - AttrTypes: WriteValue{}.AttributeTypes(ctx), - }, - } -} - -var _ basetypes.ObjectTypable = WriteType{} - -type WriteType struct { - basetypes.ObjectType -} - -func (t WriteType) Equal(o attr.Type) bool { - other, ok := o.(WriteType) - - if !ok { - return false - } - - return t.ObjectType.Equal(other.ObjectType) -} - -func (t WriteType) String() string { - return "WriteType" -} - -func (t WriteType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) { - var diags diag.Diagnostics - - attributes := in.Attributes() - - hostAttribute, ok := attributes["host"] - - if !ok { - diags.AddError( - "Attribute Missing", - `host is missing from object`) - - return nil, diags - } - - hostVal, ok := hostAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute)) - } - - portAttribute, ok := attributes["port"] - - if !ok { - diags.AddError( - "Attribute Missing", - `port is missing from object`) - - return nil, diags - } - - portVal, ok := portAttribute.(basetypes.Int64Value) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute)) - } - - if diags.HasError() { - return nil, diags - } - - return WriteValue{ - Host: hostVal, - Port: portVal, - state: attr.ValueStateKnown, - }, diags -} - -func NewWriteValueNull() WriteValue { - return WriteValue{ - state: attr.ValueStateNull, - } -} - -func NewWriteValueUnknown() WriteValue { - return WriteValue{ - state: attr.ValueStateUnknown, - } -} - -func NewWriteValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (WriteValue, diag.Diagnostics) { - var diags diag.Diagnostics - - // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521 - ctx := context.Background() - - for name, attributeType := range attributeTypes { - attribute, ok := attributes[name] - - if !ok { - diags.AddError( - "Missing WriteValue Attribute Value", - "While creating a WriteValue value, a missing attribute value was detected. "+ - "A WriteValue must contain values for all attributes, even if null or unknown. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("WriteValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()), - ) - - continue - } - - if !attributeType.Equal(attribute.Type(ctx)) { - diags.AddError( - "Invalid WriteValue Attribute Type", - "While creating a WriteValue value, an invalid attribute value was detected. "+ - "A WriteValue must use a matching attribute type for the value. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("WriteValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+ - fmt.Sprintf("WriteValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)), - ) - } - } - - for name := range attributes { - _, ok := attributeTypes[name] - - if !ok { - diags.AddError( - "Extra WriteValue Attribute Value", - "While creating a WriteValue value, an extra attribute value was detected. "+ - "A WriteValue must not contain values beyond the expected attribute types. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("Extra WriteValue Attribute Name: %s", name), - ) - } - } - - if diags.HasError() { - return NewWriteValueUnknown(), diags - } - - hostAttribute, ok := attributes["host"] - - if !ok { - diags.AddError( - "Attribute Missing", - `host is missing from object`) - - return NewWriteValueUnknown(), diags - } - - hostVal, ok := hostAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute)) - } - - portAttribute, ok := attributes["port"] - - if !ok { - diags.AddError( - "Attribute Missing", - `port is missing from object`) - - return NewWriteValueUnknown(), diags - } - - portVal, ok := portAttribute.(basetypes.Int64Value) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute)) - } - - if diags.HasError() { - return NewWriteValueUnknown(), diags - } - - return WriteValue{ - Host: hostVal, - Port: portVal, - state: attr.ValueStateKnown, - }, diags -} - -func NewWriteValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) WriteValue { - object, diags := NewWriteValue(attributeTypes, attributes) - - if diags.HasError() { - // This could potentially be added to the diag package. - diagsStrings := make([]string, 0, len(diags)) - - for _, diagnostic := range diags { - diagsStrings = append(diagsStrings, fmt.Sprintf( - "%s | %s | %s", - diagnostic.Severity(), - diagnostic.Summary(), - diagnostic.Detail())) - } - - panic("NewWriteValueMust received error(s): " + strings.Join(diagsStrings, "\n")) - } - - return object -} - -func (t WriteType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { - if in.Type() == nil { - return NewWriteValueNull(), nil - } - - if !in.Type().Equal(t.TerraformType(ctx)) { - return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type()) - } - - if !in.IsKnown() { - return NewWriteValueUnknown(), nil - } - - if in.IsNull() { - return NewWriteValueNull(), nil - } - - attributes := map[string]attr.Value{} - - val := map[string]tftypes.Value{} - - err := in.As(&val) - - if err != nil { - return nil, err - } - - for k, v := range val { - a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v) - - if err != nil { - return nil, err - } - - attributes[k] = a - } - - return NewWriteValueMust(WriteValue{}.AttributeTypes(ctx), attributes), nil -} - -func (t WriteType) ValueType(ctx context.Context) attr.Value { - return WriteValue{} -} - -var _ basetypes.ObjectValuable = WriteValue{} - -type WriteValue struct { Host basetypes.StringValue `tfsdk:"host"` Port basetypes.Int64Value `tfsdk:"port"` state attr.ValueState } -func (v WriteValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { +func (v ConnectionInfoValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { attrTypes := make(map[string]tftypes.Type, 2) var val tftypes.Value @@ -881,19 +518,19 @@ func (v WriteValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) } } -func (v WriteValue) IsNull() bool { +func (v ConnectionInfoValue) IsNull() bool { return v.state == attr.ValueStateNull } -func (v WriteValue) IsUnknown() bool { +func (v ConnectionInfoValue) IsUnknown() bool { return v.state == attr.ValueStateUnknown } -func (v WriteValue) String() string { - return "WriteValue" +func (v ConnectionInfoValue) String() string { + return "ConnectionInfoValue" } -func (v WriteValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { +func (v ConnectionInfoValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { var diags diag.Diagnostics attributeTypes := map[string]attr.Type{ @@ -919,8 +556,8 @@ func (v WriteValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, d return objVal, diags } -func (v WriteValue) Equal(o attr.Value) bool { - other, ok := o.(WriteValue) +func (v ConnectionInfoValue) Equal(o attr.Value) bool { + other, ok := o.(ConnectionInfoValue) if !ok { return false @@ -945,15 +582,15 @@ func (v WriteValue) Equal(o attr.Value) bool { return true } -func (v WriteValue) Type(ctx context.Context) attr.Type { - return WriteType{ +func (v ConnectionInfoValue) Type(ctx context.Context) attr.Type { + return ConnectionInfoType{ basetypes.ObjectType{ AttrTypes: v.AttributeTypes(ctx), }, } } -func (v WriteValue) AttributeTypes(ctx context.Context) map[string]attr.Type { +func (v ConnectionInfoValue) AttributeTypes(ctx context.Context) map[string]attr.Type { return map[string]attr.Type{ "host": basetypes.StringType{}, "port": basetypes.Int64Type{}, diff --git a/stackit/internal/services/postgresflexalpha/instance/functions.go b/stackit/internal/services/postgresflexalpha/instance/functions.go index e9c9c9c2..93fb544d 100644 --- a/stackit/internal/services/postgresflexalpha/instance/functions.go +++ b/stackit/internal/services/postgresflexalpha/instance/functions.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - + "github.com/hashicorp/terraform-plugin-log/tflog" postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" postgresflexalphadatasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance/datasources_gen" postgresflexalpharesource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance/resources_gen" @@ -19,6 +19,28 @@ func mapGetInstanceResponseToModel( m *postgresflexalpharesource.InstanceModel, resp *postgresflex.GetInstanceResponse, ) error { + tflog.Debug( + ctx, ">>>> MSH DEBUG <<<<", map[string]interface{}{ + "id": m.Id.ValueString(), + "instance_id": m.InstanceId.ValueString(), + "backup_schedule": m.BackupSchedule.ValueString(), + "flavor_id": m.FlavorId.ValueString(), + "encryption.kek_key_id": m.Encryption.KekKeyId.ValueString(), + "encryption.kek_key_ring_id": m.Encryption.KekKeyRingId.ValueString(), + "encryption.kek_key_version": m.Encryption.KekKeyVersion.ValueString(), + "encryption.service_account": m.Encryption.ServiceAccount.ValueString(), + "is_deletable": m.IsDeletable.ValueBool(), + "name": m.Name.ValueString(), + "status": m.Status.ValueString(), + "retention_days": m.RetentionDays.ValueInt64(), + "replicas": m.Replicas.ValueInt64(), + "network.instance_address": m.Network.InstanceAddress.ValueString(), + "network.router_address": m.Network.RouterAddress.ValueString(), + "version": m.Version.ValueString(), + "network.acl": m.Network.Acl.String(), + }, + ) + m.BackupSchedule = types.StringValue(resp.GetBackupSchedule()) m.Encryption = postgresflexalpharesource.NewEncryptionValueNull() if resp.HasEncryption() { @@ -33,9 +55,9 @@ func mapGetInstanceResponseToModel( ) } - isConnectionInfoIncomplete := resp.ConnectionInfo == nil || resp.ConnectionInfo.Write == nil || - resp.ConnectionInfo.Write.Host == nil || *resp.ConnectionInfo.Write.Host == "" || - resp.ConnectionInfo.Write.Port == nil || *resp.ConnectionInfo.Write.Port == 0 + isConnectionInfoIncomplete := resp.ConnectionInfo == nil || + resp.ConnectionInfo.Host == nil || *resp.ConnectionInfo.Host == "" || + resp.ConnectionInfo.Port == nil || *resp.ConnectionInfo.Port == 0 if isConnectionInfoIncomplete { m.ConnectionInfo = postgresflexalpharesource.NewConnectionInfoValueNull() @@ -43,17 +65,22 @@ func mapGetInstanceResponseToModel( m.ConnectionInfo = postgresflexalpharesource.NewConnectionInfoValueMust( postgresflexalpharesource.ConnectionInfoValue{}.AttributeTypes(ctx), map[string]attr.Value{ - "write": postgresflexalpharesource.NewWriteValueMust( - postgresflexalpharesource.WriteValue{}.AttributeTypes(ctx), - map[string]attr.Value{ - "host": types.StringPointerValue(resp.ConnectionInfo.Write.Host), - "port": types.Int64PointerValue(resp.ConnectionInfo.Write.Port), - }, - ), + "host": types.StringPointerValue(resp.ConnectionInfo.Host), + "port": types.Int64PointerValue(resp.ConnectionInfo.Port), }, ) } + m.ConnectionInfo.Host = types.StringValue("") + if host, ok := resp.ConnectionInfo.GetHostOk(); ok { + m.ConnectionInfo.Host = types.StringValue(host) + } + + m.ConnectionInfo.Port = types.Int64Value(0) + if port, ok := resp.ConnectionInfo.GetPortOk(); ok { + m.ConnectionInfo.Port = types.Int64Value(port) + } + m.FlavorId = types.StringValue(resp.GetFlavorId()) if m.Id.IsNull() || m.Id.IsUnknown() { m.Id = utils.BuildInternalTerraformId( @@ -159,9 +186,9 @@ func mapGetDataInstanceResponseToModel( } func handleConnectionInfo(ctx context.Context, m *dataSourceModel, resp *postgresflex.GetInstanceResponse) { - isConnectionInfoIncomplete := resp.ConnectionInfo == nil || resp.ConnectionInfo.Write == nil || - resp.ConnectionInfo.Write.Host == nil || *resp.ConnectionInfo.Write.Host == "" || - resp.ConnectionInfo.Write.Port == nil || *resp.ConnectionInfo.Write.Port == 0 + isConnectionInfoIncomplete := resp.ConnectionInfo == nil || + resp.ConnectionInfo.Host == nil || *resp.ConnectionInfo.Host == "" || + resp.ConnectionInfo.Port == nil || *resp.ConnectionInfo.Port == 0 if isConnectionInfoIncomplete { m.ConnectionInfo = postgresflexalphadatasource.NewConnectionInfoValueNull() @@ -169,13 +196,8 @@ func handleConnectionInfo(ctx context.Context, m *dataSourceModel, resp *postgre m.ConnectionInfo = postgresflexalphadatasource.NewConnectionInfoValueMust( postgresflexalphadatasource.ConnectionInfoValue{}.AttributeTypes(ctx), map[string]attr.Value{ - "write": postgresflexalphadatasource.NewWriteValueMust( - postgresflexalphadatasource.WriteValue{}.AttributeTypes(ctx), - map[string]attr.Value{ - "host": types.StringPointerValue(resp.ConnectionInfo.Write.Host), - "port": types.Int64PointerValue(resp.ConnectionInfo.Write.Port), - }, - ), + "host": types.StringPointerValue(resp.ConnectionInfo.Host), + "port": types.Int64PointerValue(resp.ConnectionInfo.Port), }, ) } diff --git a/stackit/internal/services/postgresflexalpha/instance/functions_test.go b/stackit/internal/services/postgresflexalpha/instance/functions_test.go index ae2e55e3..19784ad8 100644 --- a/stackit/internal/services/postgresflexalpha/instance/functions_test.go +++ b/stackit/internal/services/postgresflexalpha/instance/functions_test.go @@ -2,7 +2,6 @@ package postgresflexalpha import ( "github.com/stackitcloud/stackit-sdk-go/core/utils" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" ) diff --git a/stackit/internal/services/postgresflexalpha/instance/resource.go b/stackit/internal/services/postgresflexalpha/instance/resource.go index d4049fb5..3d603df0 100644 --- a/stackit/internal/services/postgresflexalpha/instance/resource.go +++ b/stackit/internal/services/postgresflexalpha/instance/resource.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" @@ -243,8 +242,7 @@ func (r *instanceResource) Create( return } - waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId). - WaitWithContext(ctx) + waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).WaitWithContext(ctx) if err != nil { core.LogAndAddError( ctx, @@ -328,6 +326,10 @@ func (r *instanceResource) Read( ctx = core.InitProviderContext(ctx) + // projectId := model.ProjectId.ValueString() + // region := r.providerData.GetRegionWithOverride(model.Region) + // instanceId := model.InstanceId.ValueString() + var projectId string if !model.ProjectId.IsNull() && !model.ProjectId.IsUnknown() { projectId = model.ProjectId.ValueString() @@ -431,6 +433,18 @@ func (r *instanceResource) Update( return } + //if model.InstanceId.IsNull() || model.InstanceId.IsUnknown() { + // core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", "instanceId is null or unknown") + // return + //} + // + //if model.ProjectId.IsNull() || model.ProjectId.IsUnknown() { + // core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", "projectId is null or unknown") + // return + //} + + //projectId := model.ProjectId.ValueString() + //instanceId := model.InstanceId.ValueString() projectId := identityData.ProjectID.ValueString() instanceId := identityData.InstanceID.ValueString() region := model.Region.ValueString() @@ -578,7 +592,7 @@ func (r *instanceResource) ImportState( ctx, &resp.Diagnostics, "Error importing instance", fmt.Sprintf( - "Expected import identifier with format [project_id],[region],[instance_id] Got: %q", + "Expected import identifier with format: [project_id],[region],[instance_id] Got: %q", req.ID, ), ) diff --git a/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go b/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go index 25ad092b..35d31cbc 100644 --- a/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go +++ b/stackit/internal/services/postgresflexalpha/instance/resources_gen/instance_resource_gen.go @@ -35,27 +35,15 @@ func InstanceResourceSchema(ctx context.Context) schema.Schema { }, "connection_info": schema.SingleNestedAttribute{ Attributes: map[string]schema.Attribute{ - "write": schema.SingleNestedAttribute{ - Attributes: map[string]schema.Attribute{ - "host": schema.StringAttribute{ - Computed: true, - Description: "The host of the instance.", - MarkdownDescription: "The host of the instance.", - }, - "port": schema.Int64Attribute{ - Computed: true, - Description: "The port of the instance.", - MarkdownDescription: "The port of the instance.", - }, - }, - CustomType: WriteType{ - ObjectType: types.ObjectType{ - AttrTypes: WriteValue{}.AttributeTypes(ctx), - }, - }, + "host": schema.StringAttribute{ Computed: true, - Description: "The DNS name and port in the instance overview", - MarkdownDescription: "The DNS name and port in the instance overview", + Description: "The host of the instance.", + MarkdownDescription: "The host of the instance.", + }, + "port": schema.Int64Attribute{ + Computed: true, + Description: "The port of the instance.", + MarkdownDescription: "The port of the instance.", }, }, CustomType: ConnectionInfoType{ @@ -64,8 +52,8 @@ func InstanceResourceSchema(ctx context.Context) schema.Schema { }, }, Computed: true, - Description: "The connection information of the instance", - MarkdownDescription: "The connection information of the instance", + Description: "The DNS name and port in the instance overview", + MarkdownDescription: "The DNS name and port in the instance overview", }, "encryption": schema.SingleNestedAttribute{ Attributes: map[string]schema.Attribute{ @@ -275,22 +263,40 @@ func (t ConnectionInfoType) ValueFromObject(ctx context.Context, in basetypes.Ob attributes := in.Attributes() - writeAttribute, ok := attributes["write"] + hostAttribute, ok := attributes["host"] if !ok { diags.AddError( "Attribute Missing", - `write is missing from object`) + `host is missing from object`) return nil, diags } - writeVal, ok := writeAttribute.(basetypes.ObjectValue) + hostVal, ok := hostAttribute.(basetypes.StringValue) if !ok { diags.AddError( "Attribute Wrong Type", - fmt.Sprintf(`write expected to be basetypes.ObjectValue, was: %T`, writeAttribute)) + fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute)) + } + + portAttribute, ok := attributes["port"] + + if !ok { + diags.AddError( + "Attribute Missing", + `port is missing from object`) + + return nil, diags + } + + portVal, ok := portAttribute.(basetypes.Int64Value) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute)) } if diags.HasError() { @@ -298,7 +304,8 @@ func (t ConnectionInfoType) ValueFromObject(ctx context.Context, in basetypes.Ob } return ConnectionInfoValue{ - Write: writeVal, + Host: hostVal, + Port: portVal, state: attr.ValueStateKnown, }, diags } @@ -366,22 +373,40 @@ func NewConnectionInfoValue(attributeTypes map[string]attr.Type, attributes map[ return NewConnectionInfoValueUnknown(), diags } - writeAttribute, ok := attributes["write"] + hostAttribute, ok := attributes["host"] if !ok { diags.AddError( "Attribute Missing", - `write is missing from object`) + `host is missing from object`) return NewConnectionInfoValueUnknown(), diags } - writeVal, ok := writeAttribute.(basetypes.ObjectValue) + hostVal, ok := hostAttribute.(basetypes.StringValue) if !ok { diags.AddError( "Attribute Wrong Type", - fmt.Sprintf(`write expected to be basetypes.ObjectValue, was: %T`, writeAttribute)) + fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute)) + } + + portAttribute, ok := attributes["port"] + + if !ok { + diags.AddError( + "Attribute Missing", + `port is missing from object`) + + return NewConnectionInfoValueUnknown(), diags + } + + portVal, ok := portAttribute.(basetypes.Int64Value) + + if !ok { + diags.AddError( + "Attribute Wrong Type", + fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute)) } if diags.HasError() { @@ -389,7 +414,8 @@ func NewConnectionInfoValue(attributeTypes map[string]attr.Type, attributes map[ } return ConnectionInfoValue{ - Write: writeVal, + Host: hostVal, + Port: portVal, state: attr.ValueStateKnown, }, diags } @@ -462,401 +488,12 @@ func (t ConnectionInfoType) ValueType(ctx context.Context) attr.Value { var _ basetypes.ObjectValuable = ConnectionInfoValue{} type ConnectionInfoValue struct { - Write basetypes.ObjectValue `tfsdk:"write"` - state attr.ValueState -} - -func (v ConnectionInfoValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { - attrTypes := make(map[string]tftypes.Type, 1) - - var val tftypes.Value - var err error - - attrTypes["write"] = basetypes.ObjectType{ - AttrTypes: WriteValue{}.AttributeTypes(ctx), - }.TerraformType(ctx) - - objectType := tftypes.Object{AttributeTypes: attrTypes} - - switch v.state { - case attr.ValueStateKnown: - vals := make(map[string]tftypes.Value, 1) - - val, err = v.Write.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["write"] = val - - if err := tftypes.ValidateValue(objectType, vals); err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - return tftypes.NewValue(objectType, vals), nil - case attr.ValueStateNull: - return tftypes.NewValue(objectType, nil), nil - case attr.ValueStateUnknown: - return tftypes.NewValue(objectType, tftypes.UnknownValue), nil - default: - panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state)) - } -} - -func (v ConnectionInfoValue) IsNull() bool { - return v.state == attr.ValueStateNull -} - -func (v ConnectionInfoValue) IsUnknown() bool { - return v.state == attr.ValueStateUnknown -} - -func (v ConnectionInfoValue) String() string { - return "ConnectionInfoValue" -} - -func (v ConnectionInfoValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { - var diags diag.Diagnostics - - var write basetypes.ObjectValue - - if v.Write.IsNull() { - write = types.ObjectNull( - WriteValue{}.AttributeTypes(ctx), - ) - } - - if v.Write.IsUnknown() { - write = types.ObjectUnknown( - WriteValue{}.AttributeTypes(ctx), - ) - } - - if !v.Write.IsNull() && !v.Write.IsUnknown() { - write = types.ObjectValueMust( - WriteValue{}.AttributeTypes(ctx), - v.Write.Attributes(), - ) - } - - attributeTypes := map[string]attr.Type{ - "write": basetypes.ObjectType{ - AttrTypes: WriteValue{}.AttributeTypes(ctx), - }, - } - - if v.IsNull() { - return types.ObjectNull(attributeTypes), diags - } - - if v.IsUnknown() { - return types.ObjectUnknown(attributeTypes), diags - } - - objVal, diags := types.ObjectValue( - attributeTypes, - map[string]attr.Value{ - "write": write, - }) - - return objVal, diags -} - -func (v ConnectionInfoValue) Equal(o attr.Value) bool { - other, ok := o.(ConnectionInfoValue) - - if !ok { - return false - } - - if v.state != other.state { - return false - } - - if v.state != attr.ValueStateKnown { - return true - } - - if !v.Write.Equal(other.Write) { - return false - } - - return true -} - -func (v ConnectionInfoValue) Type(ctx context.Context) attr.Type { - return ConnectionInfoType{ - basetypes.ObjectType{ - AttrTypes: v.AttributeTypes(ctx), - }, - } -} - -func (v ConnectionInfoValue) AttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "write": basetypes.ObjectType{ - AttrTypes: WriteValue{}.AttributeTypes(ctx), - }, - } -} - -var _ basetypes.ObjectTypable = WriteType{} - -type WriteType struct { - basetypes.ObjectType -} - -func (t WriteType) Equal(o attr.Type) bool { - other, ok := o.(WriteType) - - if !ok { - return false - } - - return t.ObjectType.Equal(other.ObjectType) -} - -func (t WriteType) String() string { - return "WriteType" -} - -func (t WriteType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) { - var diags diag.Diagnostics - - attributes := in.Attributes() - - hostAttribute, ok := attributes["host"] - - if !ok { - diags.AddError( - "Attribute Missing", - `host is missing from object`) - - return nil, diags - } - - hostVal, ok := hostAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute)) - } - - portAttribute, ok := attributes["port"] - - if !ok { - diags.AddError( - "Attribute Missing", - `port is missing from object`) - - return nil, diags - } - - portVal, ok := portAttribute.(basetypes.Int64Value) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute)) - } - - if diags.HasError() { - return nil, diags - } - - return WriteValue{ - Host: hostVal, - Port: portVal, - state: attr.ValueStateKnown, - }, diags -} - -func NewWriteValueNull() WriteValue { - return WriteValue{ - state: attr.ValueStateNull, - } -} - -func NewWriteValueUnknown() WriteValue { - return WriteValue{ - state: attr.ValueStateUnknown, - } -} - -func NewWriteValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (WriteValue, diag.Diagnostics) { - var diags diag.Diagnostics - - // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521 - ctx := context.Background() - - for name, attributeType := range attributeTypes { - attribute, ok := attributes[name] - - if !ok { - diags.AddError( - "Missing WriteValue Attribute Value", - "While creating a WriteValue value, a missing attribute value was detected. "+ - "A WriteValue must contain values for all attributes, even if null or unknown. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("WriteValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()), - ) - - continue - } - - if !attributeType.Equal(attribute.Type(ctx)) { - diags.AddError( - "Invalid WriteValue Attribute Type", - "While creating a WriteValue value, an invalid attribute value was detected. "+ - "A WriteValue must use a matching attribute type for the value. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("WriteValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+ - fmt.Sprintf("WriteValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)), - ) - } - } - - for name := range attributes { - _, ok := attributeTypes[name] - - if !ok { - diags.AddError( - "Extra WriteValue Attribute Value", - "While creating a WriteValue value, an extra attribute value was detected. "+ - "A WriteValue must not contain values beyond the expected attribute types. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("Extra WriteValue Attribute Name: %s", name), - ) - } - } - - if diags.HasError() { - return NewWriteValueUnknown(), diags - } - - hostAttribute, ok := attributes["host"] - - if !ok { - diags.AddError( - "Attribute Missing", - `host is missing from object`) - - return NewWriteValueUnknown(), diags - } - - hostVal, ok := hostAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`host expected to be basetypes.StringValue, was: %T`, hostAttribute)) - } - - portAttribute, ok := attributes["port"] - - if !ok { - diags.AddError( - "Attribute Missing", - `port is missing from object`) - - return NewWriteValueUnknown(), diags - } - - portVal, ok := portAttribute.(basetypes.Int64Value) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`port expected to be basetypes.Int64Value, was: %T`, portAttribute)) - } - - if diags.HasError() { - return NewWriteValueUnknown(), diags - } - - return WriteValue{ - Host: hostVal, - Port: portVal, - state: attr.ValueStateKnown, - }, diags -} - -func NewWriteValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) WriteValue { - object, diags := NewWriteValue(attributeTypes, attributes) - - if diags.HasError() { - // This could potentially be added to the diag package. - diagsStrings := make([]string, 0, len(diags)) - - for _, diagnostic := range diags { - diagsStrings = append(diagsStrings, fmt.Sprintf( - "%s | %s | %s", - diagnostic.Severity(), - diagnostic.Summary(), - diagnostic.Detail())) - } - - panic("NewWriteValueMust received error(s): " + strings.Join(diagsStrings, "\n")) - } - - return object -} - -func (t WriteType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { - if in.Type() == nil { - return NewWriteValueNull(), nil - } - - if !in.Type().Equal(t.TerraformType(ctx)) { - return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type()) - } - - if !in.IsKnown() { - return NewWriteValueUnknown(), nil - } - - if in.IsNull() { - return NewWriteValueNull(), nil - } - - attributes := map[string]attr.Value{} - - val := map[string]tftypes.Value{} - - err := in.As(&val) - - if err != nil { - return nil, err - } - - for k, v := range val { - a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v) - - if err != nil { - return nil, err - } - - attributes[k] = a - } - - return NewWriteValueMust(WriteValue{}.AttributeTypes(ctx), attributes), nil -} - -func (t WriteType) ValueType(ctx context.Context) attr.Value { - return WriteValue{} -} - -var _ basetypes.ObjectValuable = WriteValue{} - -type WriteValue struct { Host basetypes.StringValue `tfsdk:"host"` Port basetypes.Int64Value `tfsdk:"port"` state attr.ValueState } -func (v WriteValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { +func (v ConnectionInfoValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { attrTypes := make(map[string]tftypes.Type, 2) var val tftypes.Value @@ -901,19 +538,19 @@ func (v WriteValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) } } -func (v WriteValue) IsNull() bool { +func (v ConnectionInfoValue) IsNull() bool { return v.state == attr.ValueStateNull } -func (v WriteValue) IsUnknown() bool { +func (v ConnectionInfoValue) IsUnknown() bool { return v.state == attr.ValueStateUnknown } -func (v WriteValue) String() string { - return "WriteValue" +func (v ConnectionInfoValue) String() string { + return "ConnectionInfoValue" } -func (v WriteValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { +func (v ConnectionInfoValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { var diags diag.Diagnostics attributeTypes := map[string]attr.Type{ @@ -939,8 +576,8 @@ func (v WriteValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, d return objVal, diags } -func (v WriteValue) Equal(o attr.Value) bool { - other, ok := o.(WriteValue) +func (v ConnectionInfoValue) Equal(o attr.Value) bool { + other, ok := o.(ConnectionInfoValue) if !ok { return false @@ -965,15 +602,15 @@ func (v WriteValue) Equal(o attr.Value) bool { return true } -func (v WriteValue) Type(ctx context.Context) attr.Type { - return WriteType{ +func (v ConnectionInfoValue) Type(ctx context.Context) attr.Type { + return ConnectionInfoType{ basetypes.ObjectType{ AttrTypes: v.AttributeTypes(ctx), }, } } -func (v WriteValue) AttributeTypes(ctx context.Context) map[string]attr.Type { +func (v ConnectionInfoValue) AttributeTypes(ctx context.Context) map[string]attr.Type { return map[string]attr.Type{ "host": basetypes.StringType{}, "port": basetypes.Int64Type{}, diff --git a/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go b/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go index d5ffd00c..7ec8c4f0 100644 --- a/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go +++ b/stackit/internal/services/postgresflexalpha/postgresflex_acc_test.go @@ -4,17 +4,12 @@ import ( "context" _ "embed" "fmt" - "log" "os" "strconv" - "strings" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/stackitcloud/stackit-sdk-go/core/config" - - postgresflexalpha2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" postgresflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils" @@ -26,52 +21,6 @@ import ( const pfx = "stackitprivatepreview_postgresflexalpha" -var testInstances []string - -func init() { - sweeperName := fmt.Sprintf("%s_%s", pfx, "sweeper") - resource.AddTestSweepers( - sweeperName, &resource.Sweeper{ - Name: sweeperName, - F: func(_ string) error { // region is passed by the testing framework - ctx := context.Background() - apiClientConfigOptions := []config.ConfigurationOption{} - apiClient, err := postgresflexalpha2.NewAPIClient(apiClientConfigOptions...) - if err != nil { - log.Fatalln(err) - } - - instances, err := apiClient.ListInstancesRequest(ctx, testutils.ProjectId, testutils.Region). - Size(100). - Execute() - if err != nil { - log.Fatalln(err) - } - - for _, inst := range instances.GetInstances() { - if strings.HasPrefix(inst.GetName(), "tf-acc-") { - for _, item := range testInstances { - if inst.GetName() == item { - delErr := apiClient.DeleteInstanceRequestExecute( - ctx, - testutils.ProjectId, - testutils.Region, - inst.GetId(), - ) - if delErr != nil { - // TODO: maybe just warn? - log.Fatalln(delErr) - } - } - } - } - } - return nil - }, - }, - ) -} - func TestInstanceResourceSchema(t *testing.T) { t.Parallel() @@ -109,13 +58,20 @@ func TestMain(m *testing.M) { os.Exit(code) } +//var ( +// validFlavor = "2.4" +// kekKeyRingId = "" +// kekKeyVersion = "" +// kekKeySA = "" +//) + func testAccPreCheck(t *testing.T) { if _, ok := os.LookupEnv("TF_ACC_PROJECT_ID"); !ok { t.Fatalf("could not find env var TF_ACC_PROJECT_ID") } } -// func TestAccResourceExample_parallel(t *testing.T) { +//func TestAccResourceExample_parallel(t *testing.T) { // t.Parallel() // // exData := resData{ @@ -195,6 +151,12 @@ func getExample() resData { func TestAccInstance(t *testing.T) { exData := getExample() + t.Logf(" ... working on instance %s", exData.TfName) + + resName := fmt.Sprintf( + "stackitprivatepreview_postgresflexalpha_instance.%s", + exData.TfName, + ) updNameData := exData updNameData.Name = "name-updated" @@ -202,71 +164,58 @@ func TestAccInstance(t *testing.T) { updSizeData := exData updSizeData.Size = 25 - resource.ParallelTest( - t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - t.Logf(" ... working on instance %s", exData.TfName) - testInstances = append(testInstances, exData.TfName) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create and verify + { + Config: testutils.StringFromTemplateMust( + "testdata/instance_template.gompl", + exData, + ), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resName, "name", exData.Name), + resource.TestCheckResourceAttrSet(resName, "id"), + ), }, - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create and verify - { - Config: testutils.StringFromTemplateMust( - "testdata/instance_template.gompl", - exData, - ), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr( - testutils.ResStr(pfx, "instance", exData.TfName), - "name", - exData.Name, - ), - resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "instance", exData.TfName), "id"), - ), - }, - // Update name and verify - { - Config: testutils.StringFromTemplateMust( - "testdata/instance_template.gompl", - updNameData, - ), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr( - testutils.ResStr(pfx, "instance", exData.TfName), - "name", - updNameData.Name, - ), - ), - }, - // Update size and verify - { - Config: testutils.StringFromTemplateMust( - "testdata/instance_template.gompl", - updSizeData, - ), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr( - testutils.ResStr(pfx, "instance", exData.TfName), - "storage.size", - strconv.Itoa(int(updSizeData.Size)), - ), - ), - }, - //// Import test - //{ - // ResourceName: "example_resource.test", - // ImportState: true, - // ImportStateVerify: true, - // }, + // Update name and verify + { + Config: testutils.StringFromTemplateMust( + "testdata/instance_template.gompl", + updNameData, + ), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resName, "name", updNameData.Name), + ), }, + // Update size and verify + { + Config: testutils.StringFromTemplateMust( + "testdata/instance_template.gompl", + updSizeData, + ), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + resName, + "storage.size", + strconv.Itoa(int(updSizeData.Size)), + ), + ), + }, + //// Import test + //{ + // ResourceName: "example_resource.test", + // ImportState: true, + // ImportStateVerify: true, + //}, }, - ) + }) } func TestAccInstanceWithUsers(t *testing.T) { data := getExample() + t.Logf(" ... working on instance %s", data.TfName) userName := "testUser" data.Users = []User{ @@ -277,41 +226,32 @@ func TestAccInstanceWithUsers(t *testing.T) { }, } - resource.ParallelTest( - t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - t.Logf(" ... working on instance %s", data.TfName) - testInstances = append(testInstances, data.TfName) - }, - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create and verify - { - Config: testutils.StringFromTemplateMust( - "testdata/instance_template.gompl", - data, - ), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr( - testutils.ResStr(pfx, "instance", data.TfName), - "name", - data.Name, - ), - resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "instance", data.TfName), "id"), - resource.TestCheckResourceAttr(testutils.ResStr(pfx, "user", userName), "name", userName), - resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "user", userName), "id"), - ), - }, + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create and verify + { + Config: testutils.StringFromTemplateMust( + "testdata/instance_template.gompl", + data, + ), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(testutils.ResStr(pfx, "instance", data.TfName), "name", data.Name), + resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "instance", data.TfName), "id"), + resource.TestCheckResourceAttr(testutils.ResStr(pfx, "user", userName), "name", userName), + resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "user", userName), "id"), + ), }, }, - ) + }) } func TestAccInstanceWithDatabases(t *testing.T) { data := getExample() + t.Logf(" ... working on instance %s", data.TfName) - dbName := "testdb" + dbName := "testDb" userName := "testUser" data.Users = []User{ { @@ -329,41 +269,46 @@ func TestAccInstanceWithDatabases(t *testing.T) { }, } - resource.ParallelTest( - t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - t.Logf(" ... working on instance %s", data.TfName) - testInstances = append(testInstances, data.TfName) - }, - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create and verify - { - Config: testutils.StringFromTemplateMust( - "testdata/instance_template.gompl", - data, - ), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr( - testutils.ResStr(pfx, "instance", data.TfName), - "name", - data.Name, - ), - resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "instance", data.TfName), "id"), - resource.TestCheckResourceAttr(testutils.ResStr(pfx, "user", userName), "name", userName), - resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "user", userName), "id"), - resource.TestCheckResourceAttr(testutils.ResStr(pfx, "database", dbName), "name", dbName), - resource.TestCheckResourceAttr(testutils.ResStr(pfx, "database", dbName), "owner", userName), - resource.TestCheckResourceAttrSet(testutils.ResStr(pfx, "database", dbName), "id"), - ), - }, + resName := fmt.Sprintf( + "stackitprivatepreview_postgresflexalpha_instance.%s", + data.TfName, + ) + + resUserName := fmt.Sprintf( + "stackitprivatepreview_postgresflexalpha_user.%s", + userName, + ) + + resDbName := fmt.Sprintf( + "stackitprivatepreview_postgresflexalpha_database.%s", + dbName, + ) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create and verify + { + Config: testutils.StringFromTemplateMust( + "testdata/instance_template.gompl", + data, + ), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resName, "name", data.Name), + resource.TestCheckResourceAttrSet(resName, "id"), + resource.TestCheckResourceAttr(resUserName, "name", userName), + resource.TestCheckResourceAttrSet(resUserName, "id"), + resource.TestCheckResourceAttr(resDbName, "name", dbName), + resource.TestCheckResourceAttr(resDbName, "owner", userName), + resource.TestCheckResourceAttrSet(resDbName, "id"), + ), }, }, - ) + }) } -// func setupMockServer() *httptest.Server { +//func setupMockServer() *httptest.Server { // mux := http.NewServeMux() // // mux.HandleFunc("/api/resources", func(w http.ResponseWriter, r *http.Request) { @@ -389,7 +334,7 @@ func TestAccInstanceWithDatabases(t *testing.T) { // return httptest.NewServer(mux) //} // -// func TestUnitResourceCreate(t *testing.T) { +//func TestUnitResourceCreate(t *testing.T) { // server := setupMockServer() // defer server.Close() // @@ -415,14 +360,14 @@ func TestAccInstanceWithDatabases(t *testing.T) { // return c.getFlavorsResp, nil // } -// func TestNewInstanceResource(t *testing.T) { +//func TestNewInstanceResource(t *testing.T) { // exData := resData{ // Region: "eu01", // ServiceAccountFilePath: sa_file, // ProjectID: project_id, // Name: "testRes", // } -// resource.ParallelTest(t, resource.TestCase{ +// resource.Test(t, resource.TestCase{ // ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, // Steps: []resource.TestStep{ // { @@ -454,7 +399,7 @@ func TestAccInstanceWithDatabases(t *testing.T) { //} //// Instance resource data -// var instanceResource = map[string]string{ +//var instanceResource = map[string]string{ // "project_id": testutils.ProjectId, // "region": "eu01", // "name": fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlphaNum)), @@ -478,19 +423,19 @@ func TestAccInstanceWithDatabases(t *testing.T) { //} // //// User resource data -// var userResource = map[string]string{ +//var userResource = map[string]string{ // "username": fmt.Sprintf("tfaccuser%s", acctest.RandStringFromCharSet(4, acctest.CharSetAlpha)), // "role": "createdb", // "project_id": testutils.ProjectId, //} // //// Database resource data -// var databaseResource = map[string]string{ +//var databaseResource = map[string]string{ // "name": fmt.Sprintf("tfaccdb%s", acctest.RandStringFromCharSet(4, acctest.CharSetAlphaNum)), // "project_id": testutils.ProjectId, //} // -// func configResources(backupSchedule string, _ *string) string { +//func configResources(backupSchedule string, _ *string) string { // return fmt.Sprintf( // ` // %s @@ -564,8 +509,8 @@ func TestAccInstanceWithDatabases(t *testing.T) { // ) //} // -// func TestAccPostgresFlexFlexResource(t *testing.T) { -// resource.ParallelTest( +//func TestAccPostgresFlexFlexResource(t *testing.T) { +// resource.Test( // t, resource.TestCase{ // ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, // CheckDestroy: testAccCheckPostgresFlexDestroy, @@ -983,7 +928,7 @@ func TestAccInstanceWithDatabases(t *testing.T) { // ) //} // -// func testAccCheckPostgresFlexDestroy(s *terraform.State) error { +//func testAccCheckPostgresFlexDestroy(s *terraform.State) error { // ctx := context.Background() // var client *postgresflex.APIClient // var err error diff --git a/stackit/internal/services/postgresflexalpha/testdata/instance_template.gompl b/stackit/internal/services/postgresflexalpha/testdata/instance_template.gompl index 260f0b57..83444f7c 100644 --- a/stackit/internal/services/postgresflexalpha/testdata/instance_template.gompl +++ b/stackit/internal/services/postgresflexalpha/testdata/instance_template.gompl @@ -48,7 +48,7 @@ resource "stackitprivatepreview_postgresflexalpha_database" "{{ $db.Name }}" { project_id = "{{ $db.ProjectId }}" instance_id = stackitprivatepreview_postgresflexalpha_instance.{{ $tfName }}.instance_id name = "{{ $db.Name }}" - owner = stackitprivatepreview_postgresflexalpha_user.{{ $db.Owner }}.name + owner = "{{ $db.Owner }}" } {{ end }} {{ end }} diff --git a/stackit/internal/services/postgresflexalpha/user/datasource.go b/stackit/internal/services/postgresflexalpha/user/datasource.go index 0bb991df..b0cf9d3b 100644 --- a/stackit/internal/services/postgresflexalpha/user/datasource.go +++ b/stackit/internal/services/postgresflexalpha/user/datasource.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/diag" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" postgresflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user/datasources_gen" @@ -17,7 +16,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" ) @@ -108,7 +106,7 @@ func (r *userDataSource) Read( core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (userId)") return } - userId := int32(userId64) // nolint:gosec // check is performed above + userId := int32(userId64) region := r.providerData.GetRegionWithOverride(model.Region) ctx = tflog.SetField(ctx, "project_id", projectId) diff --git a/stackit/internal/services/postgresflexalpha/user/mapper.go b/stackit/internal/services/postgresflexalpha/user/mapper.go index 952235ca..8fb4278f 100644 --- a/stackit/internal/services/postgresflexalpha/user/mapper.go +++ b/stackit/internal/services/postgresflexalpha/user/mapper.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" diff --git a/stackit/internal/services/postgresflexalpha/user/mapper_test.go b/stackit/internal/services/postgresflexalpha/user/mapper_test.go index 5014d4ac..37410b19 100644 --- a/stackit/internal/services/postgresflexalpha/user/mapper_test.go +++ b/stackit/internal/services/postgresflexalpha/user/mapper_test.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/utils" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" data "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user/datasources_gen" ) @@ -52,6 +51,7 @@ func TestMapDataSourceFields(t *testing.T) { }, testRegion, dataSourceModel{ + UserModel: data.UserModel{ Id: types.Int64Value(1), UserId: types.Int64Value(1), @@ -164,16 +164,16 @@ func TestMapFieldsCreate(t *testing.T) { }, testRegion, resourceModel{ - Id: types.Int64Value(1), - UserId: types.Int64Value(1), - InstanceId: types.StringValue("iid"), - ProjectId: types.StringValue("pid"), - Name: types.StringNull(), - Roles: types.List(types.SetNull(types.StringType)), - Password: types.StringNull(), - Region: types.StringValue(testRegion), - Status: types.StringNull(), - //ConnectionString: types.StringNull(), + Id: types.Int64Value(1), + UserId: types.Int64Value(1), + InstanceId: types.StringValue("iid"), + ProjectId: types.StringValue("pid"), + Name: types.StringNull(), + Roles: types.List(types.SetNull(types.StringType)), + Password: types.StringNull(), + Region: types.StringValue(testRegion), + Status: types.StringNull(), + ConnectionString: types.StringNull(), }, true, }, @@ -186,16 +186,16 @@ func TestMapFieldsCreate(t *testing.T) { }, testRegion, resourceModel{ - Id: types.Int64Value(1), - UserId: types.Int64Value(1), - InstanceId: types.StringValue("iid"), - ProjectId: types.StringValue("pid"), - Name: types.StringValue("username"), - Roles: types.List(types.SetNull(types.StringType)), - Password: types.StringNull(), - Region: types.StringValue(testRegion), - Status: types.StringValue("status"), - //ConnectionString: types.StringNull(), + Id: types.Int64Value(1), + UserId: types.Int64Value(1), + InstanceId: types.StringValue("iid"), + ProjectId: types.StringValue("pid"), + Name: types.StringValue("username"), + Roles: types.List(types.SetNull(types.StringType)), + Password: types.StringNull(), + Region: types.StringValue(testRegion), + Status: types.StringValue("status"), + ConnectionString: types.StringNull(), }, true, }, @@ -208,16 +208,16 @@ func TestMapFieldsCreate(t *testing.T) { }, testRegion, resourceModel{ - Id: types.Int64Value(1), - UserId: types.Int64Value(1), - InstanceId: types.StringValue("iid"), - ProjectId: types.StringValue("pid"), - Name: types.StringNull(), - Roles: types.List(types.SetNull(types.StringType)), - Password: types.StringNull(), - Region: types.StringValue(testRegion), - Status: types.StringNull(), - //ConnectionString: types.StringNull(), + Id: types.Int64Value(1), + UserId: types.Int64Value(1), + InstanceId: types.StringValue("iid"), + ProjectId: types.StringValue("pid"), + Name: types.StringNull(), + Roles: types.List(types.SetNull(types.StringType)), + Password: types.StringNull(), + Region: types.StringValue(testRegion), + Status: types.StringNull(), + ConnectionString: types.StringNull(), }, true, }, @@ -285,15 +285,15 @@ func TestMapFields(t *testing.T) { }, testRegion, resourceModel{ - Id: types.Int64Value(1), - UserId: types.Int64Value(int64(1)), - InstanceId: types.StringValue("iid"), - ProjectId: types.StringValue("pid"), - Name: types.StringNull(), - Roles: types.List(types.SetNull(types.StringType)), - Region: types.StringValue(testRegion), - Status: types.StringNull(), - //ConnectionString: types.StringNull(), + Id: types.Int64Value(1), + UserId: types.Int64Value(int64(1)), + InstanceId: types.StringValue("iid"), + ProjectId: types.StringValue("pid"), + Name: types.StringNull(), + Roles: types.List(types.SetNull(types.StringType)), + Region: types.StringValue(testRegion), + Status: types.StringNull(), + ConnectionString: types.StringNull(), }, true, }, @@ -324,9 +324,9 @@ func TestMapFields(t *testing.T) { }, ), ), - Region: types.StringValue(testRegion), - Status: types.StringNull(), - //ConnectionString: types.StringNull(), + Region: types.StringValue(testRegion), + Status: types.StringNull(), + ConnectionString: types.StringNull(), }, true, }, @@ -338,15 +338,15 @@ func TestMapFields(t *testing.T) { }, testRegion, resourceModel{ - Id: types.Int64Value(1), - UserId: types.Int64Value(1), - InstanceId: types.StringValue("iid"), - ProjectId: types.StringValue("pid"), - Name: types.StringNull(), - Roles: types.List(types.SetNull(types.StringType)), - Region: types.StringValue(testRegion), - Status: types.StringNull(), - //ConnectionString: types.StringNull(), + Id: types.Int64Value(1), + UserId: types.Int64Value(1), + InstanceId: types.StringValue("iid"), + ProjectId: types.StringValue("pid"), + Name: types.StringNull(), + Roles: types.List(types.SetNull(types.StringType)), + Region: types.StringValue(testRegion), + Status: types.StringNull(), + ConnectionString: types.StringNull(), }, true, }, diff --git a/stackit/internal/services/postgresflexalpha/user/planModifiers.yaml b/stackit/internal/services/postgresflexalpha/user/planModifiers.yaml index e0822704..a7d4cde6 100644 --- a/stackit/internal/services/postgresflexalpha/user/planModifiers.yaml +++ b/stackit/internal/services/postgresflexalpha/user/planModifiers.yaml @@ -2,12 +2,10 @@ fields: - name: 'id' modifiers: - 'UseStateForUnknown' - - 'RequiresReplace' - name: 'user_id' modifiers: - 'UseStateForUnknown' - - 'RequiresReplace' - name: 'instance_id' validators: @@ -15,7 +13,6 @@ fields: - validate.UUID modifiers: - 'UseStateForUnknown' - - 'RequiresReplace' - name: 'project_id' validators: @@ -35,30 +32,24 @@ fields: - name: 'password' modifiers: - - 'RequiresReplace' - 'UseStateForUnknown' - name: 'host' modifiers: - - 'RequiresReplace' - 'UseStateForUnknown' - name: 'port' modifiers: - - 'RequiresReplace' - 'UseStateForUnknown' - name: 'region' modifiers: - 'RequiresReplace' - - 'RequiresReplace' - name: 'status' modifiers: - - 'RequiresReplace' - 'UseStateForUnknown' - name: 'connection_string' modifiers: - - 'RequiresReplace' - 'UseStateForUnknown' diff --git a/stackit/internal/services/postgresflexalpha/user/resource.go b/stackit/internal/services/postgresflexalpha/user/resource.go index ab7ec563..c6cad445 100644 --- a/stackit/internal/services/postgresflexalpha/user/resource.go +++ b/stackit/internal/services/postgresflexalpha/user/resource.go @@ -5,14 +5,12 @@ import ( _ "embed" "fmt" "math" - "slices" "strconv" "strings" "time" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/resource/identityschema" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" postgresflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user/resources_gen" postgresflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils" @@ -22,7 +20,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" @@ -30,12 +27,11 @@ import ( var ( // Ensure the implementation satisfies the expected interfaces. - _ resource.Resource = &userResource{} - _ resource.ResourceWithConfigure = &userResource{} - _ resource.ResourceWithImportState = &userResource{} - _ resource.ResourceWithModifyPlan = &userResource{} - _ resource.ResourceWithIdentity = &userResource{} - _ resource.ResourceWithValidateConfig = &userResource{} + _ resource.Resource = &userResource{} + _ resource.ResourceWithConfigure = &userResource{} + _ resource.ResourceWithImportState = &userResource{} + _ resource.ResourceWithModifyPlan = &userResource{} + _ resource.ResourceWithIdentity = &userResource{} // Error message constants extractErrorSummary = "extracting failed" @@ -140,39 +136,6 @@ func (r *userResource) Schema(ctx context.Context, _ resource.SchemaRequest, res resp.Schema = s } -func (r *userResource) ValidateConfig( - ctx context.Context, - req resource.ValidateConfigRequest, - resp *resource.ValidateConfigResponse, -) { - var data resourceModel - - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - var roles []string - diags := data.Roles.ElementsAs(ctx, &roles, false) - resp.Diagnostics.Append(diags...) - if diags.HasError() { - return - } - - var resRoles []string - for _, role := range roles { - if slices.Contains(resRoles, role) { - resp.Diagnostics.AddAttributeError( - path.Root("roles"), - "Attribute Configuration Error", - "defined roles MUST NOT contain duplicates", - ) - return - } - resRoles = append(resRoles, role) - } -} - // Create creates the resource and sets the initial Terraform state. func (r *userResource) Create( ctx context.Context, @@ -252,6 +215,7 @@ func (r *userResource) Create( model.UserId = types.Int64Value(id) model.Password = types.StringValue(userResp.GetPassword()) model.Status = types.StringValue(userResp.GetStatus()) + model.ConnectionString = types.StringValue(userResp.GetConnectionString()) waitResp, err := postgresflexalphaWait.GetUserByIdWaitHandler( ctx, @@ -440,7 +404,7 @@ func (r *userResource) Update( core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (userId)") return } - userId := int32(userId64) // nolint:gosec // check is performed above + userId := int32(userId64) // Update existing instance err = r.client.UpdateUserRequest( @@ -488,7 +452,7 @@ func (r *userResource) Update( ctx, &resp.Diagnostics, "read user", - fmt.Sprintf("user update waiting: %v", err), + fmt.Sprintf("Instance creation waiting: %v", err), ) return } @@ -497,8 +461,8 @@ func (r *userResource) Update( core.LogAndAddError( ctx, &resp.Diagnostics, - "update user", - "User creation waiting: returned id is nil or wrong", + "read user", + "Instance creation waiting: returned id is nil or wrong", ) return } @@ -552,7 +516,7 @@ func (r *userResource) Delete( core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (userId)") return } - userId := int32(userId64) // nolint:gosec // check is performed above + userId := int32(userId64) // Delete existing record set err := r.client.DeleteUserRequest(ctx, arg.projectId, arg.region, arg.instanceId, userId).Execute() @@ -563,12 +527,12 @@ func (r *userResource) Delete( ctx = core.LogResponse(ctx) // TODO: Verify deletion - // exists, err := r.getUserResource(ctx, &model, arg) - // if err != nil { + //exists, err := r.getUserResource(ctx, &model, arg) + //if err != nil { // core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting user", fmt.Sprintf("Calling API: %v", err)) // return //} - // if exists { + //if exists { // core.LogAndAddError( // ctx, &resp.Diagnostics, "Error deleting user", // fmt.Sprintf("User ID '%v' resource still exists after deletion", model.UserId.ValueInt64()), @@ -620,9 +584,11 @@ func (r *userResource) ImportState( req resource.ImportStateRequest, resp *resource.ImportStateResponse, ) { + ctx = core.InitProviderContext(ctx) if req.ID != "" { + idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" { @@ -683,6 +649,7 @@ func (r *userResource) extractIdentityData( model resourceModel, identity UserResourceIdentityModel, ) (*clientArg, error) { + var projectId, region, instanceId string var userId int64 @@ -746,6 +713,5 @@ func (r *userResource) expandRoles(ctx context.Context, rolesSet types.List, dia } var roles []string diags.Append(rolesSet.ElementsAs(ctx, &roles, false)...) - slices.Sort(roles) return roles } diff --git a/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go b/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go index f96d8d93..f07ab701 100644 --- a/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go +++ b/stackit/internal/services/postgresflexalpha/user/resources_gen/user_resource_gen.go @@ -14,6 +14,11 @@ import ( func UserResourceSchema(ctx context.Context) schema.Schema { return schema.Schema{ Attributes: map[string]schema.Attribute{ + "connection_string": schema.StringAttribute{ + Computed: true, + Description: "The connection string for the user to the instance.", + MarkdownDescription: "The connection string for the user to the instance.", + }, "id": schema.Int64Attribute{ Computed: true, Description: "The ID of the user.", @@ -75,13 +80,14 @@ func UserResourceSchema(ctx context.Context) schema.Schema { } type UserModel struct { - Id types.Int64 `tfsdk:"id"` - InstanceId types.String `tfsdk:"instance_id"` - Name types.String `tfsdk:"name"` - Password types.String `tfsdk:"password"` - ProjectId types.String `tfsdk:"project_id"` - Region types.String `tfsdk:"region"` - Roles types.List `tfsdk:"roles"` - Status types.String `tfsdk:"status"` - UserId types.Int64 `tfsdk:"user_id"` + ConnectionString types.String `tfsdk:"connection_string"` + Id types.Int64 `tfsdk:"id"` + InstanceId types.String `tfsdk:"instance_id"` + Name types.String `tfsdk:"name"` + Password types.String `tfsdk:"password"` + ProjectId types.String `tfsdk:"project_id"` + Region types.String `tfsdk:"region"` + Roles types.List `tfsdk:"roles"` + Status types.String `tfsdk:"status"` + UserId types.Int64 `tfsdk:"user_id"` } diff --git a/stackit/internal/services/postgresflexalpha/utils/util.go b/stackit/internal/services/postgresflexalpha/utils/util.go index 2b6d1de8..7d6c721a 100644 --- a/stackit/internal/services/postgresflexalpha/utils/util.go +++ b/stackit/internal/services/postgresflexalpha/utils/util.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/stackitcloud/stackit-sdk-go/core/config" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" diff --git a/stackit/internal/services/postgresflexalpha/utils/util_test.go b/stackit/internal/services/postgresflexalpha/utils/util_test.go index e0f7a829..185ece19 100644 --- a/stackit/internal/services/postgresflexalpha/utils/util_test.go +++ b/stackit/internal/services/postgresflexalpha/utils/util_test.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients" "github.com/stackitcloud/stackit-sdk-go/core/config" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" diff --git a/stackit/internal/services/sqlserverflexalpha/database/datasource.go b/stackit/internal/services/sqlserverflexalpha/database/datasource.go index 5155b41c..176f3d35 100644 --- a/stackit/internal/services/sqlserverflexalpha/database/datasource.go +++ b/stackit/internal/services/sqlserverflexalpha/database/datasource.go @@ -10,34 +10,33 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/stackitcloud/stackit-sdk-go/core/config" - + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" - - sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database/datasources_gen" + sqlserverflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils" + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" ) +// dataSourceModel maps the data source schema data. +type dataSourceModel struct { + sqlserverflexalphaGen.DatabaseModel + TerraformID types.String `tfsdk:"id"` +} + var _ datasource.DataSource = (*databaseDataSource)(nil) -const errorPrefix = "[sqlserverflexalpha - Database]" - +// NewDatabaseDataSource creates a new database data source. func NewDatabaseDataSource() datasource.DataSource { return &databaseDataSource{} } -type dataSourceModel struct { - sqlserverflexalphaGen.DatabaseModel - TerraformId types.String `tfsdk:"id"` -} - type databaseDataSource struct { - client *sqlserverflexalphaPkg.APIClient + client *sqlserverflexalpha.APIClient providerData core.ProviderData } +// Metadata returns the data source type name. func (d *databaseDataSource) Metadata( _ context.Context, req datasource.MetadataRequest, @@ -46,13 +45,16 @@ func (d *databaseDataSource) Metadata( resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_database" } +// Schema defines the data source schema. func (d *databaseDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = sqlserverflexalphaGen.DatabaseDataSourceSchema(ctx) - resp.Schema.Attributes["id"] = schema.StringAttribute{ - Computed: true, - Description: "The terraform internal identifier.", - MarkdownDescription: "The terraform internal identifier.", + s := sqlserverflexalphaGen.DatabaseDataSourceSchema(ctx) + s.Attributes["id"] = schema.StringAttribute{ + Description: "Terraform's internal resource ID. It is structured as \\\"`project_id`,`region`,`instance_id`," + + "`database_id`\\\".\",", + Computed: true, } + + resp.Schema = s } // Configure adds the provider configured client to the data source. @@ -67,41 +69,20 @@ func (d *databaseDataSource) Configure( return } - apiClientConfigOptions := []config.ConfigurationOption{ - config.WithCustomAuth(d.providerData.RoundTripper), - utils.UserAgentConfigOption(d.providerData.Version), - } - if d.providerData.SQLServerFlexCustomEndpoint != "" { - apiClientConfigOptions = append( - apiClientConfigOptions, - config.WithEndpoint(d.providerData.SQLServerFlexCustomEndpoint), - ) - } else { - apiClientConfigOptions = append( - apiClientConfigOptions, - config.WithRegion(d.providerData.GetRegion()), - ) - } - apiClient, err := sqlserverflexalphaPkg.NewAPIClient(apiClientConfigOptions...) - if err != nil { - resp.Diagnostics.AddError( - "Error configuring API client", - fmt.Sprintf( - "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration", - err, - ), - ) + apiClient := sqlserverflexUtils.ConfigureClient(ctx, &d.providerData, &resp.Diagnostics) + if resp.Diagnostics.HasError() { return } d.client = apiClient - tflog.Info(ctx, fmt.Sprintf("%s client configured", errorPrefix)) + tflog.Info(ctx, "SQL SERVER Flex alpha database client configured") } +// Read retrieves the resource's state from the API. func (d *databaseDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data dataSourceModel - // Read Terraform configuration data into the model - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + var model dataSourceModel + diags := req.Config.Get(ctx, &model) + resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return } @@ -109,17 +90,22 @@ func (d *databaseDataSource) Read(ctx context.Context, req datasource.ReadReques ctx = core.InitProviderContext(ctx) // Extract identifiers from the plan - projectId := data.ProjectId.ValueString() - region := d.providerData.GetRegionWithOverride(data.Region) - instanceId := data.InstanceId.ValueString() + projectId := model.ProjectId.ValueString() + instanceId := model.InstanceId.ValueString() + region := d.providerData.GetRegionWithOverride(model.Region) + databaseName := model.DatabaseName.ValueString() ctx = tflog.SetField(ctx, "project_id", projectId) - ctx = tflog.SetField(ctx, "region", region) ctx = tflog.SetField(ctx, "instance_id", instanceId) + ctx = tflog.SetField(ctx, "region", region) + ctx = tflog.SetField(ctx, "database_name", databaseName) - databaseName := data.DatabaseName.ValueString() - + // Fetch database from the API databaseResp, err := d.client.GetDatabaseRequest(ctx, projectId, region, instanceId, databaseName).Execute() + + if resp.Diagnostics.HasError() { + return + } if err != nil { handleReadError(ctx, &resp.Diagnostics, err, projectId, instanceId) resp.State.RemoveResource(ctx) @@ -127,8 +113,9 @@ func (d *databaseDataSource) Read(ctx context.Context, req datasource.ReadReques } ctx = core.LogResponse(ctx) + // Map response body to schema and populate Computed attribute values - err = mapFields(databaseResp, &data, region) + err = mapFields(databaseResp, &model, region) if err != nil { core.LogAndAddError( ctx, @@ -139,10 +126,14 @@ func (d *databaseDataSource) Read(ctx context.Context, req datasource.ReadReques return } - // Save data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + // Set refreshed state + diags = resp.State.Set(ctx, model) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } - tflog.Info(ctx, "SQL Server Flex beta database read") + tflog.Info(ctx, "SQL Server Flex alpha database read") } // handleReadError centralizes API error handling for the Read operation. diff --git a/stackit/internal/services/sqlserverflexalpha/database/mapper.go b/stackit/internal/services/sqlserverflexalpha/database/mapper.go index 55d0e5ae..05376158 100644 --- a/stackit/internal/services/sqlserverflexalpha/database/mapper.go +++ b/stackit/internal/services/sqlserverflexalpha/database/mapper.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/hashicorp/terraform-plugin-framework/types" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" ) @@ -41,7 +40,7 @@ func mapFields(source *sqlserverflexalpha.GetDatabaseResponse, model *dataSource model.CompatibilityLevel = types.Int64Value(source.GetCompatibilityLevel()) model.CollationName = types.StringValue(source.GetCollationName()) - model.TerraformId = utils.BuildInternalTerraformId( + model.TerraformID = utils.BuildInternalTerraformId( model.ProjectId.ValueString(), region, model.InstanceId.ValueString(), @@ -80,12 +79,6 @@ func mapResourceFields(source *sqlserverflexalpha.GetDatabaseResponse, model *re model.ProjectId = types.StringValue(model.ProjectId.ValueString()) model.InstanceId = types.StringValue(model.InstanceId.ValueString()) - model.Compatibility = types.Int64Value(source.GetCompatibilityLevel()) - model.CompatibilityLevel = types.Int64Value(source.GetCompatibilityLevel()) - - model.Collation = types.StringValue(source.GetCollationName()) // it does not come back from api - model.CollationName = types.StringValue(source.GetCollationName()) - return nil } diff --git a/stackit/internal/services/sqlserverflexalpha/database/mapper_test.go b/stackit/internal/services/sqlserverflexalpha/database/mapper_test.go index b0daa742..992a3878 100644 --- a/stackit/internal/services/sqlserverflexalpha/database/mapper_test.go +++ b/stackit/internal/services/sqlserverflexalpha/database/mapper_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/utils" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" datasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database/datasources_gen" ) @@ -35,7 +34,7 @@ func TestMapFields(t *testing.T) { Name: utils.Ptr("my-db"), CollationName: utils.Ptr("collation"), CompatibilityLevel: utils.Ptr(int64(150)), - Owner: utils.Ptr("my-owner"), + Owner: utils.Ptr("\"my-owner\""), }, model: &dataSourceModel{ DatabaseModel: datasource.DatabaseModel{ @@ -58,7 +57,7 @@ func TestMapFields(t *testing.T) { CompatibilityLevel: types.Int64Value(150), CollationName: types.StringValue("collation"), }, - TerraformId: types.StringValue("my-project,eu01,my-instance,my-db"), + TerraformID: types.StringValue("my-project,eu01,my-instance,my-db"), }, }, }, @@ -127,7 +126,7 @@ func TestMapResourceFields(t *testing.T) { source: &sqlserverflexalpha.GetDatabaseResponse{ Id: utils.Ptr(int64(1)), Name: utils.Ptr("my-db"), - Owner: utils.Ptr("my-owner"), + Owner: utils.Ptr("\"my-owner\""), }, model: &resourceModel{ ProjectId: types.StringValue("my-project"), @@ -137,17 +136,13 @@ func TestMapResourceFields(t *testing.T) { }, expected: expected{ model: &resourceModel{ - Id: types.Int64Value(1), - Name: types.StringValue("my-db"), - Compatibility: types.Int64Value(0), - CompatibilityLevel: types.Int64Value(0), - Collation: types.StringValue(""), - CollationName: types.StringValue(""), - DatabaseName: types.StringValue("my-db"), - InstanceId: types.StringValue("my-instance"), - ProjectId: types.StringValue("my-project"), - Region: types.StringValue("eu01"), - Owner: types.StringValue("my-owner"), + Id: types.Int64Value(1), + Name: types.StringValue("my-db"), + DatabaseName: types.StringValue("my-db"), + InstanceId: types.StringValue("my-instance"), + ProjectId: types.StringValue("my-project"), + Region: types.StringValue("eu01"), + Owner: types.StringValue("my-owner"), }, }, }, diff --git a/stackit/internal/services/sqlserverflexalpha/database/planModifiers.yaml b/stackit/internal/services/sqlserverflexalpha/database/planModifiers.yaml index 1d010ed7..d6209230 100644 --- a/stackit/internal/services/sqlserverflexalpha/database/planModifiers.yaml +++ b/stackit/internal/services/sqlserverflexalpha/database/planModifiers.yaml @@ -31,7 +31,7 @@ fields: - name: 'owner' modifiers: - - 'UseStateForUnknown' + - 'RequiresReplace' - name: 'database_name' modifiers: @@ -43,7 +43,6 @@ fields: - name: 'compatibility' modifiers: - - 'UseStateForUnknown' - 'RequiresReplace' - name: 'compatibility_level' diff --git a/stackit/internal/services/sqlserverflexalpha/database/resource.go b/stackit/internal/services/sqlserverflexalpha/database/resource.go index 5b46c52c..0ffba164 100644 --- a/stackit/internal/services/sqlserverflexalpha/database/resource.go +++ b/stackit/internal/services/sqlserverflexalpha/database/resource.go @@ -6,8 +6,8 @@ import ( "errors" "fmt" "net/http" + "strconv" "strings" - "time" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -16,15 +16,13 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/config" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" - wait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" - sqlserverflexalphaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database/resources_gen" + sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database/resources_gen" ) var ( @@ -36,6 +34,10 @@ var ( // Define errors errDatabaseNotFound = errors.New("database not found") + + // Error message constants + extractErrorSummary = "extracting failed" + extractErrorMessage = "Extracting identity data: %v" ) func NewDatabaseResource() resource.Resource { @@ -43,13 +45,9 @@ func NewDatabaseResource() resource.Resource { } // resourceModel describes the resource data model. -type resourceModel = sqlserverflexalphaResGen.DatabaseModel - -type databaseResource struct { - client *sqlserverflexalpha.APIClient - providerData core.ProviderData -} +type resourceModel = sqlserverflexalphaGen.DatabaseModel +// DatabaseResourceIdentityModel describes the resource's identity attributes. type DatabaseResourceIdentityModel struct { ProjectID types.String `tfsdk:"project_id"` Region types.String `tfsdk:"region"` @@ -57,11 +55,12 @@ type DatabaseResourceIdentityModel struct { DatabaseName types.String `tfsdk:"database_name"` } -func (r *databaseResource) Metadata( - _ context.Context, - req resource.MetadataRequest, - resp *resource.MetadataResponse, -) { +type databaseResource struct { + client *sqlserverflexalpha.APIClient + providerData core.ProviderData +} + +func (r *databaseResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_database" } @@ -69,7 +68,7 @@ func (r *databaseResource) Metadata( var modifiersFileByte []byte func (r *databaseResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - s := sqlserverflexalphaResGen.DatabaseResourceSchema(ctx) + s := sqlserverflexalphaGen.DatabaseResourceSchema(ctx) fields, err := utils.ReadModifiersConfig(modifiersFileByte) if err != nil { @@ -124,10 +123,10 @@ func (r *databaseResource) Configure( config.WithCustomAuth(r.providerData.RoundTripper), utils.UserAgentConfigOption(r.providerData.Version), } - if r.providerData.SQLServerFlexCustomEndpoint != "" { + if r.providerData.PostgresFlexCustomEndpoint != "" { apiClientConfigOptions = append( apiClientConfigOptions, - config.WithEndpoint(r.providerData.SQLServerFlexCustomEndpoint), + config.WithEndpoint(r.providerData.PostgresFlexCustomEndpoint), ) } else { apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(r.providerData.GetRegion())) @@ -148,54 +147,50 @@ func (r *databaseResource) Configure( } func (r *databaseResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data resourceModel - createErr := "DB create error" - - // Read Terraform plan data into the model - resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + var model resourceModel + diags := req.Plan.Get(ctx, &model) + resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return } ctx = core.InitProviderContext(ctx) - projectId := data.ProjectId.ValueString() - region := data.Region.ValueString() - instanceId := data.InstanceId.ValueString() + projectId := model.ProjectId.ValueString() + region := model.Region.ValueString() + instanceId := model.InstanceId.ValueString() + ctx = tflog.SetField(ctx, "project_id", projectId) - ctx = tflog.SetField(ctx, "region", region) ctx = tflog.SetField(ctx, "instance_id", instanceId) + ctx = tflog.SetField(ctx, "region", region) - databaseName := data.Name.ValueString() - ctx = tflog.SetField(ctx, "database_name", databaseName) - - payLoad := sqlserverflexalpha.CreateDatabaseRequestPayload{} - if !data.Collation.IsNull() && !data.Collation.IsUnknown() { - payLoad.Collation = data.Collation.ValueStringPointer() - } - - if !data.Compatibility.IsNull() && !data.Compatibility.IsUnknown() { - payLoad.Compatibility = data.Compatibility.ValueInt64Pointer() - } - - payLoad.Name = data.Name.ValueStringPointer() - payLoad.Owner = data.Owner.ValueStringPointer() - - createResp, err := r.client.CreateDatabaseRequest(ctx, projectId, region, instanceId). - CreateDatabaseRequestPayload(payLoad). - Execute() + // Generate API request body from model + payload, err := toCreatePayload(&model) if err != nil { core.LogAndAddError( ctx, &resp.Diagnostics, - createErr, - fmt.Sprintf("Calling API: %v", err), + "Error creating database", + fmt.Sprintf("Creating API payload: %v", err), ) return } + // Create new database + databaseResp, err := r.client.CreateDatabaseRequest( + ctx, + projectId, + region, + instanceId, + ).CreateDatabaseRequestPayload(*payload).Execute() + if err != nil { + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating database", fmt.Sprintf("Calling API: %v", err)) + return + } - if createResp == nil || createResp.Id == nil { + ctx = core.LogResponse(ctx) + + if databaseResp == nil || databaseResp.Id == nil { core.LogAndAddError( ctx, &resp.Diagnostics, @@ -205,9 +200,11 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques return } - databaseId := *createResp.Id + databaseId := *databaseResp.Id + databaseName := model.DatabaseName.String() ctx = tflog.SetField(ctx, "database_id", databaseId) + ctx = tflog.SetField(ctx, "database_name", databaseName) ctx = core.LogResponse(ctx) @@ -223,69 +220,6 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques return } - // TODO: is this necessary to wait for the database-> API say 200 ? - waitResp, err := wait.CreateDatabaseWaitHandler( - ctx, - r.client, - projectId, - instanceId, - region, - databaseName, - ).SetSleepBeforeWait( - 30 * time.Second, - ).SetTimeout( - 15 * time.Minute, - ).WaitWithContext(ctx) - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - createErr, - fmt.Sprintf("Database creation waiting: %v", err), - ) - return - } - - if waitResp.Id == nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - createErr, - "Database creation waiting: returned id is nil", - ) - return - } - - if *waitResp.Id != databaseId { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - createErr, - "Database creation waiting: returned id is different", - ) - return - } - - if *waitResp.Owner != data.Owner.ValueString() { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - createErr, - "Database creation waiting: returned owner is different", - ) - return - } - - if *waitResp.Name != data.Name.ValueString() { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - createErr, - "Database creation waiting: returned name is different", - ) - return - } - database, err := r.client.GetDatabaseRequest(ctx, projectId, region, instanceId, databaseName).Execute() if err != nil { core.LogAndAddError( @@ -298,7 +232,7 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques } // Map response body to schema - err = mapResourceFields(database, &data, region) + err = mapResourceFields(database, &model, region) if err != nil { core.LogAndAddError( ctx, @@ -310,13 +244,11 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques } // Set state to fully populated data - resp.Diagnostics.Append(resp.State.Set(ctx, data)...) + resp.Diagnostics.Append(resp.State.Set(ctx, model)...) if resp.Diagnostics.HasError() { return } - // Save data into Terraform state - tflog.Info(ctx, "sqlserverflexalpha.Database created") } @@ -328,12 +260,24 @@ func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, r return } + // Read identity data + var identityData DatabaseResourceIdentityModel + resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...) + if resp.Diagnostics.HasError() { + return + } + ctx = core.InitProviderContext(ctx) - projectId := model.ProjectId.ValueString() - region := model.Region.ValueString() - instanceId := model.InstanceId.ValueString() - databaseName := model.DatabaseName.ValueString() + projectId, region, instanceId, databaseName, errExt := r.extractIdentityData(model, identityData) + if errExt != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + extractErrorSummary, + fmt.Sprintf(extractErrorMessage, errExt), + ) + } ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "instance_id", instanceId) @@ -365,7 +309,7 @@ func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, r return } - // Save identity into Terraform state + // Set data returned by API in identity identity := DatabaseResourceIdentityModel{ ProjectID: types.StringValue(projectId), Region: types.StringValue(region), @@ -409,10 +353,15 @@ func (r *databaseResource) Delete(ctx context.Context, req resource.DeleteReques ctx = core.InitProviderContext(ctx) - projectId := model.ProjectId.ValueString() - region := model.Region.ValueString() - instanceId := model.InstanceId.ValueString() - databaseName := model.DatabaseName.ValueString() + projectId, region, instanceId, databaseName, errExt := r.extractIdentityData(model, identityData) + if errExt != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + extractErrorSummary, + fmt.Sprintf(extractErrorMessage, errExt), + ) + } ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "instance_id", instanceId) @@ -422,15 +371,7 @@ func (r *databaseResource) Delete(ctx context.Context, req resource.DeleteReques // Delete existing record set err := r.client.DeleteDatabaseRequestExecute(ctx, projectId, region, instanceId, databaseName) if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - "Error deleting database", - fmt.Sprintf( - "Calling API: %v\nname: %s, region: %s, instanceId: %s", err, databaseName, region, instanceId, - ), - ) - return + core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting database", fmt.Sprintf("Calling API: %v", err)) } ctx = core.LogResponse(ctx) @@ -446,12 +387,11 @@ func (r *databaseResource) ModifyPlan( req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse, ) { // nolint:gocritic // function signature required by Terraform + var configModel resourceModel // skip initial empty configuration to avoid follow-up errors if req.Config.Raw.IsNull() { return } - - var configModel resourceModel resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...) if resp.Diagnostics.HasError() { return @@ -475,15 +415,17 @@ func (r *databaseResource) ModifyPlan( } // ImportState imports a resource into the Terraform state on success. -// The expected format of the resource import identifier is: project_id,zone_id,record_set_id +// The expected import identifier format is: [project_id],[region],[instance_id],[database_id] func (r *databaseResource) ImportState( ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse, ) { + ctx = core.InitProviderContext(ctx) if req.ID != "" { + idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" { @@ -491,31 +433,36 @@ func (r *databaseResource) ImportState( ctx, &resp.Diagnostics, "Error importing database", fmt.Sprintf( - "Expected import identifier with format [project_id],[region],[instance_id],[database_name] Got: %q", + "Expected import identifier with format [project_id],[region],[instance_id],[database_name], got %q", req.ID, ), ) return } + databaseId, err := strconv.ParseInt(idParts[3], 10, 64) + if err != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error importing database", + fmt.Sprintf("Invalid database_id format: %q. It must be a valid integer.", idParts[3]), + ) + return + } + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), idParts[1])...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("database_name"), idParts[3])...) + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("database_name"), databaseId)...) - var identityData DatabaseResourceIdentityModel - identityData.ProjectID = types.StringValue(idParts[0]) - identityData.Region = types.StringValue(idParts[1]) - identityData.InstanceID = types.StringValue(idParts[2]) - identityData.DatabaseName = types.StringValue(idParts[3]) - - resp.Diagnostics.Append(resp.Identity.Set(ctx, &identityData)...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Info(ctx, "sqlserverflexalpha database state imported") - return + core.LogAndAddWarning( + ctx, + &resp.Diagnostics, + "Sqlserverflexalpha database imported with empty password", + "The database password is not imported as it is only available upon creation of a new database. The password field will be empty.", + ) + tflog.Info(ctx, "Sqlserverflexalpha database state imported") } // If no ID is provided, attempt to read identity attributes from the import configuration @@ -535,5 +482,48 @@ func (r *databaseResource) ImportState( resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("database_name"), databaseName)...) - tflog.Info(ctx, "sqlserverflexalpha database state imported") + tflog.Info(ctx, "Sqlserverflexalpha database state imported") +} + +// extractIdentityData extracts essential identifiers from the resource model, falling back to the identity model. +func (r *databaseResource) extractIdentityData( + model resourceModel, + identity DatabaseResourceIdentityModel, +) (projectId, region, instanceId, databaseName string, err error) { + if !model.Name.IsNull() && !model.Name.IsUnknown() { + databaseName = model.Name.ValueString() + } else { + if identity.DatabaseName.IsNull() || identity.DatabaseName.IsUnknown() { + return "", "", "", "", fmt.Errorf("database_name not found in config") + } + databaseName = identity.DatabaseName.ValueString() + } + + if !model.ProjectId.IsNull() && !model.ProjectId.IsUnknown() { + projectId = model.ProjectId.ValueString() + } else { + if identity.ProjectID.IsNull() || identity.ProjectID.IsUnknown() { + return "", "", "", "", fmt.Errorf("project_id not found in config") + } + projectId = identity.ProjectID.ValueString() + } + + if !model.Region.IsNull() && !model.Region.IsUnknown() { + region = r.providerData.GetRegionWithOverride(model.Region) + } else { + if identity.Region.IsNull() || identity.Region.IsUnknown() { + return "", "", "", "", fmt.Errorf("region not found in config") + } + region = r.providerData.GetRegionWithOverride(identity.Region) + } + + if !model.InstanceId.IsNull() && !model.InstanceId.IsUnknown() { + instanceId = model.InstanceId.ValueString() + } else { + if identity.InstanceID.IsNull() || identity.InstanceID.IsUnknown() { + return "", "", "", "", fmt.Errorf("instance_id not found in config") + } + instanceId = identity.InstanceID.ValueString() + } + return projectId, region, instanceId, databaseName, nil } diff --git a/stackit/internal/services/sqlserverflexalpha/flavor/datasource.go b/stackit/internal/services/sqlserverflexalpha/flavor/datasource.go index d56aafa5..a48e7572 100644 --- a/stackit/internal/services/sqlserverflexalpha/flavor/datasource.go +++ b/stackit/internal/services/sqlserverflexalpha/flavor/datasource.go @@ -1,4 +1,4 @@ -package sqlserverflexalphaFlavor +package sqlserverFlexAlphaFlavor import ( "context" @@ -10,14 +10,14 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/stackitcloud/stackit-sdk-go/core/config" + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" - sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/flavor/datasources_gen" + sqlserverflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils" ) // Ensure the implementation satisfies the expected interfaces. @@ -26,6 +26,11 @@ var ( _ datasource.DataSourceWithConfigure = &flavorDataSource{} ) +// NewFlavorDataSource is a helper function to simplify the provider implementation. +func NewFlavorDataSource() datasource.DataSource { + return &flavorDataSource{} +} + type FlavorModel struct { ProjectId types.String `tfsdk:"project_id"` Region types.String `tfsdk:"region"` @@ -41,58 +46,39 @@ type FlavorModel struct { StorageClasses types.List `tfsdk:"storage_classes"` } -// NewFlavorDataSource is a helper function to simplify the provider implementation. -func NewFlavorDataSource() datasource.DataSource { - return &flavorDataSource{} -} - // flavorDataSource is the data source implementation. type flavorDataSource struct { - client *sqlserverflexalphaPkg.APIClient + client *sqlserverflexalpha.APIClient providerData core.ProviderData } // Metadata returns the data source type name. -func (r *flavorDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { +func (r *flavorDataSource) Metadata( + _ context.Context, + req datasource.MetadataRequest, + resp *datasource.MetadataResponse, +) { resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_flavor" } // Configure adds the provider configured client to the data source. -func (r *flavorDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (r *flavorDataSource) Configure( + ctx context.Context, + req datasource.ConfigureRequest, + resp *datasource.ConfigureResponse, +) { var ok bool r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics) if !ok { return } - apiClientConfigOptions := []config.ConfigurationOption{ - config.WithCustomAuth(r.providerData.RoundTripper), - utils.UserAgentConfigOption(r.providerData.Version), - } - if r.providerData.SQLServerFlexCustomEndpoint != "" { - apiClientConfigOptions = append( - apiClientConfigOptions, - config.WithEndpoint(r.providerData.SQLServerFlexCustomEndpoint), - ) - } else { - apiClientConfigOptions = append( - apiClientConfigOptions, - config.WithRegion(r.providerData.GetRegion()), - ) - } - apiClient, err := sqlserverflexalphaPkg.NewAPIClient(apiClientConfigOptions...) - if err != nil { - resp.Diagnostics.AddError( - "Error configuring API client", - fmt.Sprintf( - "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration", - err, - ), - ) + apiClient := sqlserverflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics) + if resp.Diagnostics.HasError() { return } r.client = apiClient - tflog.Info(ctx, "SQL Server Flex instance client configured") + tflog.Info(ctx, "Postgres Flex instance client configured") } func (r *flavorDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { @@ -100,13 +86,13 @@ func (r *flavorDataSource) Schema(ctx context.Context, _ datasource.SchemaReques Attributes: map[string]schema.Attribute{ "project_id": schema.StringAttribute{ Required: true, - Description: "The project ID of the flavor.", - MarkdownDescription: "The project ID of the flavor.", + Description: "The cpu count of the instance.", + MarkdownDescription: "The cpu count of the instance.", }, "region": schema.StringAttribute{ Required: true, - Description: "The region of the flavor.", - MarkdownDescription: "The region of the flavor.", + Description: "The flavor description.", + MarkdownDescription: "The flavor description.", }, "cpu": schema.Int64Attribute{ Required: true, @@ -123,16 +109,6 @@ func (r *flavorDataSource) Schema(ctx context.Context, _ datasource.SchemaReques Description: "The memory of the instance in Gibibyte.", MarkdownDescription: "The memory of the instance in Gibibyte.", }, - "node_type": schema.StringAttribute{ - Required: true, - Description: "defines the nodeType it can be either single or HA", - MarkdownDescription: "defines the nodeType it can be either single or HA", - }, - "flavor_id": schema.StringAttribute{ - Computed: true, - Description: "The id of the instance flavor.", - MarkdownDescription: "The id of the instance flavor.", - }, "description": schema.StringAttribute{ Computed: true, Description: "The flavor description.", @@ -140,8 +116,13 @@ func (r *flavorDataSource) Schema(ctx context.Context, _ datasource.SchemaReques }, "id": schema.StringAttribute{ Computed: true, - Description: "The id of the instance flavor.", - MarkdownDescription: "The id of the instance flavor.", + Description: "The terraform id of the instance flavor.", + MarkdownDescription: "The terraform id of the instance flavor.", + }, + "flavor_id": schema.StringAttribute{ + Computed: true, + Description: "The flavor id of the instance flavor.", + MarkdownDescription: "The flavor id of the instance flavor.", }, "max_gb": schema.Int64Attribute{ Computed: true, @@ -153,7 +134,13 @@ func (r *flavorDataSource) Schema(ctx context.Context, _ datasource.SchemaReques Description: "minimum storage which is required to order in Gigabyte.", MarkdownDescription: "minimum storage which is required to order in Gigabyte.", }, + "node_type": schema.StringAttribute{ + Required: true, + Description: "defines the nodeType it can be either single or replica", + MarkdownDescription: "defines the nodeType it can be either single or replica", + }, "storage_classes": schema.ListNestedAttribute{ + Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "class": schema.StringAttribute{ @@ -172,89 +159,8 @@ func (r *flavorDataSource) Schema(ctx context.Context, _ datasource.SchemaReques }, }, }, - Computed: true, - Description: "maximum storage which can be ordered for the flavor in Gigabyte.", - MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.", }, }, - //Attributes: map[string]schema.Attribute{ - // "project_id": schema.StringAttribute{ - // Required: true, - // Description: "The cpu count of the instance.", - // MarkdownDescription: "The cpu count of the instance.", - // }, - // "region": schema.StringAttribute{ - // Required: true, - // Description: "The flavor description.", - // MarkdownDescription: "The flavor description.", - // }, - // "cpu": schema.Int64Attribute{ - // Required: true, - // Description: "The cpu count of the instance.", - // MarkdownDescription: "The cpu count of the instance.", - // }, - // "ram": schema.Int64Attribute{ - // Required: true, - // Description: "The memory of the instance in Gibibyte.", - // MarkdownDescription: "The memory of the instance in Gibibyte.", - // }, - // "storage_class": schema.StringAttribute{ - // Required: true, - // Description: "The memory of the instance in Gibibyte.", - // MarkdownDescription: "The memory of the instance in Gibibyte.", - // }, - // "description": schema.StringAttribute{ - // Computed: true, - // Description: "The flavor description.", - // MarkdownDescription: "The flavor description.", - // }, - // "id": schema.StringAttribute{ - // Computed: true, - // Description: "The terraform id of the instance flavor.", - // MarkdownDescription: "The terraform id of the instance flavor.", - // }, - // "flavor_id": schema.StringAttribute{ - // Computed: true, - // Description: "The flavor id of the instance flavor.", - // MarkdownDescription: "The flavor id of the instance flavor.", - // }, - // "max_gb": schema.Int64Attribute{ - // Computed: true, - // Description: "maximum storage which can be ordered for the flavor in Gigabyte.", - // MarkdownDescription: "maximum storage which can be ordered for the flavor in Gigabyte.", - // }, - // "min_gb": schema.Int64Attribute{ - // Computed: true, - // Description: "minimum storage which is required to order in Gigabyte.", - // MarkdownDescription: "minimum storage which is required to order in Gigabyte.", - // }, - // "node_type": schema.StringAttribute{ - // Required: true, - // Description: "defines the nodeType it can be either single or replica", - // MarkdownDescription: "defines the nodeType it can be either single or replica", - // }, - // "storage_classes": schema.ListNestedAttribute{ - // Computed: true, - // NestedObject: schema.NestedAttributeObject{ - // Attributes: map[string]schema.Attribute{ - // "class": schema.StringAttribute{ - // Computed: true, - // }, - // "max_io_per_sec": schema.Int64Attribute{ - // Computed: true, - // }, - // "max_through_in_mb": schema.Int64Attribute{ - // Computed: true, - // }, - // }, - // CustomType: sqlserverflexalphaGen.StorageClassesType{ - // ObjectType: types.ObjectType{ - // AttrTypes: sqlserverflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx), - // }, - // }, - // }, - // }, - // }, } } @@ -279,7 +185,7 @@ func (r *flavorDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - var foundFlavors []sqlserverflexalphaPkg.ListFlavors + var foundFlavors []sqlserverflexalpha.ListFlavors for _, flavor := range flavors { if model.Cpu.ValueInt64() != *flavor.Cpu { continue @@ -314,11 +220,13 @@ func (r *flavorDataSource) Read(ctx context.Context, req datasource.ReadRequest, model.MinGb = types.Int64Value(*f.MinGB) if f.StorageClasses == nil { - model.StorageClasses = types.ListNull(sqlserverflexalphaGen.StorageClassesType{ - ObjectType: basetypes.ObjectType{ - AttrTypes: sqlserverflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx), + model.StorageClasses = types.ListNull( + sqlserverflexalphaGen.StorageClassesType{ + ObjectType: basetypes.ObjectType{ + AttrTypes: sqlserverflexalphaGen.StorageClassesValue{}.AttributeTypes(ctx), + }, }, - }) + ) } else { var scList []attr.Value for _, sc := range *f.StorageClasses { @@ -351,5 +259,5 @@ func (r *flavorDataSource) Read(ctx context.Context, req datasource.ReadRequest, if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "SQL Server Flex flavors read") + tflog.Info(ctx, "Postgres Flex flavors read") } diff --git a/stackit/internal/services/sqlserverflexalpha/flavor/functions.go b/stackit/internal/services/sqlserverflexalpha/flavor/functions.go index 469b7bce..e396324a 100644 --- a/stackit/internal/services/sqlserverflexalpha/flavor/functions.go +++ b/stackit/internal/services/sqlserverflexalpha/flavor/functions.go @@ -1,4 +1,4 @@ -package sqlserverflexalphaFlavor +package sqlserverFlexAlphaFlavor import ( "context" diff --git a/stackit/internal/services/sqlserverflexalpha/flavor/functions_test.go b/stackit/internal/services/sqlserverflexalpha/flavor/functions_test.go index bed6462c..0246d866 100644 --- a/stackit/internal/services/sqlserverflexalpha/flavor/functions_test.go +++ b/stackit/internal/services/sqlserverflexalpha/flavor/functions_test.go @@ -1,11 +1,10 @@ -package sqlserverflexalphaFlavor +package sqlserverFlexAlphaFlavor import ( "context" "testing" "github.com/stackitcloud/stackit-sdk-go/core/utils" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" ) diff --git a/stackit/internal/services/sqlserverflexalpha/flavors/datasource.go b/stackit/internal/services/sqlserverflexalpha/flavors/datasource.go index 2286e81b..c1d4de36 100644 --- a/stackit/internal/services/sqlserverflexalpha/flavors/datasource.go +++ b/stackit/internal/services/sqlserverflexalpha/flavors/datasource.go @@ -2,39 +2,29 @@ package sqlserverflexalpha import ( "context" - "fmt" - "net/http" "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/stackitcloud/stackit-sdk-go/core/config" - + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" - - sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" + sqlserverflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils" sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/flavors/datasources_gen" ) +// dataSourceModel maps the data source schema data. +type dataSourceModel = sqlserverflexalphaGen.FlavorsModel + var _ datasource.DataSource = (*flavorsDataSource)(nil) -const errorPrefix = "[sqlserverflexalpha - Flavors]" - +// TODO: Use NewFlavorsDataSource when datasource is implemented func NewFlavorsDataSource() datasource.DataSource { return &flavorsDataSource{} } -type dataSourceModel struct { - sqlserverflexalphaGen.FlavorsModel - TerraformId types.String `tfsdk:"id"` -} - type flavorsDataSource struct { - client *sqlserverflexalphaPkg.APIClient + client *sqlserverflexalpha.APIClient providerData core.ProviderData } @@ -48,11 +38,6 @@ func (d *flavorsDataSource) Metadata( func (d *flavorsDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = sqlserverflexalphaGen.FlavorsDataSourceSchema(ctx) - resp.Schema.Attributes["id"] = schema.StringAttribute{ - Computed: true, - Description: "The terraform internal identifier.", - MarkdownDescription: "The terraform internal identifier.", - } } // Configure adds the provider configured client to the data source. @@ -67,34 +52,12 @@ func (d *flavorsDataSource) Configure( return } - apiClientConfigOptions := []config.ConfigurationOption{ - config.WithCustomAuth(d.providerData.RoundTripper), - utils.UserAgentConfigOption(d.providerData.Version), - } - if d.providerData.SQLServerFlexCustomEndpoint != "" { - apiClientConfigOptions = append( - apiClientConfigOptions, - config.WithEndpoint(d.providerData.SQLServerFlexCustomEndpoint), - ) - } else { - apiClientConfigOptions = append( - apiClientConfigOptions, - config.WithRegion(d.providerData.GetRegion()), - ) - } - apiClient, err := sqlserverflexalphaPkg.NewAPIClient(apiClientConfigOptions...) - if err != nil { - resp.Diagnostics.AddError( - "Error configuring API client", - fmt.Sprintf( - "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration", - err, - ), - ) + apiClient := sqlserverflexUtils.ConfigureClient(ctx, &d.providerData, &resp.Diagnostics) + if resp.Diagnostics.HasError() { return } d.client = apiClient - tflog.Info(ctx, fmt.Sprintf("%s client configured", errorPrefix)) + tflog.Info(ctx, "SQL SERVER Flex flavors client configured") } func (d *flavorsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { @@ -107,50 +70,11 @@ func (d *flavorsDataSource) Read(ctx context.Context, req datasource.ReadRequest return } - ctx = core.InitProviderContext(ctx) + // Todo: Read API call logic - projectId := data.ProjectId.ValueString() - region := d.providerData.GetRegionWithOverride(data.Region) - // TODO: implement right identifier for flavors - flavorsId := data.Flavors + // Example data value setting + // data.Id = types.StringValue("example-id") - ctx = tflog.SetField(ctx, "project_id", projectId) - ctx = tflog.SetField(ctx, "region", region) - - // TODO: implement needed fields - ctx = tflog.SetField(ctx, "flavors_id", flavorsId) - - // TODO: refactor to correct implementation - _, err := d.client.GetFlavorsRequest(ctx, projectId, region).Execute() - if err != nil { - utils.LogError( - ctx, - &resp.Diagnostics, - err, - "Reading flavors", - fmt.Sprintf("flavors with ID %q does not exist in project %q.", flavorsId, projectId), - map[int]string{ - http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId), - }, - ) - resp.State.RemoveResource(ctx) - return - } - - ctx = core.LogResponse(ctx) - - // TODO: refactor to correct implementation of internal tf id - data.TerraformId = utils.BuildInternalTerraformId(projectId, region) - - // TODO: fill remaining fields - // data.Flavors = types.Sometype(apiResponse.GetFlavors()) - // data.Page = types.Sometype(apiResponse.GetPage()) - // data.Pagination = types.Sometype(apiResponse.GetPagination()) - // data.ProjectId = types.Sometype(apiResponse.GetProjectId()) - // data.Region = types.Sometype(apiResponse.GetRegion()) - // data.Size = types.Sometype(apiResponse.GetSize()) - // data.Sort = types.Sometype(apiResponse.GetSort())// Save data into Terraform state + // Save data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - - tflog.Info(ctx, fmt.Sprintf("%s read successful", errorPrefix)) } diff --git a/stackit/internal/services/sqlserverflexalpha/instance/datasource.go b/stackit/internal/services/sqlserverflexalpha/instance/datasource.go index 123b1fe8..0d58140c 100644 --- a/stackit/internal/services/sqlserverflexalpha/instance/datasource.go +++ b/stackit/internal/services/sqlserverflexalpha/instance/datasource.go @@ -1,3 +1,5 @@ +// Copyright (c) STACKIT + package sqlserverflexalpha import ( @@ -5,40 +7,45 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/stackitcloud/stackit-sdk-go/core/config" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" + sqlserverflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen" + sqlserverflexalpha2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/resources_gen" + sqlserverflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils" + + sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-log/tflog" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" - - sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" - - sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen" ) -var _ datasource.DataSource = (*instanceDataSource)(nil) +// dataSourceModel maps the data source schema data. +type dataSourceModel struct { + sqlserverflexalpha2.InstanceModel + TerraformID types.String `tfsdk:"id"` +} -const errorPrefix = "[sqlserverflexalpha - Instance]" +// Ensure the implementation satisfies the expected interfaces. +var ( + _ datasource.DataSource = &instanceDataSource{} +) +// NewInstanceDataSource is a helper function to simplify the provider implementation. func NewInstanceDataSource() datasource.DataSource { return &instanceDataSource{} } -// dataSourceModel maps the data source schema data. -type dataSourceModel struct { - sqlserverflexalphaGen.InstanceModel - TerraformID types.String `tfsdk:"id"` -} - +// instanceDataSource is the data source implementation. type instanceDataSource struct { - client *sqlserverflexalphaPkg.APIClient + client *sqlserverflex.APIClient providerData core.ProviderData } -func (d *instanceDataSource) Metadata( +// Metadata returns the data source type name. +func (r *instanceDataSource) Metadata( _ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse, @@ -46,80 +53,66 @@ func (d *instanceDataSource) Metadata( resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_instance" } -func (d *instanceDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = sqlserverflexalphaGen.InstanceDataSourceSchema(ctx) -} - // Configure adds the provider configured client to the data source. -func (d *instanceDataSource) Configure( +func (r *instanceDataSource) Configure( ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse, ) { var ok bool - d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics) + r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics) if !ok { return } - apiClientConfigOptions := []config.ConfigurationOption{ - config.WithCustomAuth(d.providerData.RoundTripper), - utils.UserAgentConfigOption(d.providerData.Version), - } - if d.providerData.SQLServerFlexCustomEndpoint != "" { - apiClientConfigOptions = append( - apiClientConfigOptions, - config.WithEndpoint(d.providerData.SQLServerFlexCustomEndpoint), - ) - } else { - apiClientConfigOptions = append( - apiClientConfigOptions, - config.WithRegion(d.providerData.GetRegion()), - ) - } - apiClient, err := sqlserverflexalphaPkg.NewAPIClient(apiClientConfigOptions...) - if err != nil { - resp.Diagnostics.AddError( - "Error configuring API client", - fmt.Sprintf( - "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration", - err, - ), - ) + apiClient := sqlserverflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics) + if resp.Diagnostics.HasError() { return } - d.client = apiClient - tflog.Info(ctx, fmt.Sprintf("%s client configured", errorPrefix)) + r.client = apiClient + tflog.Info(ctx, "SQLServer Flex instance client configured") } -func (d *instanceDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data dataSourceModel +// Schema defines the schema for the data source. +func (r *instanceDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + s := sqlserverflexalpha.InstanceDataSourceSchema(ctx) + s.Attributes["id"] = schema.StringAttribute{ + Description: "Terraform's internal resource ID. It is structured as \\\"`project_id`,`region`,`instance_id`\\\".", + Computed: true, + } - // Read Terraform configuration data into the model - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + resp.Schema = s +} +// Read refreshes the Terraform state with the latest data. +func (r *instanceDataSource) Read( + ctx context.Context, + req datasource.ReadRequest, + resp *datasource.ReadResponse, +) { // nolint:gocritic // function signature required by Terraform + var model dataSourceModel + diags := req.Config.Get(ctx, &model) + resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return } ctx = core.InitProviderContext(ctx) - projectId := data.ProjectId.ValueString() - region := d.providerData.GetRegionWithOverride(data.Region) - instanceId := data.InstanceId.ValueString() - + projectId := model.ProjectId.ValueString() + instanceId := model.InstanceId.ValueString() + region := r.providerData.GetRegionWithOverride(model.Region) ctx = tflog.SetField(ctx, "project_id", projectId) - ctx = tflog.SetField(ctx, "region", region) ctx = tflog.SetField(ctx, "instance_id", instanceId) - - instanceResp, err := d.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute() + ctx = tflog.SetField(ctx, "region", region) + instanceResp, err := r.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute() if err != nil { utils.LogError( ctx, &resp.Diagnostics, err, "Reading instance", - fmt.Sprintf("instance with ID %q does not exist in project %q.", instanceId, projectId), + fmt.Sprintf("Instance with ID %q does not exist in project %q.", instanceId, projectId), map[int]string{ http.StatusForbidden: fmt.Sprintf("Project with ID %q not found or forbidden access", projectId), }, @@ -130,17 +123,49 @@ func (d *instanceDataSource) Read(ctx context.Context, req datasource.ReadReques ctx = core.LogResponse(ctx) - err = mapDataResponseToModel(ctx, instanceResp, &data, resp.Diagnostics) + //var storage = &storageModel{} + //if !model.Storage.IsNull() && !model.Storage.IsUnknown() { + // diags = model.Storage.As(ctx, storage, basetypes.ObjectAsOptions{}) + // resp.Diagnostics.Append(diags...) + // if resp.Diagnostics.HasError() { + // return + // } + //} + // + //var encryption = &encryptionModel{} + //if !model.Encryption.IsNull() && !model.Encryption.IsUnknown() { + // diags = model.Encryption.As(ctx, encryption, basetypes.ObjectAsOptions{}) + // resp.Diagnostics.Append(diags...) + // if resp.Diagnostics.HasError() { + // return + // } + //} + // + //var network = &networkModel{} + //if !model.Network.IsNull() && !model.Network.IsUnknown() { + // diags = model.Network.As(ctx, network, basetypes.ObjectAsOptions{}) + // resp.Diagnostics.Append(diags...) + // if resp.Diagnostics.HasError() { + // return + // } + //} + + err = mapFields(ctx, instanceResp, &model, resp.Diagnostics) + //err = mapFields(ctx, instanceResp, &model, storage, encryption, network, region) if err != nil { core.LogAndAddError( ctx, &resp.Diagnostics, - fmt.Sprintf("%s Read", errorPrefix), + "Error reading instance", fmt.Sprintf("Processing API payload: %v", err), ) return } - - // Save data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + // Set refreshed state + diags = resp.State.Set(ctx, model) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + tflog.Info(ctx, "SQLServer Flex instance read") } diff --git a/stackit/internal/services/sqlserverflexalpha/instance/functions.go b/stackit/internal/services/sqlserverflexalpha/instance/functions.go index a8567903..77effc6c 100644 --- a/stackit/internal/services/sqlserverflexalpha/instance/functions.go +++ b/stackit/internal/services/sqlserverflexalpha/instance/functions.go @@ -2,7 +2,6 @@ package sqlserverflexalpha import ( "context" - "errors" "fmt" "math" @@ -10,92 +9,29 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" - - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" + sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" - sqlserverflexalphaDataGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/datasources_gen" - sqlserverflexalphaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/resources_gen" + sqlserverflexResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/resources_gen" ) -func mapResponseToModel( - ctx context.Context, - resp *sqlserverflexalpha.GetInstanceResponse, - m *sqlserverflexalphaResGen.InstanceModel, - tfDiags diag.Diagnostics, -) error { - m.BackupSchedule = types.StringValue(resp.GetBackupSchedule()) - m.Edition = types.StringValue(string(resp.GetEdition())) - m.Encryption = handleEncryption(m, resp) - m.FlavorId = types.StringValue(resp.GetFlavorId()) - m.Id = types.StringValue(resp.GetId()) - m.InstanceId = types.StringValue(resp.GetId()) - m.IsDeletable = types.BoolValue(resp.GetIsDeletable()) - m.Name = types.StringValue(resp.GetName()) - netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl()) - tfDiags.Append(diags...) - if diags.HasError() { - return fmt.Errorf( - "error converting network acl response value", - ) - } - net, diags := sqlserverflexalphaResGen.NewNetworkValue( - sqlserverflexalphaResGen.NetworkValue{}.AttributeTypes(ctx), - map[string]attr.Value{ - "access_scope": types.StringValue(string(resp.Network.GetAccessScope())), - "acl": netAcl, - "instance_address": types.StringValue(resp.Network.GetInstanceAddress()), - "router_address": types.StringValue(resp.Network.GetRouterAddress()), - }, - ) - tfDiags.Append(diags...) - if diags.HasError() { - return errors.New("error converting network response value") - } - m.Network = net - m.Replicas = types.Int64Value(int64(resp.GetReplicas())) - m.RetentionDays = types.Int64Value(resp.GetRetentionDays()) - m.Status = types.StringValue(string(resp.GetStatus())) - - stor, diags := sqlserverflexalphaResGen.NewStorageValue( - sqlserverflexalphaResGen.StorageValue{}.AttributeTypes(ctx), - map[string]attr.Value{ - "class": types.StringValue(resp.Storage.GetClass()), - "size": types.Int64Value(resp.Storage.GetSize()), - }, - ) - tfDiags.Append(diags...) - if diags.HasError() { - return fmt.Errorf("error converting storage response value") - } - m.Storage = stor - - m.Version = types.StringValue(string(resp.GetVersion())) - return nil +// instanceModel is a type constraint for models that can be mapped from a GetInstanceResponse. +type instanceModel interface { + *dataSourceModel | *resourceModel } -func mapDataResponseToModel( +func mapFields[T instanceModel]( ctx context.Context, - resp *sqlserverflexalpha.GetInstanceResponse, - m *dataSourceModel, + resp *sqlserverflex.GetInstanceResponse, + m T, tfDiags diag.Diagnostics, ) error { - m.BackupSchedule = types.StringValue(resp.GetBackupSchedule()) - m.Edition = types.StringValue(string(resp.GetEdition())) - m.Encryption = handleDSEncryption(m, resp) - m.FlavorId = types.StringValue(resp.GetFlavorId()) - m.Id = types.StringValue(resp.GetId()) - m.InstanceId = types.StringValue(resp.GetId()) - m.IsDeletable = types.BoolValue(resp.GetIsDeletable()) - m.Name = types.StringValue(resp.GetName()) netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl()) tfDiags.Append(diags...) if diags.HasError() { - return fmt.Errorf( - "error converting network acl response value", - ) + return fmt.Errorf("error converting network acl response value") } - net, diags := sqlserverflexalphaDataGen.NewNetworkValue( - sqlserverflexalphaDataGen.NetworkValue{}.AttributeTypes(ctx), + net, diags := sqlserverflexResGen.NewNetworkValue( + sqlserverflexResGen.NetworkValue{}.AttributeTypes(ctx), map[string]attr.Value{ "access_scope": types.StringValue(string(resp.Network.GetAccessScope())), "acl": netAcl, @@ -105,15 +41,11 @@ func mapDataResponseToModel( ) tfDiags.Append(diags...) if diags.HasError() { - return errors.New("error converting network response value") + return fmt.Errorf("error converting network response value") } - m.Network = net - m.Replicas = types.Int64Value(int64(resp.GetReplicas())) - m.RetentionDays = types.Int64Value(resp.GetRetentionDays()) - m.Status = types.StringValue(string(resp.GetStatus())) - stor, diags := sqlserverflexalphaDataGen.NewStorageValue( - sqlserverflexalphaDataGen.StorageValue{}.AttributeTypes(ctx), + stor, diags := sqlserverflexResGen.NewStorageValue( + sqlserverflexResGen.StorageValue{}.AttributeTypes(ctx), map[string]attr.Value{ "class": types.StringValue(resp.Storage.GetClass()), "size": types.Int64Value(resp.Storage.GetSize()), @@ -123,61 +55,63 @@ func mapDataResponseToModel( if diags.HasError() { return fmt.Errorf("error converting storage response value") } - m.Storage = stor - m.Version = types.StringValue(string(resp.GetVersion())) + // The interface conversion is safe due to the type constraint. + model := any(m) + + if rm, ok := model.(*resourceModel); ok { + rm.BackupSchedule = types.StringValue(resp.GetBackupSchedule()) + rm.Edition = types.StringValue(string(resp.GetEdition())) + rm.Encryption = handleEncryption(rm.Encryption, resp) + rm.FlavorId = types.StringValue(resp.GetFlavorId()) + rm.Id = types.StringValue(resp.GetId()) + rm.InstanceId = types.StringValue(resp.GetId()) + rm.IsDeletable = types.BoolValue(resp.GetIsDeletable()) + rm.Name = types.StringValue(resp.GetName()) + rm.Network = net + rm.Replicas = types.Int64Value(int64(resp.GetReplicas())) + rm.RetentionDays = types.Int64Value(resp.GetRetentionDays()) + rm.Status = types.StringValue(string(resp.GetStatus())) + rm.Storage = stor + rm.Version = types.StringValue(string(resp.GetVersion())) + } else if dm, ok := model.(*dataSourceModel); ok { + dm.BackupSchedule = types.StringValue(resp.GetBackupSchedule()) + dm.Edition = types.StringValue(string(resp.GetEdition())) + dm.Encryption = handleEncryption(dm.Encryption, resp) + dm.FlavorId = types.StringValue(resp.GetFlavorId()) + dm.Id = types.StringValue(resp.GetId()) + dm.InstanceId = types.StringValue(resp.GetId()) + dm.IsDeletable = types.BoolValue(resp.GetIsDeletable()) + dm.Name = types.StringValue(resp.GetName()) + dm.Network = net + dm.Replicas = types.Int64Value(int64(resp.GetReplicas())) + dm.RetentionDays = types.Int64Value(resp.GetRetentionDays()) + dm.Status = types.StringValue(string(resp.GetStatus())) + dm.Storage = stor + dm.Version = types.StringValue(string(resp.GetVersion())) + } + return nil } func handleEncryption( - m *sqlserverflexalphaResGen.InstanceModel, - resp *sqlserverflexalpha.GetInstanceResponse, -) sqlserverflexalphaResGen.EncryptionValue { + encryptionValue sqlserverflexResGen.EncryptionValue, + resp *sqlserverflex.GetInstanceResponse, +) sqlserverflexResGen.EncryptionValue { if !resp.HasEncryption() || resp.Encryption == nil || resp.Encryption.KekKeyId == nil || resp.Encryption.KekKeyRingId == nil || resp.Encryption.KekKeyVersion == nil || resp.Encryption.ServiceAccount == nil { - if m.Encryption.IsNull() || m.Encryption.IsUnknown() { - return sqlserverflexalphaResGen.NewEncryptionValueNull() + + if encryptionValue.IsNull() || encryptionValue.IsUnknown() { + return sqlserverflexResGen.NewEncryptionValueNull() } - return m.Encryption + return encryptionValue } - enc := sqlserverflexalphaResGen.NewEncryptionValueNull() - if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok { - enc.KekKeyId = types.StringValue(kVal) - } - if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok { - enc.KekKeyRingId = types.StringValue(kkVal) - } - if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok { - enc.KekKeyVersion = types.StringValue(kkvVal) - } - if sa, ok := resp.Encryption.GetServiceAccountOk(); ok { - enc.ServiceAccount = types.StringValue(sa) - } - return enc -} - -func handleDSEncryption( - m *dataSourceModel, - resp *sqlserverflexalpha.GetInstanceResponse, -) sqlserverflexalphaDataGen.EncryptionValue { - if !resp.HasEncryption() || - resp.Encryption == nil || - resp.Encryption.KekKeyId == nil || - resp.Encryption.KekKeyRingId == nil || - resp.Encryption.KekKeyVersion == nil || - resp.Encryption.ServiceAccount == nil { - if m.Encryption.IsNull() || m.Encryption.IsUnknown() { - return sqlserverflexalphaDataGen.NewEncryptionValueNull() - } - return m.Encryption - } - - enc := sqlserverflexalphaDataGen.NewEncryptionValueNull() + enc := sqlserverflexResGen.NewEncryptionValueNull() if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok { enc.KekKeyId = types.StringValue(kVal) } @@ -195,25 +129,25 @@ func handleDSEncryption( func toCreatePayload( ctx context.Context, - model *sqlserverflexalphaResGen.InstanceModel, -) (*sqlserverflexalpha.CreateInstanceRequestPayload, error) { + model *sqlserverflexResGen.InstanceModel, +) (*sqlserverflex.CreateInstanceRequestPayload, error) { if model == nil { return nil, fmt.Errorf("nil model") } - storagePayload := &sqlserverflexalpha.CreateInstanceRequestPayloadGetStorageArgType{} + storagePayload := &sqlserverflex.CreateInstanceRequestPayloadGetStorageArgType{} if !model.Storage.IsNull() && !model.Storage.IsUnknown() { storagePayload.Class = model.Storage.Class.ValueStringPointer() storagePayload.Size = model.Storage.Size.ValueInt64Pointer() } - var encryptionPayload *sqlserverflexalpha.CreateInstanceRequestPayloadGetEncryptionArgType = nil + var encryptionPayload *sqlserverflex.CreateInstanceRequestPayloadGetEncryptionArgType = nil if !model.Encryption.IsNull() && !model.Encryption.IsUnknown() && !model.Encryption.KekKeyId.IsNull() && model.Encryption.KekKeyId.IsUnknown() && model.Encryption.KekKeyId.ValueString() != "" && !model.Encryption.KekKeyRingId.IsNull() && !model.Encryption.KekKeyRingId.IsUnknown() && model.Encryption.KekKeyRingId.ValueString() != "" && !model.Encryption.KekKeyVersion.IsNull() && !model.Encryption.KekKeyVersion.IsUnknown() && model.Encryption.KekKeyVersion.ValueString() != "" && !model.Encryption.ServiceAccount.IsNull() && !model.Encryption.ServiceAccount.IsUnknown() && model.Encryption.ServiceAccount.ValueString() != "" { - encryptionPayload = &sqlserverflexalpha.CreateInstanceRequestPayloadGetEncryptionArgType{ + encryptionPayload = &sqlserverflex.CreateInstanceRequestPayloadGetEncryptionArgType{ KekKeyId: model.Encryption.KekKeyId.ValueStringPointer(), KekKeyRingId: model.Encryption.KekKeyVersion.ValueStringPointer(), KekKeyVersion: model.Encryption.KekKeyRingId.ValueStringPointer(), @@ -221,9 +155,9 @@ func toCreatePayload( } } - networkPayload := &sqlserverflexalpha.CreateInstanceRequestPayloadGetNetworkArgType{} + networkPayload := &sqlserverflex.CreateInstanceRequestPayloadGetNetworkArgType{} if !model.Network.IsNull() && !model.Network.IsUnknown() { - networkPayload.AccessScope = sqlserverflexalpha.CreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType( + networkPayload.AccessScope = sqlserverflex.CreateInstanceRequestPayloadNetworkGetAccessScopeAttributeType( model.Network.AccessScope.ValueStringPointer(), ) @@ -235,7 +169,7 @@ func toCreatePayload( networkPayload.Acl = &resList } - return &sqlserverflexalpha.CreateInstanceRequestPayload{ + return &sqlserverflex.CreateInstanceRequestPayload{ BackupSchedule: conversion.StringValueToPointer(model.BackupSchedule), Encryption: encryptionPayload, FlavorId: conversion.StringValueToPointer(model.FlavorId), @@ -243,24 +177,20 @@ func toCreatePayload( Network: networkPayload, RetentionDays: conversion.Int64ValueToPointer(model.RetentionDays), Storage: storagePayload, - Version: sqlserverflexalpha.CreateInstanceRequestPayloadGetVersionAttributeType( - conversion.StringValueToPointer(model.Version), - ), + Version: sqlserverflex.CreateInstanceRequestPayloadGetVersionAttributeType(conversion.StringValueToPointer(model.Version)), }, nil } +// TODO: check func with his args func toUpdatePayload( ctx context.Context, - m *sqlserverflexalphaResGen.InstanceModel, + m *sqlserverflexResGen.InstanceModel, resp *resource.UpdateResponse, -) (*sqlserverflexalpha.UpdateInstanceRequestPayload, error) { - if m == nil { - return nil, fmt.Errorf("nil model") - } +) (*sqlserverflex.UpdateInstanceRequestPayload, error) { if m.Replicas.ValueInt64() > math.MaxUint32 { return nil, fmt.Errorf("replicas value is too big for uint32") } - replVal := sqlserverflexalpha.Replicas(uint32(m.Replicas.ValueInt64())) // nolint:gosec // check is performed above + replVal := sqlserverflex.Replicas(uint32(m.Replicas.ValueInt64())) var netAcl []string diags := m.Network.Acl.ElementsAs(ctx, &netAcl, false) @@ -268,16 +198,16 @@ func toUpdatePayload( if diags.HasError() { return nil, fmt.Errorf("error converting model network acl value") } - return &sqlserverflexalpha.UpdateInstanceRequestPayload{ + return &sqlserverflex.UpdateInstanceRequestPayload{ BackupSchedule: m.BackupSchedule.ValueStringPointer(), FlavorId: m.FlavorId.ValueStringPointer(), Name: m.Name.ValueStringPointer(), - Network: sqlserverflexalpha.NewUpdateInstanceRequestPayloadNetwork(netAcl), - Replicas: &replVal, - RetentionDays: m.RetentionDays.ValueInt64Pointer(), - Storage: &sqlserverflexalpha.StorageUpdate{Size: m.Storage.Size.ValueInt64Pointer()}, - Version: sqlserverflexalpha.UpdateInstanceRequestPayloadGetVersionAttributeType( - m.Version.ValueStringPointer(), - ), + Network: &sqlserverflex.UpdateInstanceRequestPayloadNetwork{ + Acl: &netAcl, + }, + Replicas: &replVal, + RetentionDays: m.RetentionDays.ValueInt64Pointer(), + Storage: &sqlserverflex.StorageUpdate{Size: m.Storage.Size.ValueInt64Pointer()}, + Version: sqlserverflex.UpdateInstanceRequestPayloadGetVersionAttributeType(m.Version.ValueStringPointer()), }, nil } diff --git a/stackit/internal/services/sqlserverflexalpha/instance/resource.go b/stackit/internal/services/sqlserverflexalpha/instance/resource.go index 3b1f4fd3..76c73639 100644 --- a/stackit/internal/services/sqlserverflexalpha/instance/resource.go +++ b/stackit/internal/services/sqlserverflexalpha/instance/resource.go @@ -1,3 +1,5 @@ +// Copyright (c) STACKIT + package sqlserverflexalpha import ( @@ -8,25 +10,24 @@ import ( "strings" "time" + "github.com/hashicorp/terraform-plugin-framework/resource/identityschema" + sqlserverflexalpha2 "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/resources_gen" + sqlserverflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/identityschema" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/stackitcloud/stackit-sdk-go/core/config" - "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" - wait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexalpha" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" - + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" + wait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexalpha" - sqlserverflexalphaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance/resources_gen" + "github.com/stackitcloud/stackit-sdk-go/core/oapierror" ) +// Ensure the implementation satisfies the expected interfaces. var ( _ resource.Resource = &instanceResource{} _ resource.ResourceWithConfigure = &instanceResource{} @@ -35,17 +36,19 @@ var ( _ resource.ResourceWithIdentity = &instanceResource{} ) +// NewInstanceResource is a helper function to simplify the provider implementation. func NewInstanceResource() resource.Resource { return &instanceResource{} } -type instanceResource struct { - client *sqlserverflexalpha.APIClient - providerData core.ProviderData +//nolint:unused // TODO: remove if not needed later +var validNodeTypes []string = []string{ + "Single", + "Replica", } // resourceModel describes the resource data model. -type resourceModel = sqlserverflexalphaResGen.InstanceModel +type resourceModel = sqlserverflexalpha2.InstanceModel type InstanceResourceIdentityModel struct { ProjectID types.String `tfsdk:"project_id"` @@ -53,19 +56,94 @@ type InstanceResourceIdentityModel struct { InstanceID types.String `tfsdk:"instance_id"` } -func (r *instanceResource) Metadata( - _ context.Context, - req resource.MetadataRequest, - resp *resource.MetadataResponse, -) { +// instanceResource is the resource implementation. +type instanceResource struct { + client *sqlserverflexalpha.APIClient + providerData core.ProviderData +} + +// Metadata returns the resource type name. +func (r *instanceResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_instance" } +// Configure adds the provider configured client to the resource. +func (r *instanceResource) Configure( + ctx context.Context, + req resource.ConfigureRequest, + resp *resource.ConfigureResponse, +) { + var ok bool + r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics) + if !ok { + return + } + + apiClient := sqlserverflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + r.client = apiClient + tflog.Info(ctx, "SQLServer Flex instance client configured") +} + +// ModifyPlan implements resource.ResourceWithModifyPlan. +// Use the modifier to set the effective region in the current plan. +func (r *instanceResource) ModifyPlan( + ctx context.Context, + req resource.ModifyPlanRequest, + resp *resource.ModifyPlanResponse, +) { // nolint:gocritic // function signature required by Terraform + + // skip initial empty configuration to avoid follow-up errors + if req.Config.Raw.IsNull() { + return + } + var configModel sqlserverflexalpha2.InstanceModel + resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...) + if resp.Diagnostics.HasError() { + return + } + + if req.Plan.Raw.IsNull() { + return + } + var planModel sqlserverflexalpha2.InstanceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...) + if resp.Diagnostics.HasError() { + return + } + + utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp) + if resp.Diagnostics.HasError() { + return + } + + var identityModel InstanceResourceIdentityModel + identityModel.ProjectID = planModel.ProjectId + identityModel.Region = planModel.Region + if !planModel.InstanceId.IsNull() && !planModel.InstanceId.IsUnknown() { + identityModel.InstanceID = planModel.InstanceId + } + + resp.Diagnostics.Append(resp.Identity.Set(ctx, identityModel)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...) + if resp.Diagnostics.HasError() { + return + } +} + //go:embed planModifiers.yaml var modifiersFileByte []byte +// Schema defines the schema for the resource. func (r *instanceResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - s := sqlserverflexalphaResGen.InstanceResourceSchema(ctx) + + schema := sqlserverflexalpha2.InstanceResourceSchema(ctx) fields, err := utils.ReadModifiersConfig(modifiersFileByte) if err != nil { @@ -73,12 +151,12 @@ func (r *instanceResource) Schema(ctx context.Context, _ resource.SchemaRequest, return } - err = utils.AddPlanModifiersToResourceSchema(fields, &s) + err = utils.AddPlanModifiersToResourceSchema(fields, &schema) if err != nil { resp.Diagnostics.AddError("error adding plan modifiers", err.Error()) return } - resp.Schema = s + resp.Schema = schema } func (r *instanceResource) IdentitySchema( @@ -101,354 +179,15 @@ func (r *instanceResource) IdentitySchema( } } -// Configure adds the provider configured client to the resource. -func (r *instanceResource) Configure( +// Create creates the resource and sets the initial Terraform state. +func (r *instanceResource) Create( ctx context.Context, - req resource.ConfigureRequest, - resp *resource.ConfigureResponse, -) { - var ok bool - r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics) - if !ok { - return - } - - apiClientConfigOptions := []config.ConfigurationOption{ - config.WithCustomAuth(r.providerData.RoundTripper), - utils.UserAgentConfigOption(r.providerData.Version), - } - if r.providerData.SQLServerFlexCustomEndpoint != "" { - apiClientConfigOptions = append( - apiClientConfigOptions, - config.WithEndpoint(r.providerData.SQLServerFlexCustomEndpoint), - ) - } else { - apiClientConfigOptions = append(apiClientConfigOptions, config.WithRegion(r.providerData.GetRegion())) - } - apiClient, err := sqlserverflexalpha.NewAPIClient(apiClientConfigOptions...) - if err != nil { - resp.Diagnostics.AddError( - "Error configuring API client", - fmt.Sprintf( - "Configuring client: %v. This is an error related to the provider configuration, not to the resource configuration", - err, - ), - ) - return - } - r.client = apiClient - tflog.Info(ctx, "sqlserverflexalpha.Instance client configured") -} - -// ModifyPlan implements resource.ResourceWithModifyPlan. -// Use the modifier to set the effective region in the current plan. -func (r *instanceResource) ModifyPlan( - ctx context.Context, - req resource.ModifyPlanRequest, - resp *resource.ModifyPlanResponse, + req resource.CreateRequest, + resp *resource.CreateResponse, ) { // nolint:gocritic // function signature required by Terraform - // skip initial empty configuration to avoid follow-up errors - if req.Config.Raw.IsNull() { - return - } - var configModel resourceModel - resp.Diagnostics.Append(req.Config.Get(ctx, &configModel)...) - if resp.Diagnostics.HasError() { - return - } - - if req.Plan.Raw.IsNull() { - return - } - var planModel resourceModel - resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...) - if resp.Diagnostics.HasError() { - return - } - - utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...) - if resp.Diagnostics.HasError() { - return - } -} - -func (r *instanceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data resourceModel - crateErr := "[SQL Server Flex BETA - Create] error" - - // Read Terraform plan data into the model - resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - ctx = core.InitProviderContext(ctx) - - projectId := data.ProjectId.ValueString() - region := data.Region.ValueString() - ctx = tflog.SetField(ctx, "project_id", projectId) - ctx = tflog.SetField(ctx, "region", region) - - // Generate API request body from model - payload, err := toCreatePayload(ctx, &data) - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - crateErr, - fmt.Sprintf("Creating API payload: %v", err), - ) - return - } - // Create new Instance - createResp, err := r.client.CreateInstanceRequest( - ctx, - projectId, - region, - ).CreateInstanceRequestPayload(*payload).Execute() - if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, crateErr, fmt.Sprintf("Calling API: %v", err)) - return - } - - ctx = core.LogResponse(ctx) - - InstanceId := *createResp.Id - - // Example data value setting - data.InstanceId = types.StringValue("id-from-response") - - identity := InstanceResourceIdentityModel{ - ProjectID: types.StringValue(projectId), - Region: types.StringValue(region), - InstanceID: types.StringValue(InstanceId), - } - resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...) - if resp.Diagnostics.HasError() { - return - } - - waitResp, err := wait.CreateInstanceWaitHandler( - ctx, - r.client, - projectId, - InstanceId, - region, - ).SetSleepBeforeWait( - 10 * time.Second, - ).SetTimeout( - 90 * time.Minute, - ).WaitWithContext(ctx) - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - crateErr, - fmt.Sprintf("Instance creation waiting: %v", err), - ) - return - } - - if waitResp.Id == nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - crateErr, - "Instance creation waiting: returned id is nil", - ) - return - } - - // Map response body to schema - err = mapResponseToModel(ctx, waitResp, &data, resp.Diagnostics) - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - crateErr, - fmt.Sprintf("processing API payload: %v", err), - ) - return - } - - // Save data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - - tflog.Info(ctx, "sqlserverflexalpha.Instance created") -} - -func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data resourceModel - - // Read Terraform prior state data into the model - resp.Diagnostics.Append(req.State.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - // Read identity data - var identityData InstanceResourceIdentityModel - resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...) - if resp.Diagnostics.HasError() { - return - } - - ctx = core.InitProviderContext(ctx) - - projectId := data.ProjectId.ValueString() - region := data.Region.ValueString() - ctx = tflog.SetField(ctx, "project_id", projectId) - ctx = tflog.SetField(ctx, "region", region) - - instanceId := data.InstanceId.ValueString() - ctx = tflog.SetField(ctx, "instance_id", instanceId) - - instanceResp, err := r.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute() - if err != nil { - oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped - if ok && oapiErr.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } - core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", err.Error()) - return - } - - ctx = core.LogResponse(ctx) - - // Map response body to schema - err = mapResponseToModel(ctx, instanceResp, &data, resp.Diagnostics) - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - "Error reading instance", - fmt.Sprintf("Processing API payload: %v", err), - ) - return - } - - // Save identity into Terraform state - identity := InstanceResourceIdentityModel{ - ProjectID: types.StringValue(projectId), - Region: types.StringValue(region), - InstanceID: types.StringValue(instanceId), - } - resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...) - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Info(ctx, "sqlserverflexalpha.Instance read") -} - -func (r *instanceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var data resourceModel - updateInstanceError := "Error updating instance" - - resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - ctx = core.InitProviderContext(ctx) - - projectId := data.ProjectId.ValueString() - region := data.Region.ValueString() - ctx = tflog.SetField(ctx, "project_id", projectId) - ctx = tflog.SetField(ctx, "region", region) - - instanceId := data.InstanceId.ValueString() - ctx = tflog.SetField(ctx, "instance_id", instanceId) - - // Generate API request body from model - payload, err := toUpdatePayload(ctx, &data, resp) - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - updateInstanceError, - fmt.Sprintf("Creating API payload: %v", err), - ) - return - } - // Update existing instance - err = r.client.UpdateInstanceRequest( - ctx, - projectId, - region, - instanceId, - ).UpdateInstanceRequestPayload(*payload).Execute() - if err != nil { - core.LogAndAddError(ctx, &resp.Diagnostics, updateInstanceError, err.Error()) - return - } - - ctx = core.LogResponse(ctx) - - waitResp, err := wait. - UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId, region). - SetSleepBeforeWait(15 * time.Second). - SetTimeout(45 * time.Minute). - WaitWithContext(ctx) - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - updateInstanceError, - fmt.Sprintf("Instance update waiting: %v", err), - ) - return - } - - // Map response body to schema - err = mapResponseToModel(ctx, waitResp, &data, resp.Diagnostics) - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - updateInstanceError, - fmt.Sprintf("Processing API payload: %v", err), - ) - return - } - - identity := InstanceResourceIdentityModel{ - ProjectID: types.StringValue(projectId), - Region: types.StringValue(region), - InstanceID: types.StringValue(instanceId), - } - resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...) - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - tflog.Info(ctx, "sqlserverflexalpha.Instance updated") -} - -func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data resourceModel - - // Read Terraform prior state data into the model - resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + var model resourceModel + diags := req.Plan.Get(ctx, &model) + resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return } @@ -467,8 +206,284 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "region", region) - instanceId := identityData.InstanceID.ValueString() + // Generate API request body from model + payload, err := toCreatePayload(ctx, &model) + if err != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error creating instance", + fmt.Sprintf("Creating API payload: %v", err), + ) + return + } + // Create new instance + createResp, err := r.client.CreateInstanceRequest( + ctx, + projectId, + region, + ).CreateInstanceRequestPayload(*payload).Execute() + if err != nil { + core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Calling API: %v", err)) + return + } + + ctx = core.LogResponse(ctx) + + instanceId := *createResp.Id + + // Set data returned by API in identity + identity := InstanceResourceIdentityModel{ + ProjectID: types.StringValue(projectId), + Region: types.StringValue(region), + InstanceID: types.StringValue(instanceId), + } + resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...) + if resp.Diagnostics.HasError() { + return + } + + utils.SetAndLogStateFields( + ctx, &resp.Diagnostics, &resp.State, map[string]any{ + "id": utils.BuildInternalTerraformId(projectId, region, instanceId), + "instance_id": instanceId, + }, + ) + if resp.Diagnostics.HasError() { + return + } + + // The creation waiter sometimes returns an error from the API: "instance with id xxx has unexpected status Failure" + // which can be avoided by sleeping before wait + waitResp, err := wait.CreateInstanceWaitHandler( + ctx, + r.client, + projectId, + instanceId, + region, + ).SetSleepBeforeWait( + 30 * time.Second, + ).SetTimeout( + 90 * time.Minute, + ).WaitWithContext(ctx) + if err != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error creating instance", + fmt.Sprintf("Instance creation waiting: %v", err), + ) + return + } + + if waitResp.FlavorId == nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error creating instance", + "Instance creation waiting: returned flavor id is nil", + ) + return + } + + // Map response body to schema + // err = mapFields(ctx, waitResp, &model, storage, encryption, network, region) + err = mapFields(ctx, waitResp, &model, resp.Diagnostics) + if err != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error creating instance", + fmt.Sprintf("Processing API payload: %v", err), + ) + return + } + // Set state to fully populated data + diags = resp.State.Set(ctx, model) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Info(ctx, "SQLServer Flex instance created") +} + +// Read refreshes the Terraform state with the latest data. +func (r *instanceResource) Read( + ctx context.Context, + req resource.ReadRequest, + resp *resource.ReadResponse, +) { // nolint:gocritic // function signature required by Terraform + var model resourceModel + diags := req.State.Get(ctx, &model) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + // Read identity data + var identityData InstanceResourceIdentityModel + resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...) + if resp.Diagnostics.HasError() { + return + } + + ctx = core.InitProviderContext(ctx) + + projectId := model.ProjectId.ValueString() + instanceId := model.InstanceId.ValueString() + region := r.providerData.GetRegionWithOverride(model.Region) + + ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "instance_id", instanceId) + ctx = tflog.SetField(ctx, "region", region) + + instanceResp, err := r.client.GetInstanceRequest(ctx, projectId, region, instanceId).Execute() + if err != nil { + oapiErr, ok := err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped + if ok && oapiErr.StatusCode == http.StatusNotFound { + resp.State.RemoveResource(ctx) + return + } + core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", err.Error()) + return + } + + ctx = core.LogResponse(ctx) + + // Map response body to schema + err = mapFields(ctx, instanceResp, &model, resp.Diagnostics) + if err != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error reading instance", + fmt.Sprintf("Processing API payload: %v", err), + ) + return + } + // Set refreshed state + diags = resp.State.Set(ctx, model) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + // Set data returned by API in identity + identity := InstanceResourceIdentityModel{ + ProjectID: types.StringValue(projectId), + Region: types.StringValue(region), + InstanceID: types.StringValue(instanceId), + } + resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...) + if resp.Diagnostics.HasError() { + return + } + tflog.Info(ctx, "SQLServer Flex instance read") +} + +// Update updates the resource and sets the updated Terraform state on success. +func (r *instanceResource) Update( + ctx context.Context, + req resource.UpdateRequest, + resp *resource.UpdateResponse, +) { // nolint:gocritic // function signature required by Terraform + // Retrieve values from plan + var model resourceModel + diags := req.Plan.Get(ctx, &model) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + ctx = core.InitProviderContext(ctx) + + projectId := model.ProjectId.ValueString() + instanceId := model.InstanceId.ValueString() + region := model.Region.ValueString() + + ctx = tflog.SetField(ctx, "project_id", projectId) + ctx = tflog.SetField(ctx, "instance_id", instanceId) + ctx = tflog.SetField(ctx, "region", region) + + // Generate API request body from model + payload, err := toUpdatePayload(ctx, &model, resp) + if err != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error updating instance", + fmt.Sprintf("Creating API payload: %v", err), + ) + return + } + // Update existing instance + err = r.client.UpdateInstanceRequest( + ctx, + projectId, + region, + instanceId, + ).UpdateInstanceRequestPayload(*payload).Execute() + if err != nil { + core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", err.Error()) + return + } + + ctx = core.LogResponse(ctx) + + waitResp, err := wait.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).WaitWithContext(ctx) + if err != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error updating instance", + fmt.Sprintf("Instance update waiting: %v", err), + ) + return + } + + // Map response body to schema + err = mapFields(ctx, waitResp, &model, resp.Diagnostics) + // err = mapFields(ctx, waitResp, &model, storage, encryption, network, region) + if err != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error updating instance", + fmt.Sprintf("Processing API payload: %v", err), + ) + return + } + diags = resp.State.Set(ctx, model) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + tflog.Info(ctx, "SQLServer Flex instance updated") +} + +// Delete deletes the resource and removes the Terraform state on success. +func (r *instanceResource) Delete( + ctx context.Context, + req resource.DeleteRequest, + resp *resource.DeleteResponse, +) { // nolint:gocritic // function signature required by Terraform + // Retrieve values from state + var model resourceModel + diags := req.State.Get(ctx, &model) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + ctx = core.InitProviderContext(ctx) + + projectId := model.ProjectId.ValueString() + instanceId := model.InstanceId.ValueString() + region := model.Region.ValueString() + ctx = tflog.SetField(ctx, "project_id", projectId) + ctx = tflog.SetField(ctx, "instance_id", instanceId) + ctx = tflog.SetField(ctx, "region", region) // Delete existing instance err := r.client.DeleteInstanceRequest(ctx, projectId, region, instanceId).Execute() @@ -479,7 +494,7 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques ctx = core.LogResponse(ctx) - delResp, err := wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).WaitWithContext(ctx) + _, err = wait.DeleteInstanceWaitHandler(ctx, r.client, projectId, instanceId, region).WaitWithContext(ctx) if err != nil { core.LogAndAddError( ctx, @@ -489,31 +504,16 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques ) return } - - if delResp != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - "Error deleting instance", - "wait handler returned non nil result", - ) - return - } - - resp.State.RemoveResource(ctx) - - tflog.Info(ctx, "sqlserverflexalpha.Instance deleted") + tflog.Info(ctx, "SQLServer Flex instance deleted") } // ImportState imports a resource into the Terraform state on success. -// The expected format of the resource import identifier is: project_id,zone_id,record_set_id +// The expected format of the resource import identifier is: project_id,instance_id func (r *instanceResource) ImportState( ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse, ) { - ctx = core.InitProviderContext(ctx) - if req.ID != "" { idParts := strings.Split(req.ID, core.Separator) @@ -522,7 +522,7 @@ func (r *instanceResource) ImportState( ctx, &resp.Diagnostics, "Error importing instance", fmt.Sprintf( - "Expected import identifier with format [project_id],[region],[instance_id] Got: %q", + "Expected import identifier with format: [project_id],[region],[instance_id] Got: %q", req.ID, ), ) @@ -550,5 +550,5 @@ func (r *instanceResource) ImportState( resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("region"), region)...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), instanceId)...) - tflog.Info(ctx, "sqlserverflexalpha instance state imported") + tflog.Info(ctx, "SQLServer Flex instance state imported") } diff --git a/stackit/internal/services/sqlserverflexalpha/instance/resource_test.go b/stackit/internal/services/sqlserverflexalpha/instance/resource_test.go new file mode 100644 index 00000000..175711ff --- /dev/null +++ b/stackit/internal/services/sqlserverflexalpha/instance/resource_test.go @@ -0,0 +1,823 @@ +package sqlserverflexalpha + +// type sqlserverflexClientMocked struct { +// returnError bool +// listFlavorsResp *sqlserverflex.GetFlavorsResponse +// } +// +// func (c *sqlserverflexClientMocked) GetFlavorsExecute(_ context.Context, _, _ string) (*sqlserverflex.GetFlavorsResponse, error) { +// if c.returnError { +// return nil, fmt.Errorf("get flavors failed") +// } +// +// return c.listFlavorsResp, nil +// } + +//func TestMapFields(t *testing.T) { +// t.Skip("Skipping - needs refactoring") +// const testRegion = "region" +// tests := []struct { +// description string +// state Model +// input *sqlserverflex.GetInstanceResponse +// storage *storageModel +// encryption *encryptionModel +// network *networkModel +// region string +// expected Model +// isValid bool +// }{ +// { +// "default_values", +// Model{ +// InstanceId: types.StringValue("iid"), +// ProjectId: types.StringValue("pid"), +// Replicas: types.Int64Value(1), +// RetentionDays: types.Int64Value(1), +// Version: types.StringValue("v1"), +// Edition: types.StringValue("edition 1"), +// Status: types.StringValue("status"), +// IsDeletable: types.BoolValue(true), +// }, +// &sqlserverflex.GetInstanceResponse{ +// FlavorId: utils.Ptr("flavor_id"), +// Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(1))), +// RetentionDays: utils.Ptr(int64(1)), +// Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("v1")), +// Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition 1")), +// Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")), +// IsDeletable: utils.Ptr(true), +// }, +// &storageModel{}, +// &encryptionModel{}, +// &networkModel{ +// ACL: types.ListNull(basetypes.StringType{}), +// }, +// testRegion, +// Model{ +// Id: types.StringValue("pid,region,iid"), +// InstanceId: types.StringValue("iid"), +// ProjectId: types.StringValue("pid"), +// Name: types.StringNull(), +// BackupSchedule: types.StringNull(), +// Replicas: types.Int64Value(1), +// Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{ +// "class": types.StringNull(), +// "size": types.Int64Null(), +// }), +// Encryption: types.ObjectValueMust(encryptionTypes, map[string]attr.Value{ +// "keyring_id": types.StringNull(), +// "key_id": types.StringNull(), +// "key_version": types.StringNull(), +// "service_account": types.StringNull(), +// }), +// Network: types.ObjectValueMust(networkTypes, map[string]attr.Value{ +// "acl": types.ListNull(types.StringType), +// "access_scope": types.StringNull(), +// "instance_address": types.StringNull(), +// "router_address": types.StringNull(), +// }), +// IsDeletable: types.BoolValue(true), +// Edition: types.StringValue("edition 1"), +// Status: types.StringValue("status"), +// RetentionDays: types.Int64Value(1), +// Version: types.StringValue("v1"), +// Region: types.StringValue(testRegion), +// }, +// true, +// }, +// { +// "simple_values", +// Model{ +// InstanceId: types.StringValue("iid"), +// ProjectId: types.StringValue("pid"), +// }, +// &sqlserverflex.GetInstanceResponse{ +// BackupSchedule: utils.Ptr("schedule"), +// FlavorId: utils.Ptr("flavor_id"), +// Id: utils.Ptr("iid"), +// Name: utils.Ptr("name"), +// Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))), +// Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")), +// Storage: &sqlserverflex.Storage{ +// Class: utils.Ptr("class"), +// Size: utils.Ptr(int64(78)), +// }, +// Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition")), +// RetentionDays: utils.Ptr(int64(1)), +// Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")), +// IsDeletable: utils.Ptr(true), +// Encryption: nil, +// Network: &sqlserverflex.InstanceNetwork{ +// AccessScope: nil, +// Acl: &[]string{ +// "ip1", +// "ip2", +// "", +// }, +// InstanceAddress: nil, +// RouterAddress: nil, +// }, +// }, +// &storageModel{}, +// &encryptionModel{}, +// &networkModel{ +// ACL: types.ListValueMust(basetypes.StringType{}, []attr.Value{ +// types.StringValue("ip1"), +// types.StringValue("ip2"), +// types.StringValue(""), +// }), +// }, +// testRegion, +// Model{ +// Id: types.StringValue("pid,region,iid"), +// InstanceId: types.StringValue("iid"), +// ProjectId: types.StringValue("pid"), +// Name: types.StringValue("name"), +// BackupSchedule: types.StringValue("schedule"), +// Replicas: types.Int64Value(56), +// Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{ +// "class": types.StringValue("class"), +// "size": types.Int64Value(78), +// }), +// Network: types.ObjectValueMust(networkTypes, map[string]attr.Value{ +// "acl": types.ListValueMust(types.StringType, []attr.Value{ +// types.StringValue("ip1"), +// types.StringValue("ip2"), +// types.StringValue(""), +// }), +// "access_scope": types.StringNull(), +// "instance_address": types.StringNull(), +// "router_address": types.StringNull(), +// }), +// Edition: types.StringValue("edition"), +// RetentionDays: types.Int64Value(1), +// Version: types.StringValue("version"), +// Region: types.StringValue(testRegion), +// IsDeletable: types.BoolValue(true), +// Encryption: types.ObjectValueMust(encryptionTypes, map[string]attr.Value{ +// "keyring_id": types.StringNull(), +// "key_id": types.StringNull(), +// "key_version": types.StringNull(), +// "service_account": types.StringNull(), +// }), +// Status: types.StringValue("status"), +// }, +// true, +// }, +// // { +// // "simple_values_no_flavor_and_storage", +// // Model{ +// // InstanceId: types.StringValue("iid"), +// // ProjectId: types.StringValue("pid"), +// // }, +// // &sqlserverflex.GetInstanceResponse{ +// // Acl: &[]string{ +// // "ip1", +// // "ip2", +// // "", +// // }, +// // BackupSchedule: utils.Ptr("schedule"), +// // FlavorId: nil, +// // Id: utils.Ptr("iid"), +// // Name: utils.Ptr("name"), +// // Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))), +// // Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")), +// // Storage: nil, +// // Edition: sqlserverflex.GetInstanceResponseGetEditionAttributeType(utils.Ptr("edition")), +// // RetentionDays: utils.Ptr(int64(1)), +// // Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")), +// // }, +// // &flavorModel{ +// // CPU: types.Int64Value(12), +// // RAM: types.Int64Value(34), +// // }, +// // &storageModel{ +// // Class: types.StringValue("class"), +// // Size: types.Int64Value(78), +// // }, +// // &optionsModel{ +// // Edition: types.StringValue("edition"), +// // RetentionDays: types.Int64Value(1), +// // }, +// // testRegion, +// // Model{ +// // Id: types.StringValue("pid,region,iid"), +// // InstanceId: types.StringValue("iid"), +// // ProjectId: types.StringValue("pid"), +// // Name: types.StringValue("name"), +// // ACL: types.ListValueMust(types.StringType, []attr.Value{ +// // types.StringValue("ip1"), +// // types.StringValue("ip2"), +// // types.StringValue(""), +// // }), +// // BackupSchedule: types.StringValue("schedule"), +// // Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{ +// // "id": types.StringNull(), +// // "description": types.StringNull(), +// // "cpu": types.Int64Value(12), +// // "ram": types.Int64Value(34), +// // }), +// // Replicas: types.Int64Value(56), +// // Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{ +// // "class": types.StringValue("class"), +// // "size": types.Int64Value(78), +// // }), +// // Options: types.ObjectValueMust(optionsTypes, map[string]attr.Value{ +// // "edition": types.StringValue("edition"), +// // "retention_days": types.Int64Value(1), +// // }), +// // Version: types.StringValue("version"), +// // Region: types.StringValue(testRegion), +// // }, +// // true, +// // }, +// // { +// // "acls_unordered", +// // Model{ +// // InstanceId: types.StringValue("iid"), +// // ProjectId: types.StringValue("pid"), +// // ACL: types.ListValueMust(types.StringType, []attr.Value{ +// // types.StringValue("ip2"), +// // types.StringValue(""), +// // types.StringValue("ip1"), +// // }), +// // }, +// // &sqlserverflex.GetInstanceResponse{ +// // Acl: &[]string{ +// // "", +// // "ip1", +// // "ip2", +// // }, +// // BackupSchedule: utils.Ptr("schedule"), +// // FlavorId: nil, +// // Id: utils.Ptr("iid"), +// // Name: utils.Ptr("name"), +// // Replicas: sqlserverflex.GetInstanceResponseGetReplicasAttributeType(utils.Ptr(int32(56))), +// // Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr("status")), +// // Storage: nil, +// // //Options: &map[string]string{ +// // // "edition": "edition", +// // // "retentionDays": "1", +// // //}, +// // Version: sqlserverflex.GetInstanceResponseGetVersionAttributeType(utils.Ptr("version")), +// // }, +// // &flavorModel{ +// // CPU: types.Int64Value(12), +// // RAM: types.Int64Value(34), +// // }, +// // &storageModel{ +// // Class: types.StringValue("class"), +// // Size: types.Int64Value(78), +// // }, +// // &optionsModel{}, +// // testRegion, +// // Model{ +// // Id: types.StringValue("pid,region,iid"), +// // InstanceId: types.StringValue("iid"), +// // ProjectId: types.StringValue("pid"), +// // Name: types.StringValue("name"), +// // ACL: types.ListValueMust(types.StringType, []attr.Value{ +// // types.StringValue("ip2"), +// // types.StringValue(""), +// // types.StringValue("ip1"), +// // }), +// // BackupSchedule: types.StringValue("schedule"), +// // Flavor: types.ObjectValueMust(flavorTypes, map[string]attr.Value{ +// // "id": types.StringNull(), +// // "description": types.StringNull(), +// // "cpu": types.Int64Value(12), +// // "ram": types.Int64Value(34), +// // }), +// // Replicas: types.Int64Value(56), +// // Storage: types.ObjectValueMust(storageTypes, map[string]attr.Value{ +// // "class": types.StringValue("class"), +// // "size": types.Int64Value(78), +// // }), +// // Options: types.ObjectValueMust(optionsTypes, map[string]attr.Value{ +// // "edition": types.StringValue("edition"), +// // "retention_days": types.Int64Value(1), +// // }), +// // Version: types.StringValue("version"), +// // Region: types.StringValue(testRegion), +// // }, +// // true, +// // }, +// // { +// // "nil_response", +// // Model{ +// // InstanceId: types.StringValue("iid"), +// // ProjectId: types.StringValue("pid"), +// // }, +// // nil, +// // &flavorModel{}, +// // &storageModel{}, +// // &optionsModel{}, +// // testRegion, +// // Model{}, +// // false, +// // }, +// // { +// // "no_resource_id", +// // Model{ +// // InstanceId: types.StringValue("iid"), +// // ProjectId: types.StringValue("pid"), +// // }, +// // &sqlserverflex.GetInstanceResponse{}, +// // &flavorModel{}, +// // &storageModel{}, +// // &optionsModel{}, +// // testRegion, +// // Model{}, +// // false, +// // }, +// } +// for _, tt := range tests { +// t.Run(tt.description, func(t *testing.T) { +// err := mapFields(context.Background(), tt.input, &tt.state, tt.storage, tt.encryption, tt.network, tt.region) +// if !tt.isValid && err == nil { +// t.Fatalf("Should have failed") +// } +// if tt.isValid && err != nil { +// t.Fatalf("Should not have failed: %v", err) +// } +// if tt.isValid { +// diff := cmp.Diff(tt.state, tt.expected) +// if diff != "" { +// t.Fatalf("Data does not match: %s", diff) +// } +// } +// }) +// } +//} + +// func TestToCreatePayload(t *testing.T) { +// tests := []struct { +// description string +// input *Model +// inputAcl []string +// inputFlavor *flavorModel +// inputStorage *storageModel +// inputOptions *optionsModel +// expected *sqlserverflex.CreateInstanceRequestPayload +// isValid bool +// }{ +// { +// "default_values", +// &Model{}, +// []string{}, +// &flavorModel{}, +// &storageModel{}, +// &optionsModel{}, +// &sqlserverflex.CreateInstanceRequestPayload{ +// Acl: &sqlserverflex.CreateInstanceRequestPayloadGetAclArgType{}, +// Storage: &sqlserverflex.CreateInstanceRequestPayloadGetStorageArgType{}, +// }, +// true, +// }, +// { +// "simple_values", +// &Model{ +// BackupSchedule: types.StringValue("schedule"), +// Name: types.StringValue("name"), +// Replicas: types.Int64Value(12), +// Version: types.StringValue("version"), +// }, +// []string{ +// "ip_1", +// "ip_2", +// }, +// &flavorModel{ +// Id: types.StringValue("flavor_id"), +// }, +// &storageModel{ +// Class: types.StringValue("class"), +// Size: types.Int64Value(34), +// }, +// &optionsModel{ +// Edition: types.StringValue("edition"), +// RetentionDays: types.Int64Value(1), +// }, +// &sqlserverflex.CreateInstancePayload{ +// Acl: &sqlserverflex.CreateInstancePayloadAcl{ +// Items: &[]string{ +// "ip_1", +// "ip_2", +// }, +// }, +// BackupSchedule: utils.Ptr("schedule"), +// FlavorId: utils.Ptr("flavor_id"), +// Name: utils.Ptr("name"), +// Storage: &sqlserverflex.CreateInstancePayloadStorage{ +// Class: utils.Ptr("class"), +// Size: utils.Ptr(int64(34)), +// }, +// Options: &sqlserverflex.CreateInstancePayloadOptions{ +// Edition: utils.Ptr("edition"), +// RetentionDays: utils.Ptr("1"), +// }, +// Version: utils.Ptr("version"), +// }, +// true, +// }, +// { +// "null_fields_and_int_conversions", +// &Model{ +// BackupSchedule: types.StringNull(), +// Name: types.StringNull(), +// Replicas: types.Int64Value(2123456789), +// Version: types.StringNull(), +// }, +// []string{ +// "", +// }, +// &flavorModel{ +// Id: types.StringNull(), +// }, +// &storageModel{ +// Class: types.StringNull(), +// Size: types.Int64Null(), +// }, +// &optionsModel{ +// Edition: types.StringNull(), +// RetentionDays: types.Int64Null(), +// }, +// &sqlserverflex.CreateInstancePayload{ +// Acl: &sqlserverflex.CreateInstancePayloadAcl{ +// Items: &[]string{ +// "", +// }, +// }, +// BackupSchedule: nil, +// FlavorId: nil, +// Name: nil, +// Storage: &sqlserverflex.CreateInstancePayloadStorage{ +// Class: nil, +// Size: nil, +// }, +// Options: &sqlserverflex.CreateInstancePayloadOptions{}, +// Version: nil, +// }, +// true, +// }, +// { +// "nil_model", +// nil, +// []string{}, +// &flavorModel{}, +// &storageModel{}, +// &optionsModel{}, +// nil, +// false, +// }, +// { +// "nil_acl", +// &Model{}, +// nil, +// &flavorModel{}, +// &storageModel{}, +// &optionsModel{}, +// &sqlserverflex.CreateInstancePayload{ +// Acl: &sqlserverflex.CreateInstancePayloadAcl{}, +// Storage: &sqlserverflex.CreateInstancePayloadStorage{}, +// Options: &sqlserverflex.CreateInstancePayloadOptions{}, +// }, +// true, +// }, +// { +// "nil_flavor", +// &Model{}, +// []string{}, +// nil, +// &storageModel{}, +// &optionsModel{}, +// nil, +// false, +// }, +// { +// "nil_storage", +// &Model{}, +// []string{}, +// &flavorModel{}, +// nil, +// &optionsModel{}, +// &sqlserverflex.CreateInstancePayload{ +// Acl: &sqlserverflex.CreateInstancePayloadAcl{ +// Items: &[]string{}, +// }, +// Storage: &sqlserverflex.CreateInstancePayloadStorage{}, +// Options: &sqlserverflex.CreateInstancePayloadOptions{}, +// }, +// true, +// }, +// { +// "nil_options", +// &Model{}, +// []string{}, +// &flavorModel{}, +// &storageModel{}, +// nil, +// &sqlserverflex.CreateInstancePayload{ +// Acl: &sqlserverflex.CreateInstancePayloadAcl{ +// Items: &[]string{}, +// }, +// Storage: &sqlserverflex.CreateInstancePayloadStorage{}, +// Options: &sqlserverflex.CreateInstancePayloadOptions{}, +// }, +// true, +// }, +// } +// for _, tt := range tests { +// t.Run(tt.description, func(t *testing.T) { +// output, err := toCreatePayload(tt.input, tt.inputAcl, tt.inputFlavor, tt.inputStorage, tt.inputOptions) +// if !tt.isValid && err == nil { +// t.Fatalf("Should have failed") +// } +// if tt.isValid && err != nil { +// t.Fatalf("Should not have failed: %v", err) +// } +// if tt.isValid { +// diff := cmp.Diff(output, tt.expected) +// if diff != "" { +// t.Fatalf("Data does not match: %s", diff) +// } +// } +// }) +// } +// } +// +// func TestToUpdatePayload(t *testing.T) { +// tests := []struct { +// description string +// input *Model +// inputAcl []string +// inputFlavor *flavorModel +// expected *sqlserverflex.PartialUpdateInstancePayload +// isValid bool +// }{ +// { +// "default_values", +// &Model{}, +// []string{}, +// &flavorModel{}, +// &sqlserverflex.PartialUpdateInstancePayload{ +// Acl: &sqlserverflex.CreateInstancePayloadAcl{ +// Items: &[]string{}, +// }, +// }, +// true, +// }, +// { +// "simple_values", +// &Model{ +// BackupSchedule: types.StringValue("schedule"), +// Name: types.StringValue("name"), +// Replicas: types.Int64Value(12), +// Version: types.StringValue("version"), +// }, +// []string{ +// "ip_1", +// "ip_2", +// }, +// &flavorModel{ +// Id: types.StringValue("flavor_id"), +// }, +// &sqlserverflex.PartialUpdateInstancePayload{ +// Acl: &sqlserverflex.CreateInstancePayloadAcl{ +// Items: &[]string{ +// "ip_1", +// "ip_2", +// }, +// }, +// BackupSchedule: utils.Ptr("schedule"), +// FlavorId: utils.Ptr("flavor_id"), +// Name: utils.Ptr("name"), +// Version: utils.Ptr("version"), +// }, +// true, +// }, +// { +// "null_fields_and_int_conversions", +// &Model{ +// BackupSchedule: types.StringNull(), +// Name: types.StringNull(), +// Replicas: types.Int64Value(2123456789), +// Version: types.StringNull(), +// }, +// []string{ +// "", +// }, +// &flavorModel{ +// Id: types.StringNull(), +// }, +// &sqlserverflex.PartialUpdateInstancePayload{ +// Acl: &sqlserverflex.CreateInstancePayloadAcl{ +// Items: &[]string{ +// "", +// }, +// }, +// BackupSchedule: nil, +// FlavorId: nil, +// Name: nil, +// Version: nil, +// }, +// true, +// }, +// { +// "nil_model", +// nil, +// []string{}, +// &flavorModel{}, +// nil, +// false, +// }, +// { +// "nil_acl", +// &Model{}, +// nil, +// &flavorModel{}, +// &sqlserverflex.PartialUpdateInstancePayload{ +// Acl: &sqlserverflex.CreateInstancePayloadAcl{}, +// }, +// true, +// }, +// { +// "nil_flavor", +// &Model{}, +// []string{}, +// nil, +// nil, +// false, +// }, +// } +// for _, tt := range tests { +// t.Run(tt.description, func(t *testing.T) { +// output, err := toUpdatePayload(tt.input, tt.inputAcl, tt.inputFlavor) +// if !tt.isValid && err == nil { +// t.Fatalf("Should have failed") +// } +// if tt.isValid && err != nil { +// t.Fatalf("Should not have failed: %v", err) +// } +// if tt.isValid { +// diff := cmp.Diff(output, tt.expected) +// if diff != "" { +// t.Fatalf("Data does not match: %s", diff) +// } +// } +// }) +// } +// } +// +// func TestLoadFlavorId(t *testing.T) { +// tests := []struct { +// description string +// inputFlavor *flavorModel +// mockedResp *sqlserverflex.ListFlavorsResponse +// expected *flavorModel +// getFlavorsFails bool +// isValid bool +// }{ +// { +// "ok_flavor", +// &flavorModel{ +// CPU: types.Int64Value(2), +// RAM: types.Int64Value(8), +// }, +// &sqlserverflex.ListFlavorsResponse{ +// Flavors: &[]sqlserverflex.InstanceFlavorEntry{ +// { +// Id: utils.Ptr("fid-1"), +// Cpu: utils.Ptr(int64(2)), +// Description: utils.Ptr("description"), +// Ram: utils.Ptr(int64(8)), +// }, +// }, +// }, +// &flavorModel{ +// Id: types.StringValue("fid-1"), +// Description: types.StringValue("description"), +// CPU: types.Int64Value(2), +// RAM: types.Int64Value(8), +// }, +// false, +// true, +// }, +// { +// "ok_flavor_2", +// &flavorModel{ +// CPU: types.Int64Value(2), +// RAM: types.Int64Value(8), +// }, +// &sqlserverflex.ListFlavorsResponse{ +// Flavors: &[]sqlserverflex.InstanceFlavorEntry{ +// { +// Id: utils.Ptr("fid-1"), +// Cpu: utils.Ptr(int64(2)), +// Description: utils.Ptr("description"), +// Ram: utils.Ptr(int64(8)), +// }, +// { +// Id: utils.Ptr("fid-2"), +// Cpu: utils.Ptr(int64(1)), +// Description: utils.Ptr("description"), +// Ram: utils.Ptr(int64(4)), +// }, +// }, +// }, +// &flavorModel{ +// Id: types.StringValue("fid-1"), +// Description: types.StringValue("description"), +// CPU: types.Int64Value(2), +// RAM: types.Int64Value(8), +// }, +// false, +// true, +// }, +// { +// "no_matching_flavor", +// &flavorModel{ +// CPU: types.Int64Value(2), +// RAM: types.Int64Value(8), +// }, +// &sqlserverflex.ListFlavorsResponse{ +// Flavors: &[]sqlserverflex.InstanceFlavorEntry{ +// { +// Id: utils.Ptr("fid-1"), +// Cpu: utils.Ptr(int64(1)), +// Description: utils.Ptr("description"), +// Ram: utils.Ptr(int64(8)), +// }, +// { +// Id: utils.Ptr("fid-2"), +// Cpu: utils.Ptr(int64(1)), +// Description: utils.Ptr("description"), +// Ram: utils.Ptr(int64(4)), +// }, +// }, +// }, +// &flavorModel{ +// CPU: types.Int64Value(2), +// RAM: types.Int64Value(8), +// }, +// false, +// false, +// }, +// { +// "nil_response", +// &flavorModel{ +// CPU: types.Int64Value(2), +// RAM: types.Int64Value(8), +// }, +// &sqlserverflex.ListFlavorsResponse{}, +// &flavorModel{ +// CPU: types.Int64Value(2), +// RAM: types.Int64Value(8), +// }, +// false, +// false, +// }, +// { +// "error_response", +// &flavorModel{ +// CPU: types.Int64Value(2), +// RAM: types.Int64Value(8), +// }, +// &sqlserverflex.ListFlavorsResponse{}, +// &flavorModel{ +// CPU: types.Int64Value(2), +// RAM: types.Int64Value(8), +// }, +// true, +// false, +// }, +// } +// for _, tt := range tests { +// t.Run(tt.description, func(t *testing.T) { +// client := &sqlserverflexClientMocked{ +// returnError: tt.getFlavorsFails, +// listFlavorsResp: tt.mockedResp, +// } +// model := &Model{ +// ProjectId: types.StringValue("pid"), +// } +// flavorModel := &flavorModel{ +// CPU: tt.inputFlavor.CPU, +// RAM: tt.inputFlavor.RAM, +// } +// err := loadFlavorId(context.Background(), client, model, flavorModel) +// if !tt.isValid && err == nil { +// t.Fatalf("Should have failed") +// } +// if tt.isValid && err != nil { +// t.Fatalf("Should not have failed: %v", err) +// } +// if tt.isValid { +// diff := cmp.Diff(flavorModel, tt.expected) +// if diff != "" { +// t.Fatalf("Data does not match: %s", diff) +// } +// } +// }) +// } +// } diff --git a/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go b/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go index 9eebac99..6c2915ea 100644 --- a/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go +++ b/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go @@ -4,68 +4,21 @@ import ( "context" _ "embed" "fmt" - "log" "os" "strconv" - "strings" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/stackitcloud/stackit-sdk-go/core/config" - - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils" - sqlserverflexalphaPkgGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" sqlserverflexalpha "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance" + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils" // The fwresource import alias is so there is no collision // with the more typical acceptance testing import: // "github.com/hashicorp/terraform-plugin-testing/helper/resource" fwresource "github.com/hashicorp/terraform-plugin-framework/resource" ) -const providerPrefix = "stackitprivatepreview_sqlserverflexalpha" - -var testInstances []string - -func init() { - sweeperName := fmt.Sprintf("%s_%s", providerPrefix, "sweeper") - - resource.AddTestSweepers(sweeperName, &resource.Sweeper{ - Name: sweeperName, - F: func(region string) error { - ctx := context.Background() - apiClientConfigOptions := []config.ConfigurationOption{} - apiClient, err := sqlserverflexalphaPkgGen.NewAPIClient(apiClientConfigOptions...) - if err != nil { - log.Fatalln(err) - } - - instances, err := apiClient.ListInstancesRequest(ctx, testutils.ProjectId, region). - Size(100). - Execute() - if err != nil { - log.Fatalln(err) - } - - for _, inst := range instances.GetInstances() { - if strings.HasPrefix(inst.GetName(), "tf-acc-") { - for _, item := range testInstances { - if inst.GetName() == item { - delErr := apiClient.DeleteInstanceRequestExecute(ctx, testutils.ProjectId, region, inst.GetId()) - if delErr != nil { - // TODO: maybe just warn? - log.Fatalln(delErr) - } - } - } - } - } - return nil - }, - }) -} - func TestInstanceResourceSchema(t *testing.T) { t.Parallel() @@ -131,15 +84,9 @@ type User struct { } type Database struct { - Name string - ProjectId string - Owner string - Collation string - Compatibility string -} - -func resName(res, name string) string { - return fmt.Sprintf("%s_%s.%s", providerPrefix, res, name) + Name string + ProjectId string + Owner string } func getExample() resData { @@ -164,6 +111,10 @@ func getExample() resData { func TestAccInstance(t *testing.T) { exData := getExample() + resName := fmt.Sprintf( + "stackitprivatepreview_sqlserverflexalpha_instance.%s", + exData.TfName, + ) updNameData := exData updNameData.Name = "name-updated" @@ -171,12 +122,8 @@ func TestAccInstance(t *testing.T) { updSizeData := exData updSizeData.Size = 25 - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - t.Logf(" ... working on instance %s", exData.TfName) - testInstances = append(testInstances, exData.TfName) - }, + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ // Create and verify @@ -186,9 +133,8 @@ func TestAccInstance(t *testing.T) { exData, ), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", exData.Name), - resource.TestCheckResourceAttrSet(resName("instance", exData.TfName), "id"), - // TODO: check all fields + resource.TestCheckResourceAttr(resName, "name", exData.Name), + resource.TestCheckResourceAttrSet(resName, "id"), ), }, // Update name and verify @@ -198,7 +144,7 @@ func TestAccInstance(t *testing.T) { updNameData, ), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", updNameData.Name), + resource.TestCheckResourceAttr(resName, "name", updNameData.Name), ), }, // Update size and verify @@ -209,42 +155,73 @@ func TestAccInstance(t *testing.T) { ), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - testutils.ResStr(providerPrefix, "instance", exData.TfName), + resName, "storage.size", strconv.Itoa(int(updSizeData.Size)), ), ), }, - { - RefreshState: true, - }, //// Import test //{ - // ResourceName: resName("instance", exData.TfName), + // ResourceName: "example_resource.test", // ImportState: true, // ImportStateVerify: true, - // }, + //}, }, }) } -func TestAccInstanceNoEncryption(t *testing.T) { +func TestAccInstanceWithUsers(t *testing.T) { data := getExample() + userName := "testUser" + data.Users = []User{ + { + Name: userName, + ProjectId: os.Getenv("TF_ACC_PROJECT_ID"), + Roles: []string{"##STACKIT_LoginManager##", "##STACKIT_DatabaseManager##"}, + }, + } + resName := fmt.Sprintf( + "stackitprivatepreview_sqlserverflexalpha_instance.%s", + data.TfName, + ) + + resUserName := fmt.Sprintf( + "stackitprivatepreview_sqlserverflexalpha_user.%s", + userName, + ) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create and verify + { + Config: testutils.StringFromTemplateMust( + "testdata/instance_template.gompl", + data, + ), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resName, "name", data.Name), + resource.TestCheckResourceAttrSet(resName, "id"), + resource.TestCheckResourceAttr(resUserName, "name", userName), + resource.TestCheckResourceAttrSet(resUserName, "id"), + ), + }, + }, + }) +} + +func TestAccInstanceWithDatabases(t *testing.T) { + data := getExample() dbName := "testDb" userName := "testUser" data.Users = []User{ { Name: userName, ProjectId: os.Getenv("TF_ACC_PROJECT_ID"), - Roles: []string{ - "##STACKIT_DatabaseManager##", - "##STACKIT_LoginManager##", - "##STACKIT_ProcessManager##", - "##STACKIT_SQLAgentManager##", - "##STACKIT_SQLAgentUser##", - "##STACKIT_ServerManager##", - }, + Roles: []string{"##STACKIT_LoginManager##", "##STACKIT_DatabaseManager##"}, }, } data.Databases = []Database{ @@ -255,12 +232,23 @@ func TestAccInstanceNoEncryption(t *testing.T) { }, } - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - t.Logf(" ... working on instance %s", data.TfName) - testInstances = append(testInstances, data.TfName) - }, + resName := fmt.Sprintf( + "stackitprivatepreview_sqlserverflexalpha_instance.%s", + data.TfName, + ) + + resUserName := fmt.Sprintf( + "stackitprivatepreview_sqlserverflexalpha_user.%s", + userName, + ) + + resDbName := fmt.Sprintf( + "stackitprivatepreview_sqlserverflexalpha_database.%s", + dbName, + ) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ // Create and verify @@ -270,162 +258,13 @@ func TestAccInstanceNoEncryption(t *testing.T) { data, ), Check: resource.ComposeAggregateTestCheckFunc( - // check instance values are set - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "id"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "backup_schedule"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "edition"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "flavor_id"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "instance_id"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "is_deletable"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "name"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "replicas"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "retention_days"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "status"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "version"), - - resource.TestCheckNoResourceAttr(resName("instance", data.TfName), "encryption"), - - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_id"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_version"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_ring_id"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.service_account"), - - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.access_scope"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.acl"), - - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.instance_address"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.router_address"), - - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.class"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.size"), - - // check instance values are correct - resource.TestCheckResourceAttr(resName("instance", data.TfName), "name", data.Name), - - // check user values are set - resource.TestCheckResourceAttrSet(resName("user", userName), "id"), - resource.TestCheckResourceAttrSet(resName("user", userName), "username"), - // resource.TestCheckResourceAttrSet(resName("user", userName), "roles"), - - // func(s *terraform.State) error { - // return nil - // }, - - // check user values are correct - resource.TestCheckResourceAttr(resName("user", userName), "username", userName), - resource.TestCheckResourceAttr(resName("user", userName), "roles.#", strconv.Itoa(len(data.Users[0].Roles))), - - // check database values are set - resource.TestCheckResourceAttrSet(resName("database", dbName), "id"), - resource.TestCheckResourceAttrSet(resName("database", dbName), "name"), - resource.TestCheckResourceAttrSet(resName("database", dbName), "owner"), - resource.TestCheckResourceAttrSet(resName("database", dbName), "compatibility"), - resource.TestCheckResourceAttrSet(resName("database", dbName), "collation"), - - // check database values are correct - resource.TestCheckResourceAttr(resName("database", dbName), "name", dbName), - resource.TestCheckResourceAttr(resName("database", dbName), "owner", userName), - ), - }, - }, - }) -} - -func TestAccInstanceEncryption(t *testing.T) { - data := getExample() - - dbName := "testDb" - userName := "testUser" - data.Users = []User{ - { - Name: userName, - ProjectId: os.Getenv("TF_ACC_PROJECT_ID"), - Roles: []string{"##STACKIT_DatabaseManager##", "##STACKIT_LoginManager##"}, - }, - } - data.Databases = []Database{ - { - Name: dbName, - ProjectId: os.Getenv("TF_ACC_PROJECT_ID"), - Owner: userName, - }, - } - - data.UseEncryption = true - data.KekKeyId = "fe039bcf-8d7b-431a-801d-9e81371a6b7b" - data.KekKeyRingId = "6a2d95ab-3c4c-4963-a2bb-08d17a320e27" - data.KekKeyVersion = 1 - data.KekServiceAccount = "henselinm-u2v3ex1@sa.stackit.cloud" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - t.Logf(" ... working on instance %s", data.TfName) - testInstances = append(testInstances, data.TfName) - }, - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create and verify - { - Config: testutils.StringFromTemplateMust( - "testdata/instance_template.gompl", - data, - ), - Check: resource.ComposeAggregateTestCheckFunc( - // check instance values are set - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "id"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "backup_schedule"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "edition"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "flavor_id"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "instance_id"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "is_deletable"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "name"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "replicas"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "retention_days"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "status"), - resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "version"), - - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_id"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_version"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_ring_id"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.service_account"), - - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.access_scope"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.acl"), - - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.instance_address"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.router_address"), - - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.class"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.size"), - - // check instance values are correct - resource.TestCheckResourceAttr(resName("instance", data.TfName), "name", data.Name), - - // check user values are set - resource.TestCheckResourceAttrSet(resName("user", userName), "id"), - resource.TestCheckResourceAttrSet(resName("user", userName), "username"), - - // func(s *terraform.State) error { - // return nil - // }, - - // check user values are correct - resource.TestCheckResourceAttr(resName("user", userName), "username", userName), - resource.TestCheckResourceAttr(resName("user", userName), "roles.#", "2"), - - // check database values are set - resource.TestCheckResourceAttrSet(resName("database", dbName), "id"), - resource.TestCheckResourceAttrSet(resName("database", dbName), "name"), - resource.TestCheckResourceAttrSet(resName("database", dbName), "owner"), - resource.TestCheckResourceAttrSet(resName("database", dbName), "compatibility"), - resource.TestCheckResourceAttrSet(resName("database", dbName), "collation"), - - // check database values are correct - resource.TestCheckResourceAttr(resName("database", dbName), "name", dbName), - resource.TestCheckResourceAttr(resName("database", dbName), "owner", userName), + resource.TestCheckResourceAttr(resName, "name", data.Name), + resource.TestCheckResourceAttrSet(resName, "id"), + resource.TestCheckResourceAttr(resUserName, "name", userName), + resource.TestCheckResourceAttrSet(resUserName, "id"), + resource.TestCheckResourceAttr(resDbName, "name", dbName), + resource.TestCheckResourceAttr(resDbName, "owner", userName), + resource.TestCheckResourceAttrSet(resDbName, "id"), ), }, }, diff --git a/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go_old.bak b/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go_old.bak new file mode 100644 index 00000000..5138deee --- /dev/null +++ b/stackit/internal/services/sqlserverflexalpha/sqlserverflex_acc_test.go_old.bak @@ -0,0 +1,483 @@ +// Copyright (c) STACKIT + +package sqlserverflexalpha_test + +import ( + "context" + _ "embed" + "fmt" + "maps" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/config" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + coreconfig "github.com/stackitcloud/stackit-sdk-go/core/config" + "github.com/stackitcloud/stackit-sdk-go/core/utils" + "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex" + "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/wait" + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils" + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" +) + +var ( + //go:embed testdata/resource-max.tf + resourceMaxConfig string + //go:embed testdata/resource-min.tf + resourceMinConfig string +) + +var testConfigVarsMin = config.Variables{ + "project_id": config.StringVariable(testutils.ProjectId), + "name": config.StringVariable(fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlphaNum))), + "flavor_cpu": config.IntegerVariable(4), + "flavor_ram": config.IntegerVariable(16), + "flavor_description": config.StringVariable("SQLServer-Flex-4.16-Standard-EU01"), + "replicas": config.IntegerVariable(1), + "flavor_id": config.StringVariable("4.16-Single"), + "username": config.StringVariable(fmt.Sprintf("tf-acc-user-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlpha))), + "role": config.StringVariable("##STACKIT_LoginManager##"), +} + +var testConfigVarsMax = config.Variables{ + "project_id": config.StringVariable(testutils.ProjectId), + "name": config.StringVariable(fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlphaNum))), + "acl1": config.StringVariable("192.168.0.0/16"), + "flavor_cpu": config.IntegerVariable(4), + "flavor_ram": config.IntegerVariable(16), + "flavor_description": config.StringVariable("SQLServer-Flex-4.16-Standard-EU01"), + "storage_class": config.StringVariable("premium-perf2-stackit"), + "storage_size": config.IntegerVariable(40), + "server_version": config.StringVariable("2022"), + "replicas": config.IntegerVariable(1), + "options_retention_days": config.IntegerVariable(64), + "flavor_id": config.StringVariable("4.16-Single"), + "backup_schedule": config.StringVariable("00 6 * * *"), + "username": config.StringVariable(fmt.Sprintf("tf-acc-user-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlpha))), + "role": config.StringVariable("##STACKIT_LoginManager##"), + "region": config.StringVariable(testutils.Region), +} + +func configVarsMinUpdated() config.Variables { + temp := maps.Clone(testConfigVarsMax) + temp["name"] = config.StringVariable(testutils.ConvertConfigVariable(temp["name"]) + "changed") + return temp +} + +func configVarsMaxUpdated() config.Variables { + temp := maps.Clone(testConfigVarsMax) + temp["backup_schedule"] = config.StringVariable("00 12 * * *") + return temp +} + +func TestAccSQLServerFlexMinResource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + CheckDestroy: testAccChecksqlserverflexDestroy, + Steps: []resource.TestStep{ + // Creation + { + Config: testutils.SQLServerFlexProviderConfig("") + "\n" + resourceMinConfig, + ConfigVariables: testConfigVarsMin, + Check: resource.ComposeAggregateTestCheckFunc( + // Instance + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutils.ConvertConfigVariable(testConfigVarsMin["project_id"])), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutils.ConvertConfigVariable(testConfigVarsMin["name"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.description", testutils.ConvertConfigVariable(testConfigVarsMin["flavor_description"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "replicas", testutils.ConvertConfigVariable(testConfigVarsMin["replicas"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutils.ConvertConfigVariable(testConfigVarsMin["flavor_cpu"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutils.ConvertConfigVariable(testConfigVarsMin["flavor_ram"])), + // User + resource.TestCheckResourceAttrPair( + "stackit_sqlserverflex_user.user", "project_id", + "stackit_sqlserverflex_instance.instance", "project_id", + ), + resource.TestCheckResourceAttrPair( + "stackit_sqlserverflex_user.user", "instance_id", + "stackit_sqlserverflex_instance.instance", "instance_id", + ), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "user_id"), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "password"), + ), + }, + // Update + { + Config: testutils.SQLServerFlexProviderConfig("") + "\n" + resourceMinConfig, + ConfigVariables: testConfigVarsMin, + Check: resource.ComposeAggregateTestCheckFunc( + // Instance + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutils.ConvertConfigVariable(testConfigVarsMin["project_id"])), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutils.ConvertConfigVariable(testConfigVarsMin["name"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.description", testutils.ConvertConfigVariable(testConfigVarsMin["flavor_description"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutils.ConvertConfigVariable(testConfigVarsMin["flavor_cpu"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutils.ConvertConfigVariable(testConfigVarsMin["flavor_ram"])), + // User + resource.TestCheckResourceAttrPair( + "stackit_sqlserverflex_user.user", "project_id", + "stackit_sqlserverflex_instance.instance", "project_id", + ), + resource.TestCheckResourceAttrPair( + "stackit_sqlserverflex_user.user", "instance_id", + "stackit_sqlserverflex_instance.instance", "instance_id", + ), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "user_id"), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "password"), + ), + }, + // data source + { + Config: testutils.SQLServerFlexProviderConfig("") + "\n" + resourceMinConfig, + ConfigVariables: testConfigVarsMin, + Check: resource.ComposeAggregateTestCheckFunc( + // Instance data + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "project_id", testutils.ConvertConfigVariable(testConfigVarsMin["project_id"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "name", testutils.ConvertConfigVariable(testConfigVarsMin["name"])), + resource.TestCheckResourceAttrPair( + "data.stackit_sqlserverflex_instance.instance", "project_id", + "stackit_sqlserverflex_instance.instance", "project_id", + ), + resource.TestCheckResourceAttrPair( + "data.stackit_sqlserverflex_instance.instance", "instance_id", + "stackit_sqlserverflex_instance.instance", "instance_id", + ), + resource.TestCheckResourceAttrPair( + "data.stackit_sqlserverflex_user.user", "instance_id", + "stackit_sqlserverflex_user.user", "instance_id", + ), + + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "acl.#", "1"), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.id", testutils.ConvertConfigVariable(testConfigVarsMin["flavor_id"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.description", testutils.ConvertConfigVariable(testConfigVarsMin["flavor_description"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.cpu", testutils.ConvertConfigVariable(testConfigVarsMin["flavor_cpu"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.ram", testutils.ConvertConfigVariable(testConfigVarsMin["flavor_ram"])), + + // User data + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "project_id", testutils.ConvertConfigVariable(testConfigVarsMin["project_id"])), + resource.TestCheckResourceAttrSet("data.stackit_sqlserverflex_user.user", "user_id"), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "username", testutils.ConvertConfigVariable(testConfigVarsMin["username"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "roles.#", "1"), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "roles.0", testutils.ConvertConfigVariable(testConfigVarsMax["role"])), + ), + }, + // Import + { + ConfigVariables: testConfigVarsMin, + ResourceName: "stackit_sqlserverflex_instance.instance", + ImportStateIdFunc: func(s *terraform.State) (string, error) { + r, ok := s.RootModule().Resources["stackit_sqlserverflex_instance.instance"] + if !ok { + return "", fmt.Errorf("couldn't find resource stackit_sqlserverflex_instance.instance") + } + instanceId, ok := r.Primary.Attributes["instance_id"] + if !ok { + return "", fmt.Errorf("couldn't find attribute instance_id") + } + + return fmt.Sprintf("%s,%s,%s", testutils.ProjectId, testutils.Region, instanceId), nil + }, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"backup_schedule"}, + ImportStateCheck: func(s []*terraform.InstanceState) error { + if len(s) != 1 { + return fmt.Errorf("expected 1 state, got %d", len(s)) + } + return nil + }, + }, + { + ResourceName: "stackit_sqlserverflex_user.user", + ConfigVariables: testConfigVarsMin, + ImportStateIdFunc: func(s *terraform.State) (string, error) { + r, ok := s.RootModule().Resources["stackit_sqlserverflex_user.user"] + if !ok { + return "", fmt.Errorf("couldn't find resource stackit_sqlserverflex_user.user") + } + instanceId, ok := r.Primary.Attributes["instance_id"] + if !ok { + return "", fmt.Errorf("couldn't find attribute instance_id") + } + userId, ok := r.Primary.Attributes["user_id"] + if !ok { + return "", fmt.Errorf("couldn't find attribute user_id") + } + + return fmt.Sprintf("%s,%s,%s,%s", testutils.ProjectId, testutils.Region, instanceId, userId), nil + }, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"password"}, + }, + // Update + { + Config: testutils.SQLServerFlexProviderConfig("") + "\n" + resourceMinConfig, + ConfigVariables: configVarsMinUpdated(), + Check: resource.ComposeAggregateTestCheckFunc( + // Instance data + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutils.ConvertConfigVariable(configVarsMinUpdated()["project_id"])), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutils.ConvertConfigVariable(configVarsMinUpdated()["name"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.description"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutils.ConvertConfigVariable(configVarsMinUpdated()["flavor_cpu"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutils.ConvertConfigVariable(configVarsMinUpdated()["flavor_ram"])), + ), + }, + // Deletion is done by the framework implicitly + }, + }) +} + +func TestAccSQLServerFlexMaxResource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + CheckDestroy: testAccChecksqlserverflexDestroy, + Steps: []resource.TestStep{ + // Creation + { + Config: testutils.SQLServerFlexProviderConfig("") + "\n" + resourceMaxConfig, + ConfigVariables: testConfigVarsMax, + Check: resource.ComposeAggregateTestCheckFunc( + // Instance + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutils.ConvertConfigVariable(testConfigVarsMax["project_id"])), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutils.ConvertConfigVariable(testConfigVarsMax["name"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.0", testutils.ConvertConfigVariable(testConfigVarsMax["acl1"])), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.description", testutils.ConvertConfigVariable(testConfigVarsMax["flavor_description"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "replicas", testutils.ConvertConfigVariable(testConfigVarsMax["replicas"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutils.ConvertConfigVariable(testConfigVarsMax["flavor_cpu"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutils.ConvertConfigVariable(testConfigVarsMax["flavor_ram"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.class", testutils.ConvertConfigVariable(testConfigVarsMax["storage_class"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.size", testutils.ConvertConfigVariable(testConfigVarsMax["storage_size"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "version", testutils.ConvertConfigVariable(testConfigVarsMax["server_version"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "options.retention_days", testutils.ConvertConfigVariable(testConfigVarsMax["options_retention_days"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "backup_schedule", testutils.ConvertConfigVariable(testConfigVarsMax["backup_schedule"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "region", testutils.Region), + // User + resource.TestCheckResourceAttrPair( + "stackit_sqlserverflex_user.user", "project_id", + "stackit_sqlserverflex_instance.instance", "project_id", + ), + resource.TestCheckResourceAttrPair( + "stackit_sqlserverflex_user.user", "instance_id", + "stackit_sqlserverflex_instance.instance", "instance_id", + ), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "user_id"), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "password"), + ), + }, + // Update + { + Config: testutils.SQLServerFlexProviderConfig("") + "\n" + resourceMaxConfig, + ConfigVariables: testConfigVarsMax, + Check: resource.ComposeAggregateTestCheckFunc( + // Instance + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutils.ConvertConfigVariable(testConfigVarsMax["project_id"])), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutils.ConvertConfigVariable(testConfigVarsMax["name"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.0", testutils.ConvertConfigVariable(testConfigVarsMax["acl1"])), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.description", testutils.ConvertConfigVariable(testConfigVarsMax["flavor_description"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "replicas", testutils.ConvertConfigVariable(testConfigVarsMax["replicas"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutils.ConvertConfigVariable(testConfigVarsMax["flavor_cpu"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutils.ConvertConfigVariable(testConfigVarsMax["flavor_ram"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.class", testutils.ConvertConfigVariable(testConfigVarsMax["storage_class"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.size", testutils.ConvertConfigVariable(testConfigVarsMax["storage_size"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "version", testutils.ConvertConfigVariable(testConfigVarsMax["server_version"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "options.retention_days", testutils.ConvertConfigVariable(testConfigVarsMax["options_retention_days"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "backup_schedule", testutils.ConvertConfigVariable(testConfigVarsMax["backup_schedule"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "region", testutils.Region), + // User + resource.TestCheckResourceAttrPair( + "stackit_sqlserverflex_user.user", "project_id", + "stackit_sqlserverflex_instance.instance", "project_id", + ), + resource.TestCheckResourceAttrPair( + "stackit_sqlserverflex_user.user", "instance_id", + "stackit_sqlserverflex_instance.instance", "instance_id", + ), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "user_id"), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_user.user", "password"), + ), + }, + // data source + { + Config: testutils.SQLServerFlexProviderConfig("") + "\n" + resourceMaxConfig, + ConfigVariables: testConfigVarsMax, + Check: resource.ComposeAggregateTestCheckFunc( + // Instance data + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "project_id", testutils.ConvertConfigVariable(testConfigVarsMax["project_id"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "name", testutils.ConvertConfigVariable(testConfigVarsMax["name"])), + resource.TestCheckResourceAttrPair( + "data.stackit_sqlserverflex_instance.instance", "project_id", + "stackit_sqlserverflex_instance.instance", "project_id", + ), + resource.TestCheckResourceAttrPair( + "data.stackit_sqlserverflex_instance.instance", "instance_id", + "stackit_sqlserverflex_instance.instance", "instance_id", + ), + resource.TestCheckResourceAttrPair( + "data.stackit_sqlserverflex_user.user", "instance_id", + "stackit_sqlserverflex_user.user", "instance_id", + ), + + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "acl.#", "1"), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "acl.0", testutils.ConvertConfigVariable(testConfigVarsMax["acl1"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.id", testutils.ConvertConfigVariable(testConfigVarsMax["flavor_id"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.description", testutils.ConvertConfigVariable(testConfigVarsMax["flavor_description"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.cpu", testutils.ConvertConfigVariable(testConfigVarsMax["flavor_cpu"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "flavor.ram", testutils.ConvertConfigVariable(testConfigVarsMax["flavor_ram"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "replicas", testutils.ConvertConfigVariable(testConfigVarsMax["replicas"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "options.retention_days", testutils.ConvertConfigVariable(testConfigVarsMax["options_retention_days"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_instance.instance", "backup_schedule", testutils.ConvertConfigVariable(testConfigVarsMax["backup_schedule"])), + + // User data + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "project_id", testutils.ConvertConfigVariable(testConfigVarsMax["project_id"])), + resource.TestCheckResourceAttrSet("data.stackit_sqlserverflex_user.user", "user_id"), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "username", testutils.ConvertConfigVariable(testConfigVarsMax["username"])), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "roles.#", "1"), + resource.TestCheckResourceAttr("data.stackit_sqlserverflex_user.user", "roles.0", testutils.ConvertConfigVariable(testConfigVarsMax["role"])), + resource.TestCheckResourceAttrSet("data.stackit_sqlserverflex_user.user", "host"), + resource.TestCheckResourceAttrSet("data.stackit_sqlserverflex_user.user", "port"), + ), + }, + // Import + { + ConfigVariables: testConfigVarsMax, + ResourceName: "stackit_sqlserverflex_instance.instance", + ImportStateIdFunc: func(s *terraform.State) (string, error) { + r, ok := s.RootModule().Resources["stackit_sqlserverflex_instance.instance"] + if !ok { + return "", fmt.Errorf("couldn't find resource stackit_sqlserverflex_instance.instance") + } + instanceId, ok := r.Primary.Attributes["instance_id"] + if !ok { + return "", fmt.Errorf("couldn't find attribute instance_id") + } + + return fmt.Sprintf("%s,%s,%s", testutils.ProjectId, testutils.Region, instanceId), nil + }, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"backup_schedule"}, + ImportStateCheck: func(s []*terraform.InstanceState) error { + if len(s) != 1 { + return fmt.Errorf("expected 1 state, got %d", len(s)) + } + if s[0].Attributes["backup_schedule"] != testutils.ConvertConfigVariable(testConfigVarsMax["backup_schedule"]) { + return fmt.Errorf("expected backup_schedule %s, got %s", testConfigVarsMax["backup_schedule"], s[0].Attributes["backup_schedule"]) + } + return nil + }, + }, + { + ResourceName: "stackit_sqlserverflex_user.user", + ConfigVariables: testConfigVarsMax, + ImportStateIdFunc: func(s *terraform.State) (string, error) { + r, ok := s.RootModule().Resources["stackit_sqlserverflex_user.user"] + if !ok { + return "", fmt.Errorf("couldn't find resource stackit_sqlserverflex_user.user") + } + instanceId, ok := r.Primary.Attributes["instance_id"] + if !ok { + return "", fmt.Errorf("couldn't find attribute instance_id") + } + userId, ok := r.Primary.Attributes["user_id"] + if !ok { + return "", fmt.Errorf("couldn't find attribute user_id") + } + + return fmt.Sprintf("%s,%s,%s,%s", testutils.ProjectId, testutils.Region, instanceId, userId), nil + }, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"password"}, + }, + // Update + { + Config: testutils.SQLServerFlexProviderConfig("") + "\n" + resourceMaxConfig, + ConfigVariables: configVarsMaxUpdated(), + Check: resource.ComposeAggregateTestCheckFunc( + // Instance data + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "project_id", testutils.ConvertConfigVariable(configVarsMaxUpdated()["project_id"])), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "instance_id"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "name", testutils.ConvertConfigVariable(configVarsMaxUpdated()["name"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.#", "1"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "acl.0", testutils.ConvertConfigVariable(configVarsMaxUpdated()["acl1"])), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.id"), + resource.TestCheckResourceAttrSet("stackit_sqlserverflex_instance.instance", "flavor.description"), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.cpu", testutils.ConvertConfigVariable(configVarsMaxUpdated()["flavor_cpu"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "flavor.ram", testutils.ConvertConfigVariable(configVarsMaxUpdated()["flavor_ram"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "replicas", testutils.ConvertConfigVariable(configVarsMaxUpdated()["replicas"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.class", testutils.ConvertConfigVariable(configVarsMaxUpdated()["storage_class"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "storage.size", testutils.ConvertConfigVariable(configVarsMaxUpdated()["storage_size"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "version", testutils.ConvertConfigVariable(configVarsMaxUpdated()["server_version"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "options.retention_days", testutils.ConvertConfigVariable(configVarsMaxUpdated()["options_retention_days"])), + resource.TestCheckResourceAttr("stackit_sqlserverflex_instance.instance", "backup_schedule", testutils.ConvertConfigVariable(configVarsMaxUpdated()["backup_schedule"])), + ), + }, + // Deletion is done by the framework implicitly + }, + }) +} + +func testAccChecksqlserverflexDestroy(s *terraform.State) error { + ctx := context.Background() + var client *sqlserverflex.APIClient + var err error + if testutils.SQLServerFlexCustomEndpoint == "" { + client, err = sqlserverflex.NewAPIClient() + } else { + client, err = sqlserverflex.NewAPIClient( + coreconfig.WithEndpoint(testutils.SQLServerFlexCustomEndpoint), + ) + } + if err != nil { + return fmt.Errorf("creating client: %w", err) + } + + instancesToDestroy := []string{} + for _, rs := range s.RootModule().Resources { + if rs.Type != "stackit_sqlserverflex_instance" { + continue + } + // instance terraform ID: = "[project_id],[region],[instance_id]" + instanceId := strings.Split(rs.Primary.ID, core.Separator)[2] + instancesToDestroy = append(instancesToDestroy, instanceId) + } + + instancesResp, err := client.ListInstances(ctx, testutils.ProjectId, testutils.Region).Execute() + if err != nil { + return fmt.Errorf("getting instancesResp: %w", err) + } + + items := *instancesResp.Items + for i := range items { + if items[i].Id == nil { + continue + } + if utils.Contains(instancesToDestroy, *items[i].Id) { + err := client.DeleteInstanceExecute(ctx, testutils.ProjectId, *items[i].Id, testutils.Region) + if err != nil { + return fmt.Errorf("destroying instance %s during CheckDestroy: %w", *items[i].Id, err) + } + _, err = wait.DeleteInstanceWaitHandler(ctx, client, testutils.ProjectId, *items[i].Id, testutils.Region).WaitWithContext(ctx) + if err != nil { + return fmt.Errorf("destroying instance %s during CheckDestroy: waiting for deletion %w", *items[i].Id, err) + } + } + } + return nil +} diff --git a/stackit/internal/services/sqlserverflexalpha/testdata/instance_template.gompl b/stackit/internal/services/sqlserverflexalpha/testdata/instance_template.gompl index 0bf11c9c..035a4344 100644 --- a/stackit/internal/services/sqlserverflexalpha/testdata/instance_template.gompl +++ b/stackit/internal/services/sqlserverflexalpha/testdata/instance_template.gompl @@ -15,8 +15,8 @@ resource "stackitprivatepreview_sqlserverflexalpha_instance" "{{ .TfName }}" { } {{ if .UseEncryption }} encryption = { - kek_key_id = "{{ .KekKeyId }}" - kek_key_ring_id = "{{ .KekKeyRingId }}" + kek_key_id = {{ .KekKeyId }} + kek_key_ring_id = {{ .KekKeyRingId }} kek_key_version = {{ .KekKeyVersion }} service_account = "{{ .KekServiceAccount }}" } @@ -44,17 +44,10 @@ resource "stackitprivatepreview_sqlserverflexalpha_user" "{{ $user.Name }}" { {{ $tfName := .TfName }} {{ range $db := .Databases }} resource "stackitprivatepreview_sqlserverflexalpha_database" "{{ $db.Name }}" { - depends_on = [stackitprivatepreview_sqlserverflexalpha_user.{{ $db.Owner }}] - project_id = "{{ $db.ProjectId }}" - instance_id = stackitprivatepreview_sqlserverflexalpha_instance.{{ $tfName }}.instance_id - name = "{{ $db.Name }}" - owner = "{{ $db.Owner }}" -{{ if $db.Collation }} - collation = "{{ $db.Collation }}" -{{ end }} -{{ if $db.Compatibility }} - compatibility = "{{ $db.Compatibility }}" -{{ end }} + project_id = "{{ $db.ProjectId }}" + instance_id = stackitprivatepreview_sqlserverflexalpha_instance.{{ $tfName }}.instance_id + name = "{{ $db.Name }}" + owner = "{{ $db.Owner }}" } {{ end }} {{ end }} diff --git a/stackit/internal/services/sqlserverflexalpha/user/datasource.go b/stackit/internal/services/sqlserverflexalpha/user/datasource.go index e191e5a7..d76e27a4 100644 --- a/stackit/internal/services/sqlserverflexalpha/user/datasource.go +++ b/stackit/internal/services/sqlserverflexalpha/user/datasource.go @@ -5,45 +5,53 @@ import ( "fmt" "net/http" + "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" sqlserverflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" - - sqlserverflexalphaPkg "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" - sqlserverflexalphaGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user/datasources_gen" + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/validate" ) -var _ datasource.DataSource = (*userDataSource)(nil) +// Ensure the implementation satisfies the expected interfaces. +var ( + _ datasource.DataSource = &userDataSource{} +) +// NewUserDataSource is a helper function to simplify the provider implementation. func NewUserDataSource() datasource.DataSource { return &userDataSource{} } type dataSourceModel struct { - DefaultDatabase types.String `tfsdk:"default_database"` - Host types.String `tfsdk:"host"` - Id types.String `tfsdk:"id"` - InstanceId types.String `tfsdk:"instance_id"` - Port types.Int64 `tfsdk:"port"` - ProjectId types.String `tfsdk:"project_id"` - Region types.String `tfsdk:"region"` - Roles types.List `tfsdk:"roles"` - Status types.String `tfsdk:"status"` + //TODO: check generated data source for the correct types and pointers + Id types.String `tfsdk:"id"` // needed by TF UserId types.Int64 `tfsdk:"user_id"` + InstanceId types.String `tfsdk:"instance_id"` + ProjectId types.String `tfsdk:"project_id"` Username types.String `tfsdk:"username"` + Roles types.Set `tfsdk:"roles"` + Host types.String `tfsdk:"host"` + Port types.Int64 `tfsdk:"port"` + Region types.String `tfsdk:"region"` + Status types.String `tfsdk:"status"` + DefaultDatabase types.String `tfsdk:"default_database"` } +// userDataSource is the data source implementation. type userDataSource struct { - client *sqlserverflexalphaPkg.APIClient + client *sqlserverflexalpha.APIClient providerData core.ProviderData } -func (d *userDataSource) Metadata( +// Metadata returns the data source type name. +func (r *userDataSource) Metadata( _ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse, @@ -51,31 +59,108 @@ func (d *userDataSource) Metadata( resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_user" } -func (d *userDataSource) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = sqlserverflexalphaGen.UserDataSourceSchema(ctx) -} - // Configure adds the provider configured client to the data source. -func (d *userDataSource) Configure( +func (r *userDataSource) Configure( ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse, ) { var ok bool - d.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics) + r.providerData, ok = conversion.ParseProviderData(ctx, req.ProviderData, &resp.Diagnostics) if !ok { return } - apiClient := sqlserverflexUtils.ConfigureClient(ctx, &d.providerData, &resp.Diagnostics) + apiClient := sqlserverflexUtils.ConfigureClient(ctx, &r.providerData, &resp.Diagnostics) if resp.Diagnostics.HasError() { return } - d.client = apiClient - tflog.Info(ctx, "SQL SERVER Flex alpha database client configured") + r.client = apiClient + tflog.Info(ctx, "SQLServer Flex beta user client configured") } -func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { +// Schema defines the schema for the data source. +func (r *userDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + descriptions := map[string]string{ + "main": "SQLServer Flex user data source schema. Must have a `region` specified in the provider configuration.", + "id": "Terraform's internal data source. ID. It is structured as \"`project_id`,`region`,`instance_id`,`user_id`\".", + "user_id": "User ID.", + "instance_id": "ID of the SQLServer Flex instance.", + "project_id": "STACKIT project ID to which the instance is associated.", + "username": "Username of the SQLServer Flex instance.", + "roles": "Database access levels for the user.", + "password": "Password of the user account.", + "region": "The resource region. If not defined, the provider region is used.", + "status": "Status of the user.", + "default_database": "Default database of the user.", + } + + resp.Schema = schema.Schema{ + Description: descriptions["main"], + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Description: descriptions["id"], + Computed: true, + }, + "user_id": schema.Int64Attribute{ + Description: descriptions["user_id"], + Required: true, + Validators: []validator.Int64{ + int64validator.AtLeast(1), + }, + }, + "instance_id": schema.StringAttribute{ + Description: descriptions["instance_id"], + Required: true, + Validators: []validator.String{ + validate.UUID(), + validate.NoSeparator(), + }, + }, + "project_id": schema.StringAttribute{ + Description: descriptions["project_id"], + Required: true, + Validators: []validator.String{ + validate.UUID(), + validate.NoSeparator(), + }, + }, + "username": schema.StringAttribute{ + Description: descriptions["username"], + Computed: true, + }, + "roles": schema.SetAttribute{ + Description: descriptions["roles"], + ElementType: types.StringType, + Computed: true, + }, + "host": schema.StringAttribute{ + Computed: true, + }, + "port": schema.Int64Attribute{ + Computed: true, + }, + "region": schema.StringAttribute{ + // the region cannot be found automatically, so it has to be passed + Optional: true, + Description: descriptions["region"], + }, + "status": schema.StringAttribute{ + Computed: true, + }, + "default_database": schema.StringAttribute{ + Computed: true, + }, + }, + } +} + +// Read refreshes the Terraform state with the latest data. +func (r *userDataSource) Read( + ctx context.Context, + req datasource.ReadRequest, + resp *datasource.ReadResponse, +) { // nolint:gocritic // function signature required by Terraform var model dataSourceModel diags := req.Config.Get(ctx, &model) resp.Diagnostics.Append(diags...) @@ -88,13 +173,13 @@ func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r projectId := model.ProjectId.ValueString() instanceId := model.InstanceId.ValueString() userId := model.UserId.ValueInt64() - region := d.providerData.GetRegionWithOverride(model.Region) + region := r.providerData.GetRegionWithOverride(model.Region) ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "instance_id", instanceId) ctx = tflog.SetField(ctx, "user_id", userId) ctx = tflog.SetField(ctx, "region", region) - recordSetResp, err := d.client.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute() + recordSetResp, err := r.client.GetUserRequest(ctx, projectId, region, instanceId, userId).Execute() if err != nil { utils.LogError( ctx, @@ -135,5 +220,5 @@ func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r if resp.Diagnostics.HasError() { return } - tflog.Info(ctx, "SQLServer Flex beta instance read") + tflog.Info(ctx, "SQLServer Flex alpha instance read") } diff --git a/stackit/internal/services/sqlserverflexalpha/user/mapper.go b/stackit/internal/services/sqlserverflexalpha/user/mapper.go index 8e522d59..0b7baa84 100644 --- a/stackit/internal/services/sqlserverflexalpha/user/mapper.go +++ b/stackit/internal/services/sqlserverflexalpha/user/mapper.go @@ -2,12 +2,10 @@ package sqlserverflexalpha import ( "fmt" - "slices" "strconv" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" @@ -43,20 +41,17 @@ func mapDataSourceFields(userResp *sqlserverflexalpha.GetUserResponse, model *da // Map roles if user.Roles == nil { - model.Roles = types.List(types.SetNull(types.StringType)) + model.Roles = types.SetNull(types.StringType) } else { - resRoles := *user.Roles - slices.Sort(resRoles) - var roles []attr.Value - for _, role := range resRoles { + for _, role := range *user.Roles { roles = append(roles, types.StringValue(string(role))) } rolesSet, diags := types.SetValue(types.StringType, roles) if diags.HasError() { return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags)) } - model.Roles = types.List(rolesSet) + model.Roles = rolesSet } // Set remaining attributes @@ -96,11 +91,8 @@ func mapFields(userResp *sqlserverflexalpha.GetUserResponse, model *resourceMode // Map roles if user.Roles != nil { - resRoles := *user.Roles - slices.Sort(resRoles) - var roles []attr.Value - for _, role := range resRoles { + for _, role := range *user.Roles { roles = append(roles, types.StringValue(string(role))) } rolesSet, diags := types.SetValue(types.StringType, roles) @@ -146,12 +138,9 @@ func mapFieldsCreate(userResp *sqlserverflexalpha.CreateUserResponse, model *res model.Password = types.StringValue(*user.Password) if user.Roles != nil { - resRoles := *user.Roles - slices.Sort(resRoles) - var roles []attr.Value - for _, role := range resRoles { - roles = append(roles, types.StringValue(string(role))) + for _, role := range *user.Roles { + roles = append(roles, types.StringValue(role)) } rolesSet, diags := types.SetValue(types.StringType, roles) if diags.HasError() { @@ -164,9 +153,6 @@ func mapFieldsCreate(userResp *sqlserverflexalpha.CreateUserResponse, model *res model.Roles = types.List(types.SetNull(types.StringType)) } - model.Password = types.StringPointerValue(user.Password) - model.Uri = types.StringPointerValue(user.Uri) - model.Host = types.StringPointerValue(user.Host) model.Port = types.Int64PointerValue(user.Port) model.Region = types.StringValue(region) diff --git a/stackit/internal/services/sqlserverflexalpha/user/mapper_test.go b/stackit/internal/services/sqlserverflexalpha/user/mapper_test.go index 4dbe7d03..e450b581 100644 --- a/stackit/internal/services/sqlserverflexalpha/user/mapper_test.go +++ b/stackit/internal/services/sqlserverflexalpha/user/mapper_test.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/utils" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" ) @@ -30,7 +29,7 @@ func TestMapDataSourceFields(t *testing.T) { InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), Username: types.StringNull(), - Roles: types.List(types.SetNull(types.StringType)), + Roles: types.SetNull(types.StringType), Host: types.StringNull(), Port: types.Int64Null(), Region: types.StringValue(testRegion), @@ -42,13 +41,11 @@ func TestMapDataSourceFields(t *testing.T) { { "simple_values", &sqlserverflexalpha.GetUserResponse{ + Roles: &[]string{ - "##STACKIT_SQLAgentUser##", - "##STACKIT_DatabaseManager##", - "##STACKIT_LoginManager##", - "##STACKIT_SQLAgentManager##", - "##STACKIT_ProcessManager##", - "##STACKIT_ServerManager##", + "role_1", + "role_2", + "", }, Username: utils.Ptr("username"), Host: utils.Ptr("host"), @@ -63,17 +60,12 @@ func TestMapDataSourceFields(t *testing.T) { InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), Username: types.StringValue("username"), - Roles: types.List( - types.SetValueMust( - types.StringType, []attr.Value{ - types.StringValue("##STACKIT_DatabaseManager##"), - types.StringValue("##STACKIT_LoginManager##"), - types.StringValue("##STACKIT_ProcessManager##"), - types.StringValue("##STACKIT_SQLAgentManager##"), - types.StringValue("##STACKIT_SQLAgentUser##"), - types.StringValue("##STACKIT_ServerManager##"), - }, - ), + Roles: types.SetValueMust( + types.StringType, []attr.Value{ + types.StringValue("role_1"), + types.StringValue("role_2"), + types.StringValue(""), + }, ), Host: types.StringValue("host"), Port: types.Int64Value(1234), @@ -99,7 +91,7 @@ func TestMapDataSourceFields(t *testing.T) { InstanceId: types.StringValue("iid"), ProjectId: types.StringValue("pid"), Username: types.StringNull(), - Roles: types.List(types.SetValueMust(types.StringType, []attr.Value{})), + Roles: types.SetValueMust(types.StringType, []attr.Value{}), Host: types.StringNull(), Port: types.Int64Value(2123456789), Region: types.StringValue(testRegion), @@ -144,7 +136,7 @@ func TestMapDataSourceFields(t *testing.T) { t.Fatalf("Should not have failed: %v", err) } if tt.isValid { - diff := cmp.Diff(&tt.expected, state) + diff := cmp.Diff(state, &tt.expected) if diff != "" { t.Fatalf("Data does not match: %s", diff) } @@ -189,8 +181,8 @@ func TestMapFieldsCreate(t *testing.T) { &sqlserverflexalpha.CreateUserResponse{ Id: utils.Ptr(int64(2)), Roles: &[]string{ - "role_2", "role_1", + "role_2", "", }, Username: utils.Ptr("username"), @@ -210,9 +202,9 @@ func TestMapFieldsCreate(t *testing.T) { Roles: types.List( types.SetValueMust( types.StringType, []attr.Value{ - types.StringValue(""), types.StringValue("role_1"), types.StringValue("role_2"), + types.StringValue(""), }, ), ), @@ -298,7 +290,7 @@ func TestMapFieldsCreate(t *testing.T) { t.Fatalf("Should not have failed: %v", err) } if tt.isValid { - diff := cmp.Diff(&tt.expected, state) + diff := cmp.Diff(state, &tt.expected) if diff != "" { t.Fatalf("Data does not match: %s", diff) } @@ -338,8 +330,8 @@ func TestMapFields(t *testing.T) { "simple_values", &sqlserverflexalpha.GetUserResponse{ Roles: &[]string{ - "role_2", "role_1", + "role_2", "", }, Username: utils.Ptr("username"), @@ -356,9 +348,9 @@ func TestMapFields(t *testing.T) { Roles: types.List( types.SetValueMust( types.StringType, []attr.Value{ - types.StringValue(""), types.StringValue("role_1"), types.StringValue("role_2"), + types.StringValue(""), }, ), ), @@ -429,7 +421,7 @@ func TestMapFields(t *testing.T) { t.Fatalf("Should not have failed: %v", err) } if tt.isValid { - diff := cmp.Diff(&tt.expected, state) + diff := cmp.Diff(state, &tt.expected) if diff != "" { t.Fatalf("Data does not match: %s", diff) } @@ -522,7 +514,7 @@ func TestToCreatePayload(t *testing.T) { t.Fatalf("Should not have failed: %v", err) } if tt.isValid { - diff := cmp.Diff(tt.expected, output) + diff := cmp.Diff(output, tt.expected) if diff != "" { t.Fatalf("Data does not match: %s", diff) } diff --git a/stackit/internal/services/sqlserverflexalpha/user/planModifiers.yaml b/stackit/internal/services/sqlserverflexalpha/user/planModifiers.yaml index 8ff346ab..b01aae98 100644 --- a/stackit/internal/services/sqlserverflexalpha/user/planModifiers.yaml +++ b/stackit/internal/services/sqlserverflexalpha/user/planModifiers.yaml @@ -3,12 +3,15 @@ fields: modifiers: - 'UseStateForUnknown' + - name: 'user_id' + modifiers: + - 'UseStateForUnknown' + - name: 'instance_id' validators: - validate.NoSeparator - validate.UUID modifiers: - - 'UseStateForUnknown' - 'RequiresReplace' - name: 'project_id' @@ -16,27 +19,33 @@ fields: - validate.NoSeparator - validate.UUID modifiers: - - 'UseStateForUnknown' - 'RequiresReplace' + - name: 'username' + modifiers: + - 'RequiresReplace' + + - name: 'roles' + modifiers: + - 'RequiresReplace' + + - name: 'password' + modifiers: + - 'UseStateForUnknown' + + - name: 'host' + modifiers: + - 'UseStateForUnknown' + + - name: 'port' + modifiers: + - 'UseStateForUnknown' + - name: 'region' modifiers: - 'RequiresReplace' - - name: 'user_id' - modifiers: - - 'UseStateForUnknown' - - 'RequiresReplace' - - - name: 'username' - modifiers: - - 'UseStateForUnknown' - - - name: 'roles' - modifiers: - - 'UseStateForUnknown' - - - name: 'password' + - name: 'status' modifiers: - 'UseStateForUnknown' @@ -44,6 +53,6 @@ fields: modifiers: - 'UseStateForUnknown' - - name: 'status' + - name: 'default_database' modifiers: - 'UseStateForUnknown' diff --git a/stackit/internal/services/sqlserverflexalpha/user/resource.go b/stackit/internal/services/sqlserverflexalpha/user/resource.go index ee322fab..52dee432 100644 --- a/stackit/internal/services/sqlserverflexalpha/user/resource.go +++ b/stackit/internal/services/sqlserverflexalpha/user/resource.go @@ -6,44 +6,41 @@ import ( "errors" "fmt" "net/http" - "slices" "strconv" "strings" - "time" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/identityschema" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" + sqlserverflexalphagen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user/resources_gen" sqlserverflexalphaUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils" sqlserverflexalphaWait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexalpha" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/stackitcloud/stackit-sdk-go/core/oapierror" + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" - - sqlserverflexalphaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user/resources_gen" ) +// Ensure the implementation satisfies the expected interfaces. var ( - _ resource.Resource = &userResource{} - _ resource.ResourceWithConfigure = &userResource{} - _ resource.ResourceWithImportState = &userResource{} - _ resource.ResourceWithModifyPlan = &userResource{} - _ resource.ResourceWithIdentity = &userResource{} - _ resource.ResourceWithValidateConfig = &userResource{} + _ resource.Resource = &userResource{} + _ resource.ResourceWithConfigure = &userResource{} + _ resource.ResourceWithImportState = &userResource{} + _ resource.ResourceWithModifyPlan = &userResource{} + _ resource.ResourceWithIdentity = &userResource{} ) +// NewUserResource is a helper function to simplify the provider implementation. func NewUserResource() resource.Resource { return &userResource{} } // resourceModel describes the resource data model. -type resourceModel = sqlserverflexalphaResGen.UserModel +type resourceModel = sqlserverflexalphagen.UserModel // UserResourceIdentityModel describes the resource's identity attributes. type UserResourceIdentityModel struct { @@ -53,11 +50,13 @@ type UserResourceIdentityModel struct { UserID types.Int64 `tfsdk:"user_id"` } +// userResource is the resource implementation. type userResource struct { client *sqlserverflexalpha.APIClient providerData core.ProviderData } +// Metadata returns the resource type name. func (r *userResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_sqlserverflexalpha_user" } @@ -75,7 +74,7 @@ func (r *userResource) Configure(ctx context.Context, req resource.ConfigureRequ return } r.client = apiClient - tflog.Info(ctx, "SQLServer Beta Flex user client configured") + tflog.Info(ctx, "SQLServer Alpha Flex user client configured") } // ModifyPlan implements resource.ResourceWithModifyPlan. @@ -117,7 +116,7 @@ var modifiersFileByte []byte // Schema defines the schema for the resource. func (r *userResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - s := sqlserverflexalphaResGen.UserResourceSchema(ctx) + s := sqlserverflexalphagen.UserResourceSchema(ctx) fields, err := utils.ReadModifiersConfig(modifiersFileByte) if err != nil { @@ -157,39 +156,6 @@ func (r *userResource) IdentitySchema( } } -func (r *userResource) ValidateConfig( - ctx context.Context, - req resource.ValidateConfigRequest, - resp *resource.ValidateConfigResponse, -) { - var data resourceModel - - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - var roles []string - diags := data.Roles.ElementsAs(ctx, &roles, false) - resp.Diagnostics.Append(diags...) - if diags.HasError() { - return - } - - var resRoles []string - for _, role := range roles { - if slices.Contains(resRoles, role) { - resp.Diagnostics.AddAttributeError( - path.Root("roles"), - "Attribute Configuration Error", - "defined roles MUST NOT contain duplicates", - ) - return - } - resRoles = append(resRoles, role) - } -} - // Create creates the resource and sets the initial Terraform state. func (r *userResource) Create( ctx context.Context, @@ -220,8 +186,6 @@ func (r *userResource) Create( if resp.Diagnostics.HasError() { return } - - slices.Sort(roles) } // Generate API request body from model @@ -253,7 +217,6 @@ func (r *userResource) Create( ) return } - userId := *userResp.Id ctx = tflog.SetField(ctx, "user_id", userId) @@ -262,59 +225,15 @@ func (r *userResource) Create( ProjectID: types.StringValue(projectId), Region: types.StringValue(region), InstanceID: types.StringValue(instanceId), - UserID: types.Int64Value(userId), + UserID: types.Int64Value(userResp.GetId()), } resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...) if resp.Diagnostics.HasError() { return } - err = mapFieldsCreate(userResp, &model, region) - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - "Error creating user", - fmt.Sprintf("Processing API payload: %v", err), - ) - return - } - - waitResp, err := sqlserverflexalphaWait.CreateUserWaitHandler( - ctx, - r.client, - projectId, - instanceId, - region, - userId, - ).SetSleepBeforeWait( - 90 * time.Second, - ).SetTimeout( - 90 * time.Minute, - ).WaitWithContext(ctx) - - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - "create user", - fmt.Sprintf("Instance creation waiting: %v", err), - ) - return - } - - if waitResp.Id == nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - "create user", - "Instance creation waiting: returned id is nil", - ) - return - } - // Map response body to schema - err = mapFields(waitResp, &model, region) + err = mapFieldsCreate(userResp, &model, region) if err != nil { core.LogAndAddError( ctx, @@ -375,18 +294,6 @@ func (r *userResource) Read( ctx = core.LogResponse(ctx) - // Map response body to schema - err = mapFields(recordSetResp, &model, region) - if err != nil { - core.LogAndAddError( - ctx, - &resp.Diagnostics, - "Error reading user", - fmt.Sprintf("Processing API payload: %v", err), - ) - return - } - // Set data returned by API in identity identity := UserResourceIdentityModel{ ProjectID: types.StringValue(projectId), @@ -399,6 +306,18 @@ func (r *userResource) Read( return } + // Map response body to schema + err = mapFields(recordSetResp, &model, region) + if err != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error reading user", + fmt.Sprintf("Processing API payload: %v", err), + ) + return + } + // Set refreshed state diags = resp.State.Set(ctx, model) resp.Diagnostics.Append(diags...) @@ -445,37 +364,17 @@ func (r *userResource) Delete( // Delete existing record set // err := r.client.DeleteUserRequest(ctx, projectId, region, instanceId, userId).Execute() - err := r.client.DeleteUserRequestExecute(ctx, projectId, region, instanceId, userId) - if err != nil { - var oapiErr *oapierror.GenericOpenAPIError - ok := errors.As(err, &oapiErr) - if !ok { - // TODO err handling - return - } - switch oapiErr.StatusCode { - case http.StatusNotFound: - resp.State.RemoveResource(ctx) - return - // case http.StatusInternalServerError: - // tflog.Warn(ctx, "[delete user] Wait handler got error 500") - // return false, nil, nil - default: - // TODO err handling - return - } - } // Delete existing record set - _, err = sqlserverflexalphaWait.DeleteUserWaitHandler(ctx, r.client, projectId, region, instanceId, userId). + _, err := sqlserverflexalphaWait.DeleteUserWaitHandler(ctx, r.client, projectId, region, instanceId, userId). WaitWithContext(ctx) + //err := r.client.DeleteUserRequest(ctx, arg.projectId, arg.region, arg.instanceId, userId).Execute() if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "User Delete Error", fmt.Sprintf("Calling API: %v", err)) return } ctx = core.LogResponse(ctx) - resp.State.RemoveResource(ctx) tflog.Info(ctx, "SQLServer Flex user deleted") @@ -488,9 +387,11 @@ func (r *userResource) ImportState( req resource.ImportStateRequest, resp *resource.ImportStateResponse, ) { + ctx = core.InitProviderContext(ctx) if req.ID != "" { + idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" { @@ -521,7 +422,7 @@ func (r *userResource) ImportState( resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), userId)...) - tflog.Info(ctx, "SQLServer Flex user state imported") + tflog.Info(ctx, "Postgres Flex user state imported") return } diff --git a/stackit/internal/services/sqlserverflexalpha/utils/util.go b/stackit/internal/services/sqlserverflexalpha/utils/util.go index 7fbf0901..db031162 100644 --- a/stackit/internal/services/sqlserverflexalpha/utils/util.go +++ b/stackit/internal/services/sqlserverflexalpha/utils/util.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/stackitcloud/stackit-sdk-go/core/config" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" ) diff --git a/stackit/internal/services/sqlserverflexalpha/utils/util_test.go b/stackit/internal/services/sqlserverflexalpha/utils/util_test.go index 91f90030..7afd6b1d 100644 --- a/stackit/internal/services/sqlserverflexalpha/utils/util_test.go +++ b/stackit/internal/services/sqlserverflexalpha/utils/util_test.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients" "github.com/stackitcloud/stackit-sdk-go/core/config" - sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" diff --git a/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/version_data_source_gen.go b/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/version_data_source_gen.go deleted file mode 100644 index cb9008f1..00000000 --- a/stackit/internal/services/sqlserverflexalpha/versions/datasources_gen/version_data_source_gen.go +++ /dev/null @@ -1,569 +0,0 @@ -// Code generated by terraform-plugin-framework-generator DO NOT EDIT. - -package sqlserverflexalpha - -import ( - "context" - "fmt" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/hashicorp/terraform-plugin-go/tftypes" - "strings" - - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" -) - -func VersionDataSourceSchema(ctx context.Context) schema.Schema { - return schema.Schema{ - Attributes: map[string]schema.Attribute{ - "project_id": schema.StringAttribute{ - Required: true, - Description: "The STACKIT project ID.", - MarkdownDescription: "The STACKIT project ID.", - }, - "region": schema.StringAttribute{ - Required: true, - Description: "The region which should be addressed", - MarkdownDescription: "The region which should be addressed", - Validators: []validator.String{ - stringvalidator.OneOf( - "eu01", - ), - }, - }, - "versions": schema.ListNestedAttribute{ - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "beta": schema.BoolAttribute{ - Computed: true, - Description: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.", - MarkdownDescription: "Flag if the version is a beta version. If set the version may contain bugs and is not fully tested.", - }, - "deprecated": schema.StringAttribute{ - Computed: true, - Description: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.", - MarkdownDescription: "Timestamp in RFC3339 format which says when the version will no longer be supported by STACKIT.", - }, - "recommend": schema.BoolAttribute{ - Computed: true, - Description: "Flag if the version is recommend by the STACKIT Team.", - MarkdownDescription: "Flag if the version is recommend by the STACKIT Team.", - }, - "version": schema.StringAttribute{ - Computed: true, - Description: "The sqlserver version used for the instance.", - MarkdownDescription: "The sqlserver version used for the instance.", - }, - }, - CustomType: VersionsType{ - ObjectType: types.ObjectType{ - AttrTypes: VersionsValue{}.AttributeTypes(ctx), - }, - }, - }, - Computed: true, - Description: "A list containing available sqlserver versions.", - MarkdownDescription: "A list containing available sqlserver versions.", - }, - }, - } -} - -type VersionModel struct { - ProjectId types.String `tfsdk:"project_id"` - Region types.String `tfsdk:"region"` - Versions types.List `tfsdk:"versions"` -} - -var _ basetypes.ObjectTypable = VersionsType{} - -type VersionsType struct { - basetypes.ObjectType -} - -func (t VersionsType) Equal(o attr.Type) bool { - other, ok := o.(VersionsType) - - if !ok { - return false - } - - return t.ObjectType.Equal(other.ObjectType) -} - -func (t VersionsType) String() string { - return "VersionsType" -} - -func (t VersionsType) ValueFromObject(ctx context.Context, in basetypes.ObjectValue) (basetypes.ObjectValuable, diag.Diagnostics) { - var diags diag.Diagnostics - - attributes := in.Attributes() - - betaAttribute, ok := attributes["beta"] - - if !ok { - diags.AddError( - "Attribute Missing", - `beta is missing from object`) - - return nil, diags - } - - betaVal, ok := betaAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute)) - } - - deprecatedAttribute, ok := attributes["deprecated"] - - if !ok { - diags.AddError( - "Attribute Missing", - `deprecated is missing from object`) - - return nil, diags - } - - deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute)) - } - - recommendAttribute, ok := attributes["recommend"] - - if !ok { - diags.AddError( - "Attribute Missing", - `recommend is missing from object`) - - return nil, diags - } - - recommendVal, ok := recommendAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute)) - } - - versionAttribute, ok := attributes["version"] - - if !ok { - diags.AddError( - "Attribute Missing", - `version is missing from object`) - - return nil, diags - } - - versionVal, ok := versionAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute)) - } - - if diags.HasError() { - return nil, diags - } - - return VersionsValue{ - Beta: betaVal, - Deprecated: deprecatedVal, - Recommend: recommendVal, - Version: versionVal, - state: attr.ValueStateKnown, - }, diags -} - -func NewVersionsValueNull() VersionsValue { - return VersionsValue{ - state: attr.ValueStateNull, - } -} - -func NewVersionsValueUnknown() VersionsValue { - return VersionsValue{ - state: attr.ValueStateUnknown, - } -} - -func NewVersionsValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (VersionsValue, diag.Diagnostics) { - var diags diag.Diagnostics - - // Reference: https://github.com/hashicorp/terraform-plugin-framework/issues/521 - ctx := context.Background() - - for name, attributeType := range attributeTypes { - attribute, ok := attributes[name] - - if !ok { - diags.AddError( - "Missing VersionsValue Attribute Value", - "While creating a VersionsValue value, a missing attribute value was detected. "+ - "A VersionsValue must contain values for all attributes, even if null or unknown. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s", name, attributeType.String()), - ) - - continue - } - - if !attributeType.Equal(attribute.Type(ctx)) { - diags.AddError( - "Invalid VersionsValue Attribute Type", - "While creating a VersionsValue value, an invalid attribute value was detected. "+ - "A VersionsValue must use a matching attribute type for the value. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("VersionsValue Attribute Name (%s) Expected Type: %s\n", name, attributeType.String())+ - fmt.Sprintf("VersionsValue Attribute Name (%s) Given Type: %s", name, attribute.Type(ctx)), - ) - } - } - - for name := range attributes { - _, ok := attributeTypes[name] - - if !ok { - diags.AddError( - "Extra VersionsValue Attribute Value", - "While creating a VersionsValue value, an extra attribute value was detected. "+ - "A VersionsValue must not contain values beyond the expected attribute types. "+ - "This is always an issue with the provider and should be reported to the provider developers.\n\n"+ - fmt.Sprintf("Extra VersionsValue Attribute Name: %s", name), - ) - } - } - - if diags.HasError() { - return NewVersionsValueUnknown(), diags - } - - betaAttribute, ok := attributes["beta"] - - if !ok { - diags.AddError( - "Attribute Missing", - `beta is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - betaVal, ok := betaAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`beta expected to be basetypes.BoolValue, was: %T`, betaAttribute)) - } - - deprecatedAttribute, ok := attributes["deprecated"] - - if !ok { - diags.AddError( - "Attribute Missing", - `deprecated is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - deprecatedVal, ok := deprecatedAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`deprecated expected to be basetypes.StringValue, was: %T`, deprecatedAttribute)) - } - - recommendAttribute, ok := attributes["recommend"] - - if !ok { - diags.AddError( - "Attribute Missing", - `recommend is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - recommendVal, ok := recommendAttribute.(basetypes.BoolValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`recommend expected to be basetypes.BoolValue, was: %T`, recommendAttribute)) - } - - versionAttribute, ok := attributes["version"] - - if !ok { - diags.AddError( - "Attribute Missing", - `version is missing from object`) - - return NewVersionsValueUnknown(), diags - } - - versionVal, ok := versionAttribute.(basetypes.StringValue) - - if !ok { - diags.AddError( - "Attribute Wrong Type", - fmt.Sprintf(`version expected to be basetypes.StringValue, was: %T`, versionAttribute)) - } - - if diags.HasError() { - return NewVersionsValueUnknown(), diags - } - - return VersionsValue{ - Beta: betaVal, - Deprecated: deprecatedVal, - Recommend: recommendVal, - Version: versionVal, - state: attr.ValueStateKnown, - }, diags -} - -func NewVersionsValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) VersionsValue { - object, diags := NewVersionsValue(attributeTypes, attributes) - - if diags.HasError() { - // This could potentially be added to the diag package. - diagsStrings := make([]string, 0, len(diags)) - - for _, diagnostic := range diags { - diagsStrings = append(diagsStrings, fmt.Sprintf( - "%s | %s | %s", - diagnostic.Severity(), - diagnostic.Summary(), - diagnostic.Detail())) - } - - panic("NewVersionsValueMust received error(s): " + strings.Join(diagsStrings, "\n")) - } - - return object -} - -func (t VersionsType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) { - if in.Type() == nil { - return NewVersionsValueNull(), nil - } - - if !in.Type().Equal(t.TerraformType(ctx)) { - return nil, fmt.Errorf("expected %s, got %s", t.TerraformType(ctx), in.Type()) - } - - if !in.IsKnown() { - return NewVersionsValueUnknown(), nil - } - - if in.IsNull() { - return NewVersionsValueNull(), nil - } - - attributes := map[string]attr.Value{} - - val := map[string]tftypes.Value{} - - err := in.As(&val) - - if err != nil { - return nil, err - } - - for k, v := range val { - a, err := t.AttrTypes[k].ValueFromTerraform(ctx, v) - - if err != nil { - return nil, err - } - - attributes[k] = a - } - - return NewVersionsValueMust(VersionsValue{}.AttributeTypes(ctx), attributes), nil -} - -func (t VersionsType) ValueType(ctx context.Context) attr.Value { - return VersionsValue{} -} - -var _ basetypes.ObjectValuable = VersionsValue{} - -type VersionsValue struct { - Beta basetypes.BoolValue `tfsdk:"beta"` - Deprecated basetypes.StringValue `tfsdk:"deprecated"` - Recommend basetypes.BoolValue `tfsdk:"recommend"` - Version basetypes.StringValue `tfsdk:"version"` - state attr.ValueState -} - -func (v VersionsValue) ToTerraformValue(ctx context.Context) (tftypes.Value, error) { - attrTypes := make(map[string]tftypes.Type, 4) - - var val tftypes.Value - var err error - - attrTypes["beta"] = basetypes.BoolType{}.TerraformType(ctx) - attrTypes["deprecated"] = basetypes.StringType{}.TerraformType(ctx) - attrTypes["recommend"] = basetypes.BoolType{}.TerraformType(ctx) - attrTypes["version"] = basetypes.StringType{}.TerraformType(ctx) - - objectType := tftypes.Object{AttributeTypes: attrTypes} - - switch v.state { - case attr.ValueStateKnown: - vals := make(map[string]tftypes.Value, 4) - - val, err = v.Beta.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["beta"] = val - - val, err = v.Deprecated.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["deprecated"] = val - - val, err = v.Recommend.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["recommend"] = val - - val, err = v.Version.ToTerraformValue(ctx) - - if err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - vals["version"] = val - - if err := tftypes.ValidateValue(objectType, vals); err != nil { - return tftypes.NewValue(objectType, tftypes.UnknownValue), err - } - - return tftypes.NewValue(objectType, vals), nil - case attr.ValueStateNull: - return tftypes.NewValue(objectType, nil), nil - case attr.ValueStateUnknown: - return tftypes.NewValue(objectType, tftypes.UnknownValue), nil - default: - panic(fmt.Sprintf("unhandled Object state in ToTerraformValue: %s", v.state)) - } -} - -func (v VersionsValue) IsNull() bool { - return v.state == attr.ValueStateNull -} - -func (v VersionsValue) IsUnknown() bool { - return v.state == attr.ValueStateUnknown -} - -func (v VersionsValue) String() string { - return "VersionsValue" -} - -func (v VersionsValue) ToObjectValue(ctx context.Context) (basetypes.ObjectValue, diag.Diagnostics) { - var diags diag.Diagnostics - - attributeTypes := map[string]attr.Type{ - "beta": basetypes.BoolType{}, - "deprecated": basetypes.StringType{}, - "recommend": basetypes.BoolType{}, - "version": basetypes.StringType{}, - } - - if v.IsNull() { - return types.ObjectNull(attributeTypes), diags - } - - if v.IsUnknown() { - return types.ObjectUnknown(attributeTypes), diags - } - - objVal, diags := types.ObjectValue( - attributeTypes, - map[string]attr.Value{ - "beta": v.Beta, - "deprecated": v.Deprecated, - "recommend": v.Recommend, - "version": v.Version, - }) - - return objVal, diags -} - -func (v VersionsValue) Equal(o attr.Value) bool { - other, ok := o.(VersionsValue) - - if !ok { - return false - } - - if v.state != other.state { - return false - } - - if v.state != attr.ValueStateKnown { - return true - } - - if !v.Beta.Equal(other.Beta) { - return false - } - - if !v.Deprecated.Equal(other.Deprecated) { - return false - } - - if !v.Recommend.Equal(other.Recommend) { - return false - } - - if !v.Version.Equal(other.Version) { - return false - } - - return true -} - -func (v VersionsValue) Type(ctx context.Context) attr.Type { - return VersionsType{ - basetypes.ObjectType{ - AttrTypes: v.AttributeTypes(ctx), - }, - } -} - -func (v VersionsValue) AttributeTypes(ctx context.Context) map[string]attr.Type { - return map[string]attr.Type{ - "beta": basetypes.BoolType{}, - "deprecated": basetypes.StringType{}, - "recommend": basetypes.BoolType{}, - "version": basetypes.StringType{}, - } -} diff --git a/stackit/internal/services/sqlserverflexbeta/database/datasource.go b/stackit/internal/services/sqlserverflexbeta/database/datasource.go index c6fa31bf..66d5ad0d 100644 --- a/stackit/internal/services/sqlserverflexbeta/database/datasource.go +++ b/stackit/internal/services/sqlserverflexbeta/database/datasource.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/config" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" @@ -143,6 +142,7 @@ func (d *databaseDataSource) Read(ctx context.Context, req datasource.ReadReques resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) tflog.Info(ctx, "SQL Server Flex beta database read") + } // handleReadError centralizes API error handling for the Read operation. diff --git a/stackit/internal/services/sqlserverflexbeta/database/mapper.go b/stackit/internal/services/sqlserverflexbeta/database/mapper.go index 43a4344f..7d82039a 100644 --- a/stackit/internal/services/sqlserverflexbeta/database/mapper.go +++ b/stackit/internal/services/sqlserverflexbeta/database/mapper.go @@ -2,9 +2,9 @@ package sqlserverflexbeta import ( "fmt" + "strings" "github.com/hashicorp/terraform-plugin-framework/types" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" ) @@ -33,7 +33,7 @@ func mapFields(source *sqlserverflexbeta.GetDatabaseResponse, model *dataSourceM model.Id = types.Int64Value(databaseId) model.DatabaseName = types.StringValue(source.GetName()) model.Name = types.StringValue(source.GetName()) - model.Owner = types.StringValue(source.GetOwner()) + model.Owner = types.StringValue(strings.Trim(source.GetOwner(), "\"")) model.Region = types.StringValue(region) model.ProjectId = types.StringValue(model.ProjectId.ValueString()) model.InstanceId = types.StringValue(model.InstanceId.ValueString()) @@ -74,7 +74,7 @@ func mapResourceFields(source *sqlserverflexbeta.GetDatabaseResponse, model *res model.Id = types.Int64Value(databaseId) model.DatabaseName = types.StringValue(source.GetName()) model.Name = types.StringValue(source.GetName()) - model.Owner = types.StringValue(source.GetOwner()) + model.Owner = types.StringValue(strings.Trim(source.GetOwner(), "\"")) model.Region = types.StringValue(region) model.ProjectId = types.StringValue(model.ProjectId.ValueString()) model.InstanceId = types.StringValue(model.InstanceId.ValueString()) diff --git a/stackit/internal/services/sqlserverflexbeta/database/mapper_test.go b/stackit/internal/services/sqlserverflexbeta/database/mapper_test.go index f865f22f..04125a7b 100644 --- a/stackit/internal/services/sqlserverflexbeta/database/mapper_test.go +++ b/stackit/internal/services/sqlserverflexbeta/database/mapper_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/utils" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" datasource "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database/datasources_gen" ) @@ -35,7 +34,7 @@ func TestMapFields(t *testing.T) { Name: utils.Ptr("my-db"), CollationName: utils.Ptr("collation"), CompatibilityLevel: utils.Ptr(int64(150)), - Owner: utils.Ptr("my-owner"), + Owner: utils.Ptr("\"my-owner\""), }, model: &dataSourceModel{ DatabaseModel: datasource.DatabaseModel{ @@ -127,7 +126,7 @@ func TestMapResourceFields(t *testing.T) { source: &sqlserverflexbeta.GetDatabaseResponse{ Id: utils.Ptr(int64(1)), Name: utils.Ptr("my-db"), - Owner: utils.Ptr("my-owner"), + Owner: utils.Ptr("\"my-owner\""), }, model: &resourceModel{ ProjectId: types.StringValue("my-project"), @@ -137,17 +136,13 @@ func TestMapResourceFields(t *testing.T) { }, expected: expected{ model: &resourceModel{ - Id: types.Int64Value(1), - Name: types.StringValue("my-db"), - Compatibility: types.Int64Value(0), - CompatibilityLevel: types.Int64Value(0), - Collation: types.StringValue(""), - CollationName: types.StringValue(""), - DatabaseName: types.StringValue("my-db"), - InstanceId: types.StringValue("my-instance"), - ProjectId: types.StringValue("my-project"), - Region: types.StringValue("eu01"), - Owner: types.StringValue("my-owner"), + Id: types.Int64Value(1), + Name: types.StringValue("my-db"), + DatabaseName: types.StringValue("my-db"), + InstanceId: types.StringValue("my-instance"), + ProjectId: types.StringValue("my-project"), + Region: types.StringValue("eu01"), + Owner: types.StringValue("my-owner"), }, }, }, diff --git a/stackit/internal/services/sqlserverflexbeta/database/planModifiers.yaml b/stackit/internal/services/sqlserverflexbeta/database/planModifiers.yaml index 08d7e6cf..1d010ed7 100644 --- a/stackit/internal/services/sqlserverflexbeta/database/planModifiers.yaml +++ b/stackit/internal/services/sqlserverflexbeta/database/planModifiers.yaml @@ -2,7 +2,6 @@ fields: - name: 'id' modifiers: - 'UseStateForUnknown' - - 'RequiresReplace' - name: 'instance_id' validators: @@ -33,16 +32,13 @@ fields: - name: 'owner' modifiers: - 'UseStateForUnknown' - - 'RequiresReplace' - name: 'database_name' modifiers: - 'UseStateForUnknown' - - 'RequiresReplace' - name: 'collation_name' modifiers: - - 'RequiresReplace' - 'UseStateForUnknown' - name: 'compatibility' @@ -53,4 +49,3 @@ fields: - name: 'compatibility_level' modifiers: - 'UseStateForUnknown' - - 'RequiresReplace' diff --git a/stackit/internal/services/sqlserverflexbeta/database/resource.go b/stackit/internal/services/sqlserverflexbeta/database/resource.go index 9862ca57..7c191e42 100644 --- a/stackit/internal/services/sqlserverflexbeta/database/resource.go +++ b/stackit/internal/services/sqlserverflexbeta/database/resource.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/config" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" wait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexbeta" @@ -36,6 +35,10 @@ var ( // Define errors errDatabaseNotFound = errors.New("database not found") + + // Error message constants + extractErrorSummary = "extracting failed" + extractErrorMessage = "Extracting identity data: %v" ) func NewDatabaseResource() resource.Resource { @@ -69,6 +72,7 @@ func (r *databaseResource) Metadata( var modifiersFileByte []byte func (r *databaseResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + s := sqlserverflexbetaResGen.DatabaseResourceSchema(ctx) fields, err := utils.ReadModifiersConfig(modifiersFileByte) @@ -243,6 +247,7 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques return } + // TODO: is this neccessary to wait for the database-> API say 200 ? waitResp, err := wait.CreateDatabaseWaitHandler( ctx, r.client, @@ -305,8 +310,19 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques return } + database, err := r.client.GetDatabaseRequest(ctx, projectId, region, instanceId, databaseName).Execute() + if err != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + "Error creating database", + fmt.Sprintf("Getting database details after creation: %v", err), + ) + return + } + // Map response body to schema - err = mapResourceFields(waitResp, &data, region) + err = mapResourceFields(database, &data, region) if err != nil { core.LogAndAddError( ctx, @@ -336,12 +352,24 @@ func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, r return } + // Read identity data + var identityData DatabaseResourceIdentityModel + resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...) + if resp.Diagnostics.HasError() { + return + } + ctx = core.InitProviderContext(ctx) - projectId := model.ProjectId.ValueString() - region := model.Region.ValueString() - instanceId := model.InstanceId.ValueString() - databaseName := model.DatabaseName.ValueString() + projectId, region, instanceId, databaseName, errExt := r.extractIdentityData(model, identityData) + if errExt != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + extractErrorSummary, + fmt.Sprintf(extractErrorMessage, errExt), + ) + } ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "instance_id", instanceId) @@ -396,7 +424,7 @@ func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, r func (r *databaseResource) Update(ctx context.Context, _ resource.UpdateRequest, resp *resource.UpdateResponse) { // TODO: Check update api endpoint - not available at the moment, so return an error for now - core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating database", "there is no way to update a database") + core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating database", "Database can't be updated") } func (r *databaseResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { @@ -408,10 +436,24 @@ func (r *databaseResource) Delete(ctx context.Context, req resource.DeleteReques return } - projectId := model.ProjectId.ValueString() - region := model.Region.ValueString() - instanceId := model.InstanceId.ValueString() - databaseName := model.DatabaseName.ValueString() + // Read identity data + var identityData DatabaseResourceIdentityModel + resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...) + if resp.Diagnostics.HasError() { + return + } + + ctx = core.InitProviderContext(ctx) + + projectId, region, instanceId, databaseName, errExt := r.extractIdentityData(model, identityData) + if errExt != nil { + core.LogAndAddError( + ctx, + &resp.Diagnostics, + extractErrorSummary, + fmt.Sprintf(extractErrorMessage, errExt), + ) + } ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "instance_id", instanceId) @@ -426,14 +468,10 @@ func (r *databaseResource) Delete(ctx context.Context, req resource.DeleteReques &resp.Diagnostics, "Error deleting database", fmt.Sprintf( - "Calling API: %v\nname: %s, region: %s, instanceId: %s", err, databaseName, region, instanceId, - ), - ) + "Calling API: %v\nname: %s, region: %s, instanceId: %s", err, databaseName, region, instanceId)) return } - // TODO: wait handler?? - ctx = core.LogResponse(ctx) resp.State.RemoveResource(ctx) @@ -447,6 +485,7 @@ func (r *databaseResource) ModifyPlan( req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse, ) { // nolint:gocritic // function signature required by Terraform + // skip initial empty configuration to avoid follow-up errors if req.Config.Raw.IsNull() { return @@ -509,7 +548,7 @@ func (r *databaseResource) ImportState( ctx, &resp.Diagnostics, "Error importing database", fmt.Sprintf( - "Expected import identifier with format [project_id],[region],[instance_id],[database_name] Got: %q", + "Expected import identifier with format: [project_id],[region],[instance_id],[database_name] Got: %q", req.ID, ), ) @@ -556,4 +595,45 @@ func (r *databaseResource) ImportState( tflog.Info(ctx, "Sqlserverflexbeta database state imported") } -// extractIdentityData extracts essential identifiers from the resource model, falling back to the identity mode +// extractIdentityData extracts essential identifiers from the resource model, falling back to the identity model. +func (r *databaseResource) extractIdentityData( + model resourceModel, + identity DatabaseResourceIdentityModel, +) (projectId, region, instanceId, databaseName string, err error) { + if !model.Name.IsNull() && !model.Name.IsUnknown() { + databaseName = model.Name.ValueString() + } else { + if identity.DatabaseName.IsNull() || identity.DatabaseName.IsUnknown() { + return "", "", "", "", fmt.Errorf("database_name not found in config") + } + databaseName = identity.DatabaseName.ValueString() + } + + if !model.ProjectId.IsNull() && !model.ProjectId.IsUnknown() { + projectId = model.ProjectId.ValueString() + } else { + if identity.ProjectID.IsNull() || identity.ProjectID.IsUnknown() { + return "", "", "", "", fmt.Errorf("project_id not found in config") + } + projectId = identity.ProjectID.ValueString() + } + + if !model.Region.IsNull() && !model.Region.IsUnknown() { + region = r.providerData.GetRegionWithOverride(model.Region) + } else { + if identity.Region.IsNull() || identity.Region.IsUnknown() { + return "", "", "", "", fmt.Errorf("region not found in config") + } + region = r.providerData.GetRegionWithOverride(identity.Region) + } + + if !model.InstanceId.IsNull() && !model.InstanceId.IsUnknown() { + instanceId = model.InstanceId.ValueString() + } else { + if identity.InstanceID.IsNull() || identity.InstanceID.IsUnknown() { + return "", "", "", "", fmt.Errorf("instance_id not found in config") + } + instanceId = identity.InstanceID.ValueString() + } + return projectId, region, instanceId, databaseName, nil +} diff --git a/stackit/internal/services/sqlserverflexbeta/flavor/datasource.go b/stackit/internal/services/sqlserverflexbeta/flavor/datasource.go index 06e055f2..59f3982c 100644 --- a/stackit/internal/services/sqlserverflexbeta/flavor/datasource.go +++ b/stackit/internal/services/sqlserverflexbeta/flavor/datasource.go @@ -254,7 +254,7 @@ func (r *flavorDataSource) Schema(ctx context.Context, _ datasource.SchemaReques // }, // }, // }, - // }, + //}, } } diff --git a/stackit/internal/services/sqlserverflexbeta/flavor/functions_test.go b/stackit/internal/services/sqlserverflexbeta/flavor/functions_test.go index fb666253..974f1fa4 100644 --- a/stackit/internal/services/sqlserverflexbeta/flavor/functions_test.go +++ b/stackit/internal/services/sqlserverflexbeta/flavor/functions_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/stackitcloud/stackit-sdk-go/core/utils" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" ) diff --git a/stackit/internal/services/sqlserverflexbeta/flavors/datasource.go b/stackit/internal/services/sqlserverflexbeta/flavors/datasource.go index b6be1dd4..b401e4ff 100644 --- a/stackit/internal/services/sqlserverflexbeta/flavors/datasource.go +++ b/stackit/internal/services/sqlserverflexbeta/flavors/datasource.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/config" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" @@ -112,7 +111,7 @@ func (d *flavorsDataSource) Read(ctx context.Context, req datasource.ReadRequest projectId := data.ProjectId.ValueString() region := d.providerData.GetRegionWithOverride(data.Region) // TODO: implement right identifier for flavors - flavorsId := data.Flavors + flavorsId := data.FlavorsModel.Flavors ctx = tflog.SetField(ctx, "project_id", projectId) ctx = tflog.SetField(ctx, "region", region) diff --git a/stackit/internal/services/sqlserverflexbeta/instance/datasource.go b/stackit/internal/services/sqlserverflexbeta/instance/datasource.go index 2830ac62..85834b26 100644 --- a/stackit/internal/services/sqlserverflexbeta/instance/datasource.go +++ b/stackit/internal/services/sqlserverflexbeta/instance/datasource.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/config" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" diff --git a/stackit/internal/services/sqlserverflexbeta/instance/functions.go b/stackit/internal/services/sqlserverflexbeta/instance/functions.go index 77791ee6..ee4d30b4 100644 --- a/stackit/internal/services/sqlserverflexbeta/instance/functions.go +++ b/stackit/internal/services/sqlserverflexbeta/instance/functions.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" sqlserverflexbetaDataGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance/datasources_gen" @@ -25,7 +24,7 @@ func mapResponseToModel( ) error { m.BackupSchedule = types.StringValue(resp.GetBackupSchedule()) m.Edition = types.StringValue(string(resp.GetEdition())) - m.Encryption = handleEncryption(ctx, m, resp) + m.Encryption = handleEncryption(m, resp) m.FlavorId = types.StringValue(resp.GetFlavorId()) m.Id = types.StringValue(resp.GetId()) m.InstanceId = types.StringValue(resp.GetId()) @@ -81,7 +80,7 @@ func mapDataResponseToModel( ) error { m.BackupSchedule = types.StringValue(resp.GetBackupSchedule()) m.Edition = types.StringValue(string(resp.GetEdition())) - m.Encryption = handleDSEncryption(ctx, m, resp) + m.Encryption = handleDSEncryption(m, resp) m.FlavorId = types.StringValue(resp.GetFlavorId()) m.Id = types.StringValue(resp.GetId()) m.InstanceId = types.StringValue(resp.GetId()) @@ -130,7 +129,6 @@ func mapDataResponseToModel( } func handleEncryption( - ctx context.Context, m *sqlserverflexbetaResGen.InstanceModel, resp *sqlserverflexbeta.GetInstanceResponse, ) sqlserverflexbetaResGen.EncryptionValue { @@ -140,26 +138,30 @@ func handleEncryption( resp.Encryption.KekKeyRingId == nil || resp.Encryption.KekKeyVersion == nil || resp.Encryption.ServiceAccount == nil { + if m.Encryption.IsNull() || m.Encryption.IsUnknown() { return sqlserverflexbetaResGen.NewEncryptionValueNull() } return m.Encryption } - enc := sqlserverflexbetaResGen.NewEncryptionValueMust( - sqlserverflexbetaResGen.EncryptionValue{}.AttributeTypes(ctx), - map[string]attr.Value{ - "kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()), - "kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()), - "kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()), - "service_account": types.StringValue(resp.Encryption.GetServiceAccount()), - }, - ) + enc := sqlserverflexbetaResGen.NewEncryptionValueNull() + if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok { + enc.KekKeyId = types.StringValue(kVal) + } + if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok { + enc.KekKeyRingId = types.StringValue(kkVal) + } + if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok { + enc.KekKeyVersion = types.StringValue(kkvVal) + } + if sa, ok := resp.Encryption.GetServiceAccountOk(); ok { + enc.ServiceAccount = types.StringValue(sa) + } return enc } func handleDSEncryption( - ctx context.Context, m *dataSourceModel, resp *sqlserverflexbeta.GetInstanceResponse, ) sqlserverflexbetaDataGen.EncryptionValue { @@ -169,21 +171,26 @@ func handleDSEncryption( resp.Encryption.KekKeyRingId == nil || resp.Encryption.KekKeyVersion == nil || resp.Encryption.ServiceAccount == nil { + if m.Encryption.IsNull() || m.Encryption.IsUnknown() { return sqlserverflexbetaDataGen.NewEncryptionValueNull() } return m.Encryption } - enc := sqlserverflexbetaDataGen.NewEncryptionValueMust( - sqlserverflexbetaDataGen.EncryptionValue{}.AttributeTypes(ctx), - map[string]attr.Value{ - "kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()), - "kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()), - "kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()), - "service_account": types.StringValue(resp.Encryption.GetServiceAccount()), - }, - ) + enc := sqlserverflexbetaDataGen.NewEncryptionValueNull() + if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok { + enc.KekKeyId = types.StringValue(kVal) + } + if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok { + enc.KekKeyRingId = types.StringValue(kkVal) + } + if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok { + enc.KekKeyVersion = types.StringValue(kkvVal) + } + if sa, ok := resp.Encryption.GetServiceAccountOk(); ok { + enc.ServiceAccount = types.StringValue(sa) + } return enc } @@ -202,12 +209,17 @@ func toCreatePayload( } var encryptionPayload *sqlserverflexbeta.CreateInstanceRequestPayloadGetEncryptionArgType = nil - if !model.Encryption.IsNull() && !model.Encryption.IsUnknown() { - encryptionPayload = &sqlserverflexbeta.CreateInstanceRequestPayloadGetEncryptionArgType{} - encryptionPayload.KekKeyId = model.Encryption.KekKeyId.ValueStringPointer() - encryptionPayload.KekKeyRingId = model.Encryption.KekKeyRingId.ValueStringPointer() - encryptionPayload.KekKeyVersion = model.Encryption.KekKeyVersion.ValueStringPointer() - encryptionPayload.ServiceAccount = model.Encryption.ServiceAccount.ValueStringPointer() + if !model.Encryption.IsNull() && !model.Encryption.IsUnknown() && + !model.Encryption.KekKeyId.IsNull() && model.Encryption.KekKeyId.IsUnknown() && model.Encryption.KekKeyId.ValueString() != "" && + !model.Encryption.KekKeyRingId.IsNull() && !model.Encryption.KekKeyRingId.IsUnknown() && model.Encryption.KekKeyRingId.ValueString() != "" && + !model.Encryption.KekKeyVersion.IsNull() && !model.Encryption.KekKeyVersion.IsUnknown() && model.Encryption.KekKeyVersion.ValueString() != "" && + !model.Encryption.ServiceAccount.IsNull() && !model.Encryption.ServiceAccount.IsUnknown() && model.Encryption.ServiceAccount.ValueString() != "" { + encryptionPayload = &sqlserverflexbeta.CreateInstanceRequestPayloadGetEncryptionArgType{ + KekKeyId: model.Encryption.KekKeyId.ValueStringPointer(), + KekKeyRingId: model.Encryption.KekKeyVersion.ValueStringPointer(), + KekKeyVersion: model.Encryption.KekKeyRingId.ValueStringPointer(), + ServiceAccount: model.Encryption.ServiceAccount.ValueStringPointer(), + } } networkPayload := &sqlserverflexbeta.CreateInstanceRequestPayloadGetNetworkArgType{} @@ -236,6 +248,7 @@ func toCreatePayload( conversion.StringValueToPointer(model.Version), ), }, nil + } func toUpdatePayload( @@ -249,7 +262,7 @@ func toUpdatePayload( if m.Replicas.ValueInt64() > math.MaxUint32 { return nil, fmt.Errorf("replicas value is too big for uint32") } - replVal := sqlserverflexbeta.Replicas(uint32(m.Replicas.ValueInt64())) // nolint:gosec // check is performed above + replVal := sqlserverflexbeta.Replicas(uint32(m.Replicas.ValueInt64())) var netAcl []string diags := m.Network.Acl.ElementsAs(ctx, &netAcl, false) diff --git a/stackit/internal/services/sqlserverflexbeta/instance/functions_test.go b/stackit/internal/services/sqlserverflexbeta/instance/functions_test.go deleted file mode 100644 index 0c6f6147..00000000 --- a/stackit/internal/services/sqlserverflexbeta/instance/functions_test.go +++ /dev/null @@ -1,273 +0,0 @@ -package sqlserverflexbeta - -import ( - "context" - "reflect" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/stackitcloud/stackit-sdk-go/core/utils" - - sqlserverflexbetaPkgGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" - sqlserverflexbetaRs "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance/resources_gen" -) - -func Test_handleDSEncryption(t *testing.T) { - type args struct { - m *dataSourceModel - resp *sqlserverflexbetaPkgGen.GetInstanceResponse - } - tests := []struct { - name string - args args - want sqlserverflexbetaRs.EncryptionValue - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run( - tt.name, func(t *testing.T) { - if got := handleDSEncryption(t.Context(), tt.args.m, tt.args.resp); !reflect.DeepEqual(got, tt.want) { - t.Errorf("handleDSEncryption() = %v, want %v", got, tt.want) - } - }, - ) - } -} - -func Test_handleEncryption(t *testing.T) { - type args struct { - m *sqlserverflexbetaRs.InstanceModel - resp *sqlserverflexbetaPkgGen.GetInstanceResponse - } - tests := []struct { - name string - args args - want sqlserverflexbetaRs.EncryptionValue - }{ - { - name: "nil response", - args: args{ - m: &sqlserverflexbetaRs.InstanceModel{}, - resp: &sqlserverflexbetaPkgGen.GetInstanceResponse{}, - }, - want: sqlserverflexbetaRs.EncryptionValue{}, - }, - { - name: "nil response", - args: args{ - m: &sqlserverflexbetaRs.InstanceModel{}, - resp: &sqlserverflexbetaPkgGen.GetInstanceResponse{ - Encryption: &sqlserverflexbetaPkgGen.InstanceEncryption{}, - }, - }, - want: sqlserverflexbetaRs.NewEncryptionValueNull(), - }, - { - name: "response with values", - args: args{ - m: &sqlserverflexbetaRs.InstanceModel{}, - resp: &sqlserverflexbetaPkgGen.GetInstanceResponse{ - Encryption: &sqlserverflexbetaPkgGen.InstanceEncryption{ - KekKeyId: utils.Ptr("kek_key_id"), - KekKeyRingId: utils.Ptr("kek_key_ring_id"), - KekKeyVersion: utils.Ptr("kek_key_version"), - ServiceAccount: utils.Ptr("kek_svc_acc"), - }, - }, - }, - want: sqlserverflexbetaRs.EncryptionValue{ - KekKeyId: types.StringValue("kek_key_id"), - KekKeyRingId: types.StringValue("kek_key_ring_id"), - KekKeyVersion: types.StringValue("kek_key_version"), - ServiceAccount: types.StringValue("kek_svc_acc"), - }, - }, - } - for _, tt := range tests { - t.Run( - tt.name, func(t *testing.T) { - if got := handleEncryption(t.Context(), tt.args.m, tt.args.resp); !reflect.DeepEqual(got, tt.want) { - t.Errorf("handleEncryption() = %v, want %v", got, tt.want) - } - }, - ) - } -} - -func Test_mapDataResponseToModel(t *testing.T) { - type args struct { - ctx context.Context - resp *sqlserverflexbetaPkgGen.GetInstanceResponse - m *dataSourceModel - tfDiags diag.Diagnostics - } - tests := []struct { - name string - args args - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run( - tt.name, func(t *testing.T) { - if err := mapDataResponseToModel( - tt.args.ctx, - tt.args.resp, - tt.args.m, - tt.args.tfDiags, - ); (err != nil) != tt.wantErr { - t.Errorf("mapDataResponseToModel() error = %v, wantErr %v", err, tt.wantErr) - } - }, - ) - } -} - -func Test_mapResponseToModel(t *testing.T) { - type args struct { - ctx context.Context - resp *sqlserverflexbetaPkgGen.GetInstanceResponse - m *sqlserverflexbetaRs.InstanceModel - tfDiags diag.Diagnostics - } - tests := []struct { - name string - args args - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run( - tt.name, func(t *testing.T) { - if err := mapResponseToModel( - tt.args.ctx, - tt.args.resp, - tt.args.m, - tt.args.tfDiags, - ); (err != nil) != tt.wantErr { - t.Errorf("mapResponseToModel() error = %v, wantErr %v", err, tt.wantErr) - } - }, - ) - } -} - -func Test_toCreatePayload(t *testing.T) { - type args struct { - ctx context.Context - model *sqlserverflexbetaRs.InstanceModel - } - tests := []struct { - name string - args args - want *sqlserverflexbetaPkgGen.CreateInstanceRequestPayload - wantErr bool - }{ - { - name: "simple", - args: args{ - ctx: context.Background(), - model: &sqlserverflexbetaRs.InstanceModel{ - Encryption: sqlserverflexbetaRs.NewEncryptionValueMust( - sqlserverflexbetaRs.EncryptionValue{}.AttributeTypes(context.Background()), - map[string]attr.Value{ - "kek_key_id": types.StringValue("kek_key_id"), - "kek_key_ring_id": types.StringValue("kek_key_ring_id"), - "kek_key_version": types.StringValue("kek_key_version"), - "service_account": types.StringValue("sacc"), - }, - ), - Storage: sqlserverflexbetaRs.StorageValue{}, - }, - }, - want: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayload{ - BackupSchedule: nil, - Encryption: &sqlserverflexbetaPkgGen.InstanceEncryption{ - KekKeyId: utils.Ptr("kek_key_id"), - KekKeyRingId: utils.Ptr("kek_key_ring_id"), - KekKeyVersion: utils.Ptr("kek_key_version"), - ServiceAccount: utils.Ptr("sacc"), - }, - FlavorId: nil, - Name: nil, - Network: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayloadNetwork{}, - RetentionDays: nil, - Storage: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayloadGetStorageArgType{}, - Version: nil, - }, - wantErr: false, - }, - { - name: "nil object", - args: args{ - ctx: context.Background(), - model: &sqlserverflexbetaRs.InstanceModel{ - Encryption: sqlserverflexbetaRs.NewEncryptionValueNull(), - Storage: sqlserverflexbetaRs.StorageValue{}, - }, - }, - want: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayload{ - BackupSchedule: nil, - Encryption: nil, - FlavorId: nil, - Name: nil, - Network: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayloadNetwork{}, - RetentionDays: nil, - Storage: &sqlserverflexbetaPkgGen.CreateInstanceRequestPayloadGetStorageArgType{}, - Version: nil, - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run( - tt.name, func(t *testing.T) { - got, err := toCreatePayload(tt.args.ctx, tt.args.model) - if (err != nil) != tt.wantErr { - t.Errorf("toCreatePayload() error = %v, wantErr %v", err, tt.wantErr) - return - } - if diff := cmp.Diff(tt.want, got); diff != "" { - t.Errorf("model mismatch (-want +got):\n%s", diff) - } - }, - ) - } -} - -func Test_toUpdatePayload(t *testing.T) { - type args struct { - ctx context.Context - m *sqlserverflexbetaRs.InstanceModel - resp *resource.UpdateResponse - } - tests := []struct { - name string - args args - want *sqlserverflexbetaPkgGen.UpdateInstanceRequestPayload - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run( - tt.name, func(t *testing.T) { - got, err := toUpdatePayload(tt.args.ctx, tt.args.m, tt.args.resp) - if (err != nil) != tt.wantErr { - t.Errorf("toUpdatePayload() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("toUpdatePayload() got = %v, want %v", got, tt.want) - } - }, - ) - } -} diff --git a/stackit/internal/services/sqlserverflexbeta/instance/resource.go b/stackit/internal/services/sqlserverflexbeta/instance/resource.go index 044b4b43..6abcbbd3 100644 --- a/stackit/internal/services/sqlserverflexbeta/instance/resource.go +++ b/stackit/internal/services/sqlserverflexbeta/instance/resource.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/config" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" wait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexbeta" @@ -54,7 +53,7 @@ type InstanceResourceIdentityModel struct { } func (r *instanceResource) Metadata( - _ context.Context, + ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse, ) { @@ -64,7 +63,7 @@ func (r *instanceResource) Metadata( //go:embed planModifiers.yaml var modifiersFileByte []byte -func (r *instanceResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *instanceResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { s := sqlserverflexbetaResGen.InstanceResourceSchema(ctx) fields, err := utils.ReadModifiersConfig(modifiersFileByte) @@ -147,6 +146,7 @@ func (r *instanceResource) ModifyPlan( req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse, ) { // nolint:gocritic // function signature required by Terraform + // skip initial empty configuration to avoid follow-up errors if req.Config.Raw.IsNull() { return @@ -206,7 +206,6 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques ) return } - // Create new Instance createResp, err := r.client.CreateInstanceRequest( ctx, @@ -293,6 +292,13 @@ func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, r return } + // Read identity data + var identityData InstanceResourceIdentityModel + resp.Diagnostics.Append(req.Identity.Get(ctx, &identityData)...) + if resp.Diagnostics.HasError() { + return + } + ctx = core.InitProviderContext(ctx) projectId := data.ProjectId.ValueString() @@ -516,7 +522,7 @@ func (r *instanceResource) ImportState( ctx, &resp.Diagnostics, "Error importing instance", fmt.Sprintf( - "Expected import identifier with format [project_id],[region],[instance_id] Got: %q", + "Expected import identifier with format: [project_id],[region],[instance_id] Got: %q", req.ID, ), ) diff --git a/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go b/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go index 887c5edd..33f7cd29 100644 --- a/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go +++ b/stackit/internal/services/sqlserverflexbeta/sqlserverflex_acc_test.go @@ -4,20 +4,16 @@ import ( "context" _ "embed" "fmt" - "log" "os" "strconv" - "strings" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/stackitcloud/stackit-sdk-go/core/config" - - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils" - sqlserverflexbetaResGen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" + "github.com/hashicorp/terraform-plugin-testing/terraform" sqlserverflexbeta "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance" + "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils" // The fwresource import alias is so there is no collision // with the more typical acceptance testing import: // "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -26,46 +22,6 @@ import ( const providerPrefix = "stackitprivatepreview_sqlserverflexbeta" -var testInstances []string - -func init() { - sweeperName := fmt.Sprintf("%s_%s", providerPrefix, "sweeper") - - resource.AddTestSweepers(sweeperName, &resource.Sweeper{ - Name: sweeperName, - F: func(region string) error { - ctx := context.Background() - apiClientConfigOptions := []config.ConfigurationOption{} - apiClient, err := sqlserverflexbetaResGen.NewAPIClient(apiClientConfigOptions...) - if err != nil { - log.Fatalln(err) - } - - instances, err := apiClient.ListInstancesRequest(ctx, testutils.ProjectId, region). - Size(100). - Execute() - if err != nil { - log.Fatalln(err) - } - - for _, inst := range instances.GetInstances() { - if strings.HasPrefix(inst.GetName(), "tf-acc-") { - for _, item := range testInstances { - if inst.GetName() == item { - delErr := apiClient.DeleteInstanceRequestExecute(ctx, testutils.ProjectId, region, inst.GetId()) - if delErr != nil { - // TODO: maybe just warn? - log.Fatalln(delErr) - } - } - } - } - } - return nil - }, - }) -} - func TestInstanceResourceSchema(t *testing.T) { t.Parallel() @@ -164,6 +120,7 @@ func getExample() resData { func TestAccInstance(t *testing.T) { exData := getExample() + t.Logf(" ... working on instance %s", exData.TfName) updNameData := exData updNameData.Name = "name-updated" @@ -171,12 +128,8 @@ func TestAccInstance(t *testing.T) { updSizeData := exData updSizeData.Size = 25 - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - t.Logf(" ... working on instance %s", exData.TfName) - testInstances = append(testInstances, exData.TfName) - }, + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ // Create and verify @@ -188,7 +141,6 @@ func TestAccInstance(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", exData.Name), resource.TestCheckResourceAttrSet(resName("instance", exData.TfName), "id"), - // TODO: check all fields ), }, // Update name and verify @@ -209,7 +161,7 @@ func TestAccInstance(t *testing.T) { ), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - testutils.ResStr(providerPrefix, "instance", exData.TfName), + resName("instance", exData.TfName), "storage.size", strconv.Itoa(int(updSizeData.Size)), ), @@ -220,92 +172,24 @@ func TestAccInstance(t *testing.T) { }, //// Import test //{ - // ResourceName: resName("instance", exData.TfName), + // ResourceName: "example_resource.test", // ImportState: true, // ImportStateVerify: true, - // }, - }, - }) -} - -func TestAccInstanceReApply(t *testing.T) { - exData := getExample() - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - t.Logf(" ... working on instance %s", exData.TfName) - testInstances = append(testInstances, exData.TfName) - }, - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create and verify - { - Config: testutils.StringFromTemplateMust( - "testdata/instance_template.gompl", - exData, - ), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", exData.Name), - resource.TestCheckResourceAttrSet(resName("instance", exData.TfName), "id"), - // TODO: check all fields - ), - }, - // Create and verify - { - Config: testutils.StringFromTemplateMust( - "testdata/instance_template.gompl", - exData, - ), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", exData.Name), - resource.TestCheckResourceAttrSet(resName("instance", exData.TfName), "id"), - // TODO: check all fields - ), - }, - { - RefreshState: true, - }, - // Create and verify - { - Config: testutils.StringFromTemplateMust( - "testdata/instance_template.gompl", - exData, - ), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(resName("instance", exData.TfName), "name", exData.Name), - resource.TestCheckResourceAttrSet(resName("instance", exData.TfName), "id"), - // TODO: check all fields - ), - }, - // Import test - { - ResourceName: resName("instance", exData.TfName), - ImportStateKind: resource.ImportBlockWithResourceIdentity, - ImportState: true, - // ImportStateVerify is not supported with plannable import blocks - // ImportStateVerify: true, - }, + //}, }, }) } func TestAccInstanceNoEncryption(t *testing.T) { data := getExample() - + t.Logf(" ... working on instance %s", data.TfName) dbName := "testDb" userName := "testUser" data.Users = []User{ { Name: userName, ProjectId: os.Getenv("TF_ACC_PROJECT_ID"), - Roles: []string{ - "##STACKIT_DatabaseManager##", - "##STACKIT_LoginManager##", - "##STACKIT_ProcessManager##", - "##STACKIT_SQLAgentManager##", - "##STACKIT_SQLAgentUser##", - "##STACKIT_ServerManager##", - }, + Roles: []string{"##STACKIT_LoginManager##", "##STACKIT_DatabaseManager##"}, }, } data.Databases = []Database{ @@ -316,12 +200,8 @@ func TestAccInstanceNoEncryption(t *testing.T) { }, } - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - t.Logf(" ... working on instance %s", data.TfName) - testInstances = append(testInstances, data.TfName) - }, + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ // Create and verify @@ -346,20 +226,20 @@ func TestAccInstanceNoEncryption(t *testing.T) { resource.TestCheckNoResourceAttr(resName("instance", data.TfName), "encryption"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_id"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_version"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_ring_id"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.service_account"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_id"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_version"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_ring_id"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.service_account"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.access_scope"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.acl"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.access_scope"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.acl"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.instance_address"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.router_address"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.instance_address"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.router_address"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.class"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.size"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.class"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.size"), // check instance values are correct resource.TestCheckResourceAttr(resName("instance", data.TfName), "name", data.Name), @@ -369,13 +249,13 @@ func TestAccInstanceNoEncryption(t *testing.T) { resource.TestCheckResourceAttrSet(resName("user", userName), "username"), // resource.TestCheckResourceAttrSet(resName("user", userName), "roles"), - // func(s *terraform.State) error { - // return nil - // }, + func(s *terraform.State) error { + return nil + }, // check user values are correct resource.TestCheckResourceAttr(resName("user", userName), "username", userName), - resource.TestCheckResourceAttr(resName("user", userName), "roles.#", strconv.Itoa(len(data.Users[0].Roles))), + resource.TestCheckResourceAttr(resName("user", userName), "roles.#", "2"), // check database values are set resource.TestCheckResourceAttrSet(resName("database", dbName), "id"), @@ -395,14 +275,14 @@ func TestAccInstanceNoEncryption(t *testing.T) { func TestAccInstanceEncryption(t *testing.T) { data := getExample() - + t.Logf(" ... working on instance %s", data.TfName) dbName := "testDb" userName := "testUser" data.Users = []User{ { Name: userName, ProjectId: os.Getenv("TF_ACC_PROJECT_ID"), - Roles: []string{"##STACKIT_DatabaseManager##", "##STACKIT_LoginManager##"}, + Roles: []string{"##STACKIT_LoginManager##", "##STACKIT_DatabaseManager##"}, }, } data.Databases = []Database{ @@ -419,12 +299,8 @@ func TestAccInstanceEncryption(t *testing.T) { data.KekKeyVersion = 1 data.KekServiceAccount = "henselinm-u2v3ex1@sa.stackit.cloud" - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - t.Logf(" ... working on instance %s", data.TfName) - testInstances = append(testInstances, data.TfName) - }, + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ // Create and verify @@ -447,20 +323,20 @@ func TestAccInstanceEncryption(t *testing.T) { resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "status"), resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "version"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_id"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_version"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_ring_id"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.service_account"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_id"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_version"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.kek_key_ring_id"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "encryption.service_account"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.access_scope"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.acl"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.access_scope"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.acl"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.instance_address"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.router_address"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.instance_address"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "network.router_address"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.class"), - // resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.size"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.class"), + //resource.TestCheckResourceAttrSet(resName("instance", data.TfName), "storage.size"), // check instance values are correct resource.TestCheckResourceAttr(resName("instance", data.TfName), "name", data.Name), @@ -469,9 +345,9 @@ func TestAccInstanceEncryption(t *testing.T) { resource.TestCheckResourceAttrSet(resName("user", userName), "id"), resource.TestCheckResourceAttrSet(resName("user", userName), "username"), - // func(s *terraform.State) error { - // return nil - // }, + func(s *terraform.State) error { + return nil + }, // check user values are correct resource.TestCheckResourceAttr(resName("user", userName), "username", userName), diff --git a/stackit/internal/services/sqlserverflexbeta/user/datasource.go b/stackit/internal/services/sqlserverflexbeta/user/datasource.go index d726bc2b..e15ad28f 100644 --- a/stackit/internal/services/sqlserverflexbeta/user/datasource.go +++ b/stackit/internal/services/sqlserverflexbeta/user/datasource.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" sqlserverflexUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/utils" @@ -20,6 +19,8 @@ import ( var _ datasource.DataSource = (*userDataSource)(nil) +const errorPrefix = "[Sqlserverflexbeta - User]" + func NewUserDataSource() datasource.DataSource { return &userDataSource{} } diff --git a/stackit/internal/services/sqlserverflexbeta/user/mapper.go b/stackit/internal/services/sqlserverflexbeta/user/mapper.go index ca916d28..59c915bb 100644 --- a/stackit/internal/services/sqlserverflexbeta/user/mapper.go +++ b/stackit/internal/services/sqlserverflexbeta/user/mapper.go @@ -2,12 +2,10 @@ package sqlserverflexbeta import ( "fmt" - "slices" "strconv" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" @@ -46,9 +44,7 @@ func mapDataSourceFields(userResp *sqlserverflexbeta.GetUserResponse, model *dat model.Roles = types.List(types.SetNull(types.StringType)) } else { var roles []attr.Value - resRoles := *user.Roles - slices.Sort(resRoles) - for _, role := range resRoles { + for _, role := range *user.Roles { roles = append(roles, types.StringValue(string(role))) } rolesSet, diags := types.SetValue(types.StringType, roles) @@ -94,20 +90,16 @@ func mapFields(userResp *sqlserverflexbeta.GetUserResponse, model *resourceModel model.Username = types.StringPointerValue(user.Username) // Map roles - if userResp.Roles != nil { - resRoles := *userResp.Roles - slices.Sort(resRoles) - + if user.Roles != nil { var roles []attr.Value - for _, role := range resRoles { + for _, role := range *user.Roles { roles = append(roles, types.StringValue(string(role))) } - - rolesSet, diags := types.ListValue(types.StringType, roles) + rolesSet, diags := types.SetValue(types.StringType, roles) if diags.HasError() { return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags)) } - model.Roles = rolesSet + model.Roles = types.List(rolesSet) } // Ensure roles is not null @@ -146,18 +138,15 @@ func mapFieldsCreate(userResp *sqlserverflexbeta.CreateUserResponse, model *reso model.Password = types.StringValue(*user.Password) if user.Roles != nil { - resRoles := *user.Roles - slices.Sort(resRoles) - var roles []attr.Value - for _, role := range resRoles { + for _, role := range *user.Roles { roles = append(roles, types.StringValue(string(role))) } - rolesList, diags := types.ListValue(types.StringType, roles) + rolesSet, diags := types.SetValue(types.StringType, roles) if diags.HasError() { return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags)) } - model.Roles = rolesList + model.Roles = types.List(rolesSet) } if model.Roles.IsNull() || model.Roles.IsUnknown() { @@ -185,14 +174,9 @@ func toCreatePayload( return nil, fmt.Errorf("nil model") } - pl := sqlserverflexbeta.CreateUserRequestPayload{ - Username: conversion.StringValueToPointer(model.Username), - Roles: &roles, - } - slices.Sort(roles) - if !model.DefaultDatabase.IsNull() || !model.DefaultDatabase.IsUnknown() { - pl.DefaultDatabase = conversion.StringValueToPointer(model.DefaultDatabase) - } - - return &pl, nil + return &sqlserverflexbeta.CreateUserRequestPayload{ + Username: conversion.StringValueToPointer(model.Username), + DefaultDatabase: conversion.StringValueToPointer(model.DefaultDatabase), + Roles: &roles, + }, nil } diff --git a/stackit/internal/services/sqlserverflexbeta/user/mapper_test.go b/stackit/internal/services/sqlserverflexbeta/user/mapper_test.go index c0e09bda..7b23805c 100644 --- a/stackit/internal/services/sqlserverflexbeta/user/mapper_test.go +++ b/stackit/internal/services/sqlserverflexbeta/user/mapper_test.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/utils" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" ) @@ -42,6 +41,7 @@ func TestMapDataSourceFields(t *testing.T) { { "simple_values", &sqlserverflexbeta.GetUserResponse{ + Roles: &[]string{ "role_1", "role_2", @@ -63,9 +63,9 @@ func TestMapDataSourceFields(t *testing.T) { Roles: types.List( types.SetValueMust( types.StringType, []attr.Value{ - types.StringValue(""), types.StringValue("role_1"), types.StringValue("role_2"), + types.StringValue(""), }, ), ), @@ -138,7 +138,7 @@ func TestMapDataSourceFields(t *testing.T) { t.Fatalf("Should not have failed: %v", err) } if tt.isValid { - diff := cmp.Diff(&tt.expected, state) + diff := cmp.Diff(state, &tt.expected) if diff != "" { t.Fatalf("Data does not match: %s", diff) } @@ -204,9 +204,9 @@ func TestMapFieldsCreate(t *testing.T) { Roles: types.List( types.SetValueMust( types.StringType, []attr.Value{ - types.StringValue(""), types.StringValue("role_1"), types.StringValue("role_2"), + types.StringValue(""), }, ), ), @@ -292,7 +292,7 @@ func TestMapFieldsCreate(t *testing.T) { t.Fatalf("Should not have failed: %v", err) } if tt.isValid { - diff := cmp.Diff(&tt.expected, state) + diff := cmp.Diff(state, &tt.expected) if diff != "" { t.Fatalf("Data does not match: %s", diff) } @@ -332,8 +332,8 @@ func TestMapFields(t *testing.T) { "simple_values", &sqlserverflexbeta.GetUserResponse{ Roles: &[]string{ - "role_2", "role_1", + "role_2", "", }, Username: utils.Ptr("username"), @@ -350,9 +350,9 @@ func TestMapFields(t *testing.T) { Roles: types.List( types.SetValueMust( types.StringType, []attr.Value{ - types.StringValue(""), types.StringValue("role_1"), types.StringValue("role_2"), + types.StringValue(""), }, ), ), @@ -423,7 +423,7 @@ func TestMapFields(t *testing.T) { t.Fatalf("Should not have failed: %v", err) } if tt.isValid { - diff := cmp.Diff(&tt.expected, state) + diff := cmp.Diff(state, &tt.expected) if diff != "" { t.Fatalf("Data does not match: %s", diff) } diff --git a/stackit/internal/services/sqlserverflexbeta/user/planModifiers.yaml b/stackit/internal/services/sqlserverflexbeta/user/planModifiers.yaml index 43b029e8..8ff346ab 100644 --- a/stackit/internal/services/sqlserverflexbeta/user/planModifiers.yaml +++ b/stackit/internal/services/sqlserverflexbeta/user/planModifiers.yaml @@ -2,7 +2,6 @@ fields: - name: 'id' modifiers: - 'UseStateForUnknown' - - 'RequiresReplace' - name: 'instance_id' validators: @@ -23,7 +22,6 @@ fields: - name: 'region' modifiers: - 'RequiresReplace' - - 'RequiresReplace' - name: 'user_id' modifiers: @@ -33,12 +31,10 @@ fields: - name: 'username' modifiers: - 'UseStateForUnknown' - - 'RequiresReplace' - name: 'roles' modifiers: - 'UseStateForUnknown' - - 'RequiresReplace' - name: 'password' modifiers: diff --git a/stackit/internal/services/sqlserverflexbeta/user/resource.go b/stackit/internal/services/sqlserverflexbeta/user/resource.go index efaf3fc1..a31c380b 100644 --- a/stackit/internal/services/sqlserverflexbeta/user/resource.go +++ b/stackit/internal/services/sqlserverflexbeta/user/resource.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "net/http" - "slices" "strconv" "strings" "time" @@ -17,9 +16,9 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion" + sqlserverflexbetagen "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user/resources_gen" sqlserverflexbetaUtils "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/utils" sqlserverflexbetaWait "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/wait/sqlserverflexbeta" @@ -30,12 +29,11 @@ import ( ) var ( - _ resource.Resource = &userResource{} - _ resource.ResourceWithConfigure = &userResource{} - _ resource.ResourceWithImportState = &userResource{} - _ resource.ResourceWithModifyPlan = &userResource{} - _ resource.ResourceWithIdentity = &userResource{} - _ resource.ResourceWithValidateConfig = &userResource{} + _ resource.Resource = &userResource{} + _ resource.ResourceWithConfigure = &userResource{} + _ resource.ResourceWithImportState = &userResource{} + _ resource.ResourceWithModifyPlan = &userResource{} + _ resource.ResourceWithIdentity = &userResource{} ) func NewUserResource() resource.Resource { @@ -58,7 +56,7 @@ type userResource struct { providerData core.ProviderData } -func (r *userResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { +func (r *userResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_sqlserverflexbeta_user" } @@ -106,26 +104,6 @@ func (r *userResource) ModifyPlan( return } - //// TODO: verify if this is needed - START - // var planRoles []string - // diags := planModel.Roles.ElementsAs(ctx, &planRoles, false) - // resp.Diagnostics.Append(diags...) - // if diags.HasError() { - // return - //} - // slices.Sort(planRoles) - // var roles []attr.Value - // for _, role := range planRoles { - // roles = append(roles, types.StringValue(string(role))) - //} - // rolesSet, diags := types.ListValue(types.StringType, roles) - // resp.Diagnostics.Append(diags...) - // if diags.HasError() { - // return - //} - // planModel.Roles = rolesSet - //// TODO: verify if this is needed - END - resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...) if resp.Diagnostics.HasError() { return @@ -137,7 +115,7 @@ var modifiersFileByte []byte // Schema defines the schema for the resource. func (r *userResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - s := sqlserverflexbetaResGen.UserResourceSchema(ctx) + s := sqlserverflexbetagen.UserResourceSchema(ctx) fields, err := utils.ReadModifiersConfig(modifiersFileByte) if err != nil { @@ -177,39 +155,6 @@ func (r *userResource) IdentitySchema( } } -func (r *userResource) ValidateConfig( - ctx context.Context, - req resource.ValidateConfigRequest, - resp *resource.ValidateConfigResponse, -) { - var data resourceModel - - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - if resp.Diagnostics.HasError() { - return - } - - var roles []string - diags := data.Roles.ElementsAs(ctx, &roles, false) - resp.Diagnostics.Append(diags...) - if diags.HasError() { - return - } - - var resRoles []string - for _, role := range roles { - if slices.Contains(resRoles, role) { - resp.Diagnostics.AddAttributeError( - path.Root("roles"), - "Attribute Configuration Error", - "defined roles MUST NOT contain duplicates", - ) - return - } - resRoles = append(resRoles, role) - } -} - // Create creates the resource and sets the initial Terraform state. func (r *userResource) Create( ctx context.Context, @@ -240,7 +185,6 @@ func (r *userResource) Create( if resp.Diagnostics.HasError() { return } - slices.Sort(roles) } // Generate API request body from model @@ -434,12 +378,7 @@ func (r *userResource) Update( resp *resource.UpdateResponse, ) { // nolint:gocritic // function signature required by Terraform // Update shouldn't be called - core.LogAndAddError( - ctx, - &resp.Diagnostics, - "Error updating user", - "an SQL server user can not be updated, only created", - ) + core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating user", "User can't be updated") } // Delete deletes the resource and removes the Terraform state on success. @@ -493,6 +432,7 @@ func (r *userResource) Delete( // Delete existing record set _, err = sqlserverflexbetaWait.DeleteUserWaitHandler(ctx, r.client, projectId, region, instanceId, userId). WaitWithContext(ctx) + //err := r.client.DeleteUserRequest(ctx, arg.projectId, arg.region, arg.instanceId, userId).Execute() if err != nil { core.LogAndAddError(ctx, &resp.Diagnostics, "User Delete Error", fmt.Sprintf("Calling API: %v", err)) return @@ -512,9 +452,11 @@ func (r *userResource) ImportState( req resource.ImportStateRequest, resp *resource.ImportStateResponse, ) { + ctx = core.InitProviderContext(ctx) if req.ID != "" { + idParts := strings.Split(req.ID, core.Separator) if len(idParts) != 4 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" || idParts[3] == "" { @@ -545,7 +487,7 @@ func (r *userResource) ImportState( resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[2])...) resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("user_id"), userId)...) - tflog.Info(ctx, "SQLServer Flex user state imported") + tflog.Info(ctx, "Postgres Flex user state imported") return } diff --git a/stackit/internal/services/sqlserverflexbeta/utils/util.go b/stackit/internal/services/sqlserverflexbeta/utils/util.go index d8ba984b..df638d8c 100644 --- a/stackit/internal/services/sqlserverflexbeta/utils/util.go +++ b/stackit/internal/services/sqlserverflexbeta/utils/util.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/stackitcloud/stackit-sdk-go/core/config" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" ) diff --git a/stackit/internal/services/sqlserverflexbeta/utils/util_test.go b/stackit/internal/services/sqlserverflexbeta/utils/util_test.go index 92fb1ae9..08ac1974 100644 --- a/stackit/internal/services/sqlserverflexbeta/utils/util_test.go +++ b/stackit/internal/services/sqlserverflexbeta/utils/util_test.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" sdkClients "github.com/stackitcloud/stackit-sdk-go/core/clients" "github.com/stackitcloud/stackit-sdk-go/core/config" - sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" diff --git a/stackit/internal/utils/attributes.go b/stackit/internal/utils/attributes.go index 26d228c3..6e3ec386 100644 --- a/stackit/internal/utils/attributes.go +++ b/stackit/internal/utils/attributes.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/types" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" ) diff --git a/stackit/internal/utils/regions.go b/stackit/internal/utils/regions.go index 70f79620..5c06ca1b 100644 --- a/stackit/internal/utils/regions.go +++ b/stackit/internal/utils/regions.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" ) diff --git a/stackit/internal/utils/utils.go b/stackit/internal/utils/utils.go index 8ca4984d..fbf5cb6e 100644 --- a/stackit/internal/utils/utils.go +++ b/stackit/internal/utils/utils.go @@ -20,7 +20,6 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" "github.com/stackitcloud/stackit-sdk-go/core/utils" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" ) diff --git a/stackit/internal/validate/validate.go b/stackit/internal/validate/validate.go index d118ac52..07d137ae 100644 --- a/stackit/internal/validate/validate.go +++ b/stackit/internal/validate/validate.go @@ -18,7 +18,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/teambition/rrule-go" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils" ) diff --git a/stackit/internal/wait/postgresflexalpha/wait.go b/stackit/internal/wait/postgresflexalpha/wait.go index 4aea71e8..8c8b80b3 100644 --- a/stackit/internal/wait/postgresflexalpha/wait.go +++ b/stackit/internal/wait/postgresflexalpha/wait.go @@ -9,7 +9,6 @@ import ( "time" "github.com/hashicorp/terraform-plugin-log/tflog" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" @@ -107,8 +106,8 @@ func CreateInstanceWaitHandler( ), ) if extendedTimeout < 3 { - maxWait += time.Minute * 5 - extendedTimeout++ + maxWait = maxWait + time.Minute*5 + extendedTimeout = extendedTimeout + 1 if *s.Network.AccessScope == "SNA" { ready := true if s.Network == nil || s.Network.InstanceAddress == nil { @@ -163,7 +162,6 @@ func CreateInstanceWaitHandler( if !ok { return false, nil, err } - // TODO: refactor and cooperate with api guys to mitigate if oapiErr.StatusCode < 500 { return true, instanceGetResponse, fmt.Errorf( "users request after instance creation returned %d status code", @@ -208,7 +206,7 @@ func PartialUpdateInstanceWaitHandler( case InstanceStateUnknown: return false, nil, nil case InstanceStateFailed: - return true, s, fmt.Errorf("update got status FAILURE for instance with id %s", instanceId) + return true, s, fmt.Errorf("update failed for instance with id %s", instanceId) } }, ) @@ -228,7 +226,7 @@ func GetUserByIdWaitHandler( if userId > math.MaxInt32 { return false, nil, fmt.Errorf("userId value is too big for int32") } - userId32 := int32(userId) //nolint:gosec // we need to convert databaseId to int32 because API expects int32 + userId32 := int32(userId) s, err := a.GetUserRequestExecute(ctx, projectId, region, instanceId, userId32) if err != nil { var oapiErr *oapierror.GenericOpenAPIError @@ -236,18 +234,10 @@ func GetUserByIdWaitHandler( if !ok { return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError") } - switch oapiErr.StatusCode { - case http.StatusBadGateway, http.StatusGatewayTimeout, http.StatusServiceUnavailable: - case http.StatusNotFound: - tflog.Warn( - ctx, "api responded with status", map[string]interface{}{ - "status": oapiErr.StatusCode, - }, - ) - return false, nil, nil - default: + if oapiErr.StatusCode != http.StatusNotFound { return false, nil, err } + return false, nil, nil } return true, s, nil }, @@ -264,7 +254,7 @@ func GetDatabaseByIdWaitHandler( ) *wait.AsyncActionHandler[postgresflex.GetDatabaseResponse] { handler := wait.New( func() (waitFinished bool, response *postgresflex.GetDatabaseResponse, err error) { - dbId32 := int32(databaseId) //nolint:gosec // we need to convert databaseId to int32 because API expects int32 + dbId32 := int32(databaseId) s, err := a.GetDatabaseRequestExecute(ctx, projectId, region, instanceId, dbId32) if err != nil { var oapiErr *oapierror.GenericOpenAPIError @@ -272,24 +262,10 @@ func GetDatabaseByIdWaitHandler( if !ok { return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError") } - switch oapiErr.StatusCode { - case http.StatusBadGateway, http.StatusGatewayTimeout, http.StatusServiceUnavailable: - tflog.Warn( - ctx, "api responded with 50[2,3,4] status", map[string]interface{}{ - "status": oapiErr.StatusCode, - }, - ) - return false, nil, nil - case http.StatusNotFound: - tflog.Warn( - ctx, "api responded with 404 status", map[string]interface{}{ - "status": oapiErr.StatusCode, - }, - ) - return false, nil, nil - default: + if oapiErr.StatusCode != http.StatusNotFound { return false, nil, err } + return false, nil, nil } return true, s, nil }, diff --git a/stackit/internal/wait/postgresflexalpha/wait_test.go b/stackit/internal/wait/postgresflexalpha/wait_test.go index 57d36175..e9583d14 100644 --- a/stackit/internal/wait/postgresflexalpha/wait_test.go +++ b/stackit/internal/wait/postgresflexalpha/wait_test.go @@ -10,7 +10,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" "github.com/stackitcloud/stackit-sdk-go/core/utils" - postgresflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" ) diff --git a/stackit/internal/wait/sqlserverflexalpha/wait.go b/stackit/internal/wait/sqlserverflexalpha/wait.go index 712347d1..542b06cb 100644 --- a/stackit/internal/wait/sqlserverflexalpha/wait.go +++ b/stackit/internal/wait/sqlserverflexalpha/wait.go @@ -1,3 +1,5 @@ +// Copyright (c) STACKIT + package sqlserverflexalpha import ( @@ -11,7 +13,6 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" "github.com/stackitcloud/stackit-sdk-go/core/wait" - sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" ) @@ -26,366 +27,144 @@ const ( InstanceStateTerminating = "TERMINATING" ) -// APIClientInterface Interface needed for tests -type APIClientInterface interface { - GetInstanceRequestExecute( - ctx context.Context, - projectId, region, instanceId string, - ) (*sqlserverflex.GetInstanceResponse, error) - GetDatabaseRequestExecute( - ctx context.Context, - projectId string, - region string, - instanceId string, - databaseName string, - ) (*sqlserverflex.GetDatabaseResponse, error) - GetUserRequestExecute( - ctx context.Context, - projectId string, - region string, - instanceId string, - userId int64, - ) (*sqlserverflex.GetUserResponse, error) - - ListRolesRequestExecute( - ctx context.Context, - projectId string, - region string, - instanceId string, - ) (*sqlserverflex.ListRolesResponse, error) - - ListUsersRequest( - ctx context.Context, - projectId string, - region string, - instanceId string, - ) sqlserverflex.ApiListUsersRequestRequest - - ListUsersRequestExecute( - ctx context.Context, - projectId string, - region string, - instanceId string, - ) (*sqlserverflex.ListUserResponse, error) +// APIClientInstanceInterface Interface needed for tests +type APIClientInstanceInterface interface { + GetInstanceRequestExecute(ctx context.Context, projectId, region, instanceId string) (*sqlserverflex.GetInstanceResponse, error) } // APIClientUserInterface Interface needed for tests type APIClientUserInterface interface { - DeleteUserRequestExecute( - ctx context.Context, - projectId string, - region string, - instanceId string, - userId int64, - ) error + DeleteUserRequestExecute(ctx context.Context, projectId string, region string, instanceId string, userId int64) error } // CreateInstanceWaitHandler will wait for instance creation -func CreateInstanceWaitHandler( - ctx context.Context, - a APIClientInterface, - projectId, instanceId, region string, -) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] { - handler := wait.New( - func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) { - s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId) - if err != nil { - return false, nil, err - } - if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil { - return false, nil, nil - } - switch strings.ToLower(string(*s.Status)) { - case strings.ToLower(InstanceStateSuccess): - if s.Network != nil && s.Network.AccessScope != nil && *s.Network.AccessScope == "SNA" { - if s.Network.InstanceAddress == nil { - tflog.Info(ctx, "Waiting for instance_address") - return false, nil, nil - } - if s.Network.RouterAddress == nil { - tflog.Info(ctx, "Waiting for router_address") - return false, nil, nil - } - } - - tflog.Info(ctx, "trying to get roles") - time.Sleep(10 * time.Second) - _, rolesErr := a.ListRolesRequestExecute(ctx, projectId, region, instanceId) - if rolesErr != nil { - var oapiErr *oapierror.GenericOpenAPIError - ok := errors.As(rolesErr, &oapiErr) - if !ok { - return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError") - } - if oapiErr.StatusCode != http.StatusInternalServerError { - tflog.Info( - ctx, "got error from api", map[string]interface{}{ - "error": rolesErr.Error(), - }, - ) - return false, nil, rolesErr - } - tflog.Info( - ctx, "wait for get-roles to work hack", map[string]interface{}{}, - ) - time.Sleep(10 * time.Second) +func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] { + handler := wait.New(func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) { + s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId) + if err != nil { + return false, nil, err + } + if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil { + return false, nil, nil + } + switch strings.ToLower(string(*s.Status)) { + case strings.ToLower(InstanceStateSuccess): + if *s.Network.AccessScope == "SNA" { + if s.Network.InstanceAddress == nil { + tflog.Info(ctx, "Waiting for instance_address") return false, nil, nil } - - tflog.Info(ctx, "trying to get users") - time.Sleep(10 * time.Second) - _, usersErr := a.ListUsersRequestExecute(ctx, projectId, region, instanceId) - if usersErr != nil { - var oapiErr *oapierror.GenericOpenAPIError - ok := errors.As(usersErr, &oapiErr) - if !ok { - return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError") - } - if oapiErr.StatusCode != http.StatusInternalServerError { - tflog.Info( - ctx, "got error from api", map[string]interface{}{ - "error": rolesErr.Error(), - }, - ) - return false, nil, usersErr - } - tflog.Info( - ctx, "wait for get-users to work hack", map[string]interface{}{}, - ) - time.Sleep(10 * time.Second) + if s.Network.RouterAddress == nil { + tflog.Info(ctx, "Waiting for router_address") return false, nil, nil } - return true, s, nil - case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed): - return true, nil, fmt.Errorf("create failed for instance with id %s", instanceId) - case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing): - tflog.Info( - ctx, "request is being handled", map[string]interface{}{ - "status": *s.Status, - }, - ) - time.Sleep(10 * time.Second) - return false, nil, nil - default: - tflog.Info( - ctx, "Wait (create) received unknown status", map[string]interface{}{ - "instanceId": instanceId, - "status": s.Status, - }, - ) - return true, nil, errors.New("unknown status received") } - }, - ) + return true, s, nil + case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed): + return true, s, fmt.Errorf("create failed for instance with id %s", instanceId) + case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing): + tflog.Info(ctx, "request is being handled", map[string]interface{}{ + "status": *s.Status, + }) + return false, nil, nil + default: + tflog.Info(ctx, "Wait (create) received unknown status", map[string]interface{}{ + "instanceId": instanceId, + "status": s.Status, + }) + return false, s, nil + } + }) return handler } // UpdateInstanceWaitHandler will wait for instance update -func UpdateInstanceWaitHandler( - ctx context.Context, - a APIClientInterface, - projectId, instanceId, region string, -) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] { - handler := wait.New( - func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) { - s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId) - if err != nil { - return false, nil, err - } - if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil { - return false, nil, nil - } - switch strings.ToLower(string(*s.Status)) { - case strings.ToLower(InstanceStateSuccess): - return true, s, nil - case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed): - return true, s, fmt.Errorf("update failed for instance with id %s", instanceId) - case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing): - tflog.Info( - ctx, "request is being handled", map[string]interface{}{ - "status": *s.Status, - }, - ) - return false, s, nil - default: - tflog.Info( - ctx, "Wait (update) received unknown status", map[string]interface{}{ - "instanceId": instanceId, - "status": s.Status, - }, - ) - return false, s, nil - } - }, - ) +func UpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] { + handler := wait.New(func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) { + s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId) + if err != nil { + return false, nil, err + } + if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil { + return false, nil, nil + } + switch strings.ToLower(string(*s.Status)) { + case strings.ToLower(InstanceStateSuccess): + return true, s, nil + case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed): + return true, s, fmt.Errorf("update failed for instance with id %s", instanceId) + case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing): + tflog.Info(ctx, "request is being handled", map[string]interface{}{ + "status": *s.Status, + }) + return false, nil, nil + default: + tflog.Info(ctx, "Wait (update) received unknown status", map[string]interface{}{ + "instanceId": instanceId, + "status": s.Status, + }) + return false, s, nil + } + }) + handler.SetSleepBeforeWait(15 * time.Second) + handler.SetTimeout(45 * time.Minute) return handler } +// PartialUpdateInstanceWaitHandler will wait for instance update +func PartialUpdateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] { + return UpdateInstanceWaitHandler(ctx, a, projectId, instanceId, region) +} + // DeleteInstanceWaitHandler will wait for instance deletion -func DeleteInstanceWaitHandler( - ctx context.Context, - a APIClientInterface, - projectId, instanceId, region string, -) *wait.AsyncActionHandler[sqlserverflex.GetInstanceResponse] { - handler := wait.New( - func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) { - s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId) - if err == nil { - return false, s, nil - } - var oapiErr *oapierror.GenericOpenAPIError - ok := errors.As(err, &oapiErr) - if !ok { - return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError") - } - if oapiErr.StatusCode != http.StatusNotFound { - return false, nil, err - } - return true, nil, nil - }, - ) - handler.SetTimeout(30 * time.Minute) - return handler -} - -// CreateDatabaseWaitHandler will wait for instance creation -func CreateDatabaseWaitHandler( - ctx context.Context, - a APIClientInterface, - projectId, instanceId, region, databaseName string, -) *wait.AsyncActionHandler[sqlserverflex.GetDatabaseResponse] { - handler := wait.New( - func() (waitFinished bool, response *sqlserverflex.GetDatabaseResponse, err error) { - s, err := a.GetDatabaseRequestExecute(ctx, projectId, region, instanceId, databaseName) - if err != nil { - var oapiErr *oapierror.GenericOpenAPIError - ok := errors.As(err, &oapiErr) - if !ok { - return false, nil, fmt.Errorf( - "get database - could not convert error to oapierror.GenericOpenAPIError: %s", - err.Error(), - ) - } - if oapiErr.StatusCode != http.StatusNotFound { - return false, nil, err - } - return false, nil, nil - } - if s == nil || s.Name == nil || *s.Name != databaseName { - return false, nil, errors.New("response did return different result") - } - return true, s, nil - }, - ) - return handler -} - -// CreateUserWaitHandler will wait for instance creation -func CreateUserWaitHandler( - ctx context.Context, - a APIClientInterface, - projectId, instanceId, region string, - userId int64, -) *wait.AsyncActionHandler[sqlserverflex.GetUserResponse] { - handler := wait.New( - func() (waitFinished bool, response *sqlserverflex.GetUserResponse, err error) { - s, err := a.GetUserRequestExecute(ctx, projectId, region, instanceId, userId) - if err != nil { - var oapiErr *oapierror.GenericOpenAPIError - ok := errors.As(err, &oapiErr) - if !ok { - return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError") - } - if oapiErr.StatusCode != http.StatusNotFound { - return false, nil, err - } - return false, nil, nil - } - return true, s, nil - }, - ) - return handler -} - -// WaitForUserWaitHandler will wait for instance creation -func WaitForUserWaitHandler( - ctx context.Context, - a APIClientInterface, - projectId, instanceId, region, userName string, -) *wait.AsyncActionHandler[sqlserverflex.ListUserResponse] { - startTime := time.Now() - timeOut := 2 * time.Minute - - handler := wait.New( - func() (waitFinished bool, response *sqlserverflex.ListUserResponse, err error) { - if time.Since(startTime) > timeOut { - return false, nil, errors.New("ran into timeout") - } - s, err := a.ListUsersRequest(ctx, projectId, region, instanceId).Size(100).Execute() - if err != nil { - var oapiErr *oapierror.GenericOpenAPIError - ok := errors.As(err, &oapiErr) - if !ok { - return false, nil, fmt.Errorf( - "wait (list users) could not convert error to oapierror.GenericOpenAPIError: %s", - err.Error(), - ) - } - if oapiErr.StatusCode != http.StatusNotFound { - return false, nil, err - } - tflog.Info( - ctx, "Wait (list users) still waiting", map[string]interface{}{}, - ) - - return false, nil, nil - } - users, ok := s.GetUsersOk() - if !ok { - return false, nil, errors.New("no users found") - } - - for _, u := range users { - if u.GetUsername() == userName { - return true, s, nil - } - } - tflog.Info( - ctx, "Wait (list users) user still not present", map[string]interface{}{}, - ) +func DeleteInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface, projectId, instanceId, region string) *wait.AsyncActionHandler[struct{}] { + handler := wait.New(func() (waitFinished bool, response *struct{}, err error) { + _, err = a.GetInstanceRequestExecute(ctx, projectId, region, instanceId) + if err == nil { return false, nil, nil - }, - ) + } + var oapiErr *oapierror.GenericOpenAPIError + ok := errors.As(err, &oapiErr) + if !ok { + return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError") + } + if oapiErr.StatusCode != http.StatusNotFound { + return false, nil, err + } + return true, nil, nil + }) + handler.SetTimeout(15 * time.Minute) return handler } // DeleteUserWaitHandler will wait for instance deletion func DeleteUserWaitHandler( ctx context.Context, - a APIClientInterface, - projectId, region, instanceId string, + a APIClientUserInterface, + projectId, instanceId, region string, userId int64, ) *wait.AsyncActionHandler[struct{}] { - handler := wait.New( - func() (waitFinished bool, response *struct{}, err error) { - _, err = a.GetUserRequestExecute(ctx, projectId, region, instanceId, userId) - if err == nil { - return false, nil, nil - } - var oapiErr *oapierror.GenericOpenAPIError - ok := errors.As(err, &oapiErr) - if !ok { - return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError") - } + handler := wait.New(func() (waitFinished bool, response *struct{}, err error) { + err = a.DeleteUserRequestExecute(ctx, projectId, region, instanceId, userId) + if err == nil { + return false, nil, nil + } + var oapiErr *oapierror.GenericOpenAPIError + ok := errors.As(err, &oapiErr) + if !ok { + return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError") + } - switch oapiErr.StatusCode { - case http.StatusNotFound: - return true, nil, nil - default: - return false, nil, err - } - }, - ) + switch oapiErr.StatusCode { + case http.StatusNotFound: + return true, nil, nil + case http.StatusInternalServerError: + tflog.Warn(ctx, "Wait handler got error 500") + return false, nil, nil + default: + return false, nil, err + } + }) handler.SetTimeout(15 * time.Minute) handler.SetSleepBeforeWait(15 * time.Second) return handler diff --git a/stackit/internal/wait/sqlserverflexalpha/wait_test.go b/stackit/internal/wait/sqlserverflexalpha/wait_test.go index ca84ad1e..7c0e52a9 100644 --- a/stackit/internal/wait/sqlserverflexalpha/wait_test.go +++ b/stackit/internal/wait/sqlserverflexalpha/wait_test.go @@ -1,15 +1,15 @@ +// Copyright (c) STACKIT + package sqlserverflexalpha import ( "context" - "reflect" "testing" "time" "github.com/google/go-cmp/cmp" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" "github.com/stackitcloud/stackit-sdk-go/core/utils" - sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha" ) @@ -22,81 +22,7 @@ type apiClientInstanceMocked struct { instanceGetFails bool } -type ListUsersRequestRequest struct{} - -func (l ListUsersRequestRequest) Page(_ int64) sqlserverflex.ApiListUsersRequestRequest { - return l -} - -func (l ListUsersRequestRequest) Size(_ int64) sqlserverflex.ApiListUsersRequestRequest { - return l -} - -func (l ListUsersRequestRequest) Sort(_ sqlserverflex.UserSort) sqlserverflex.ApiListUsersRequestRequest { - return l -} - -func (l ListUsersRequestRequest) Execute() (*sqlserverflex.ListUserResponse, error) { - // TODO implement me - panic("implement me") -} - -func (a *apiClientInstanceMocked) ListUsersRequest( - _ context.Context, - _ string, - _ string, - _ string, -) sqlserverflex.ApiListUsersRequestRequest { - return ListUsersRequestRequest{} -} - -func (a *apiClientInstanceMocked) ListRolesRequestExecute( - _ context.Context, - _ string, - _ string, - _ string, -) (*sqlserverflex.ListRolesResponse, error) { - return &sqlserverflex.ListRolesResponse{ - Roles: &[]string{}, - }, nil -} - -func (a *apiClientInstanceMocked) ListUsersRequestExecute( - _ context.Context, - _ string, - _ string, - _ string, -) (*sqlserverflex.ListUserResponse, error) { - return &sqlserverflex.ListUserResponse{ - Pagination: nil, - Users: nil, - }, nil -} - -func (a *apiClientInstanceMocked) GetDatabaseRequestExecute( - _ context.Context, - _ string, - _ string, - _ string, - _ string, -) (*sqlserverflex.GetDatabaseResponse, error) { - return nil, nil -} - -func (a *apiClientInstanceMocked) GetUserRequestExecute( - _ context.Context, - _ string, - _ string, - _ string, - _ int64, -) (*sqlserverflex.GetUserResponse, error) { - return nil, nil -} - -func (a *apiClientInstanceMocked) GetInstanceRequestExecute( - _ context.Context, - _, _, _ string, -) (*sqlserverflex.GetInstanceResponse, error) { +func (a *apiClientInstanceMocked) GetInstanceRequestExecute(_ context.Context, _, _, _ string) (*sqlserverflex.GetInstanceResponse, error) { if a.instanceGetFails { return nil, &oapierror.GenericOpenAPIError{ StatusCode: 500, @@ -116,10 +42,9 @@ func (a *apiClientInstanceMocked) GetInstanceRequestExecute( }, nil } func TestCreateInstanceWaitHandler(t *testing.T) { - instanceId := utils.Ptr("foo") + t.Skip("skipping - needs refactoring") tests := []struct { desc string - instanceId string instanceGetFails bool instanceState string instanceNetwork sqlserverflex.InstanceNetwork @@ -127,42 +52,40 @@ func TestCreateInstanceWaitHandler(t *testing.T) { wantErr bool wantRes *sqlserverflex.GetInstanceResponse }{ - //{ - // desc: "create_succeeded", - // instanceId: *instanceId, - // instanceGetFails: false, - // instanceState: *stateSuccess, - // instanceNetwork: sqlserverflex.InstanceNetwork{ - // AccessScope: nil, - // Acl: nil, - // InstanceAddress: utils.Ptr("10.0.0.1"), - // RouterAddress: utils.Ptr("10.0.0.2"), - // }, - // wantErr: false, - // wantRes: &sqlserverflex.GetInstanceResponse{ - // BackupSchedule: nil, - // Edition: nil, - // Encryption: nil, - // FlavorId: nil, - // Id: instanceId, - // IsDeletable: nil, - // Name: nil, - // Network: &sqlserverflex.InstanceNetwork{ - // AccessScope: nil, - // Acl: nil, - // InstanceAddress: utils.Ptr("10.0.0.1"), - // RouterAddress: utils.Ptr("10.0.0.2"), - // }, - // Replicas: nil, - // RetentionDays: nil, - // Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(stateSuccess), - // Storage: nil, - // Version: nil, - // }, - // }, + { + desc: "create_succeeded", + instanceGetFails: false, + instanceState: InstanceStateSuccess, + instanceNetwork: sqlserverflex.InstanceNetwork{ + AccessScope: nil, + Acl: nil, + InstanceAddress: utils.Ptr("10.0.0.1"), + RouterAddress: utils.Ptr("10.0.0.2"), + }, + wantErr: false, + wantRes: &sqlserverflex.GetInstanceResponse{ + BackupSchedule: nil, + Edition: nil, + Encryption: nil, + FlavorId: nil, + Id: nil, + IsDeletable: nil, + Name: nil, + Network: &sqlserverflex.InstanceNetwork{ + AccessScope: nil, + Acl: nil, + InstanceAddress: utils.Ptr("10.0.0.1"), + RouterAddress: utils.Ptr("10.0.0.2"), + }, + Replicas: nil, + RetentionDays: nil, + Status: nil, + Storage: nil, + Version: nil, + }, + }, { desc: "create_failed", - instanceId: *instanceId, instanceGetFails: false, instanceState: InstanceStateFailed, wantErr: true, @@ -170,7 +93,6 @@ func TestCreateInstanceWaitHandler(t *testing.T) { }, { desc: "create_failed_2", - instanceId: *instanceId, instanceGetFails: false, instanceState: InstanceStateEmpty, wantErr: true, @@ -178,14 +100,12 @@ func TestCreateInstanceWaitHandler(t *testing.T) { }, { desc: "instance_get_fails", - instanceId: *instanceId, instanceGetFails: true, wantErr: true, wantRes: nil, }, { desc: "timeout", - instanceId: *instanceId, instanceGetFails: false, instanceState: InstanceStateProcessing, wantErr: true, @@ -193,26 +113,26 @@ func TestCreateInstanceWaitHandler(t *testing.T) { }, } for _, tt := range tests { - t.Run( - tt.desc, func(t *testing.T) { - apiClient := &apiClientInstanceMocked{ - instanceId: tt.instanceId, - instanceState: tt.instanceState, - instanceGetFails: tt.instanceGetFails, - } + t.Run(tt.desc, func(t *testing.T) { + instanceId := "foo-bar" - handler := CreateInstanceWaitHandler(context.Background(), apiClient, "", tt.instanceId, "") + apiClient := &apiClientInstanceMocked{ + instanceId: instanceId, + instanceState: tt.instanceState, + instanceGetFails: tt.instanceGetFails, + } - gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background()) - if (err != nil) != tt.wantErr { - t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) - } + handler := CreateInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "") - if !reflect.DeepEqual(gotRes, tt.wantRes) { - t.Fatalf("handler gotRes = %v, want %v", gotRes, tt.wantRes) - } - }, - ) + gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background()) + if (err != nil) != tt.wantErr { + t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) + } + + if !cmp.Equal(gotRes, tt.wantRes) { + t.Fatalf("handler gotRes = %v, want %v", gotRes, tt.wantRes) + } + }) } } @@ -261,36 +181,34 @@ func TestUpdateInstanceWaitHandler(t *testing.T) { }, } for _, tt := range tests { - t.Run( - tt.desc, func(t *testing.T) { - instanceId := "foo-bar" + t.Run(tt.desc, func(t *testing.T) { + instanceId := "foo-bar" - apiClient := &apiClientInstanceMocked{ - instanceId: instanceId, - instanceState: tt.instanceState, - instanceGetFails: tt.instanceGetFails, + apiClient := &apiClientInstanceMocked{ + instanceId: instanceId, + instanceState: tt.instanceState, + instanceGetFails: tt.instanceGetFails, + } + + var wantRes *sqlserverflex.GetInstanceResponse + if tt.wantResp { + wantRes = &sqlserverflex.GetInstanceResponse{ + Id: &instanceId, + Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(tt.instanceState)), } + } - var wantRes *sqlserverflex.GetInstanceResponse - if tt.wantResp { - wantRes = &sqlserverflex.GetInstanceResponse{ - Id: &instanceId, - Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(utils.Ptr(tt.instanceState)), - } - } + handler := UpdateInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "") - handler := UpdateInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "") + gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background()) - gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background()) - - if (err != nil) != tt.wantErr { - t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) - } - if !cmp.Equal(gotRes, wantRes) { - t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes) - } - }, - ) + if (err != nil) != tt.wantErr { + t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) + } + if !cmp.Equal(gotRes, wantRes) { + t.Fatalf("handler gotRes = %v, want %v", gotRes, wantRes) + } + }) } } @@ -320,25 +238,23 @@ func TestDeleteInstanceWaitHandler(t *testing.T) { }, } for _, tt := range tests { - t.Run( - tt.desc, func(t *testing.T) { - instanceId := "foo-bar" + t.Run(tt.desc, func(t *testing.T) { + instanceId := "foo-bar" - apiClient := &apiClientInstanceMocked{ - instanceGetFails: tt.instanceGetFails, - instanceIsDeleted: tt.instanceState == InstanceStateSuccess, - instanceId: instanceId, - instanceState: tt.instanceState, - } + apiClient := &apiClientInstanceMocked{ + instanceGetFails: tt.instanceGetFails, + instanceIsDeleted: tt.instanceState == InstanceStateSuccess, + instanceId: instanceId, + instanceState: tt.instanceState, + } - handler := DeleteInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "") + handler := DeleteInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "") - _, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background()) + _, err := handler.SetTimeout(10 * time.Millisecond).WaitWithContext(context.Background()) - if (err != nil) != tt.wantErr { - t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) - } - }, - ) + if (err != nil) != tt.wantErr { + t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) + } + }) } } diff --git a/stackit/internal/wait/sqlserverflexbeta/wait.go b/stackit/internal/wait/sqlserverflexbeta/wait.go index 2660cac5..b6a5bfcd 100644 --- a/stackit/internal/wait/sqlserverflexbeta/wait.go +++ b/stackit/internal/wait/sqlserverflexbeta/wait.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" "github.com/stackitcloud/stackit-sdk-go/core/wait" - sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" ) @@ -54,12 +53,7 @@ type APIClientInterface interface { instanceId string, ) (*sqlserverflex.ListRolesResponse, error) - ListUsersRequest( - ctx context.Context, - projectId string, - region string, - instanceId string, - ) sqlserverflex.ApiListUsersRequestRequest + ListUsersRequest(ctx context.Context, projectId string, region string, instanceId string) sqlserverflex.ApiListUsersRequestRequest ListUsersRequestExecute( ctx context.Context, @@ -90,24 +84,14 @@ func CreateInstanceWaitHandler( func() (waitFinished bool, response *sqlserverflex.GetInstanceResponse, err error) { s, err := a.GetInstanceRequestExecute(ctx, projectId, region, instanceId) if err != nil { - var oapiErr *oapierror.GenericOpenAPIError - ok := errors.As(err, &oapiErr) - if !ok { - return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError: %w", err) - } - switch oapiErr.StatusCode { - case http.StatusNotFound: - return false, nil, nil - default: - return false, nil, fmt.Errorf("api error: %w", err) - } + return false, nil, err } if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil { return false, nil, nil } switch strings.ToLower(string(*s.Status)) { case strings.ToLower(InstanceStateSuccess): - if s.Network != nil && s.Network.AccessScope != nil && *s.Network.AccessScope == "SNA" { + if *s.Network.AccessScope == "SNA" { if s.Network.InstanceAddress == nil { tflog.Info(ctx, "Waiting for instance_address") return false, nil, nil @@ -166,18 +150,8 @@ func CreateInstanceWaitHandler( return false, nil, nil } return true, s, nil - case strings.ToLower(InstanceStateUnknown): - return true, nil, fmt.Errorf( - "create failed for instance %s with status %s", - instanceId, - InstanceStateUnknown, - ) - case strings.ToLower(InstanceStateFailed): - return true, nil, fmt.Errorf( - "create failed for instance %s with status %s", - instanceId, - InstanceStateFailed, - ) + case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed): + return true, s, fmt.Errorf("create failed for instance with id %s", instanceId) case strings.ToLower(InstanceStatePending), strings.ToLower(InstanceStateProcessing): tflog.Info( ctx, "request is being handled", map[string]interface{}{ @@ -193,7 +167,7 @@ func CreateInstanceWaitHandler( "status": s.Status, }, ) - return true, nil, errors.New("unknown status received") + return false, s, nil } }, ) @@ -281,10 +255,7 @@ func CreateDatabaseWaitHandler( var oapiErr *oapierror.GenericOpenAPIError ok := errors.As(err, &oapiErr) if !ok { - return false, nil, fmt.Errorf( - "get database - could not convert error to oapierror.GenericOpenAPIError: %s", - err.Error(), - ) + return false, nil, fmt.Errorf("get database - could not convert error to oapierror.GenericOpenAPIError: %s", err.Error()) } if oapiErr.StatusCode != http.StatusNotFound { return false, nil, err @@ -346,10 +317,7 @@ func WaitForUserWaitHandler( var oapiErr *oapierror.GenericOpenAPIError ok := errors.As(err, &oapiErr) if !ok { - return false, nil, fmt.Errorf( - "wait (list users) could not convert error to oapierror.GenericOpenAPIError: %s", - err.Error(), - ) + return false, nil, fmt.Errorf("Wait (list users) could not convert error to oapierror.GenericOpenAPIError: %s", err.Error()) } if oapiErr.StatusCode != http.StatusNotFound { return false, nil, err diff --git a/stackit/internal/wait/sqlserverflexbeta/wait_test.go b/stackit/internal/wait/sqlserverflexbeta/wait_test.go index 0d10abae..35b66cf6 100644 --- a/stackit/internal/wait/sqlserverflexbeta/wait_test.go +++ b/stackit/internal/wait/sqlserverflexbeta/wait_test.go @@ -2,14 +2,12 @@ package sqlserverflexbeta import ( "context" - "reflect" "testing" "time" "github.com/google/go-cmp/cmp" "github.com/stackitcloud/stackit-sdk-go/core/oapierror" "github.com/stackitcloud/stackit-sdk-go/core/utils" - sqlserverflex "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta" ) @@ -22,73 +20,22 @@ type apiClientInstanceMocked struct { instanceGetFails bool } -type ListUsersRequestRequest struct{} - -func (l ListUsersRequestRequest) Page(_ int64) sqlserverflex.ApiListUsersRequestRequest { - return l -} - -func (l ListUsersRequestRequest) Size(_ int64) sqlserverflex.ApiListUsersRequestRequest { - return l -} - -func (l ListUsersRequestRequest) Sort(_ sqlserverflex.UserSort) sqlserverflex.ApiListUsersRequestRequest { - return l -} - -func (l ListUsersRequestRequest) Execute() (*sqlserverflex.ListUserResponse, error) { - // TODO implement me - panic("implement me") -} - -func (a *apiClientInstanceMocked) ListUsersRequest( - _ context.Context, - _ string, - _ string, - _ string, -) sqlserverflex.ApiListUsersRequestRequest { - return ListUsersRequestRequest{} -} - -func (a *apiClientInstanceMocked) ListRolesRequestExecute( - _ context.Context, - _ string, - _ string, - _ string, -) (*sqlserverflex.ListRolesResponse, error) { - return &sqlserverflex.ListRolesResponse{ - Roles: &[]string{}, - }, nil -} - -func (a *apiClientInstanceMocked) ListUsersRequestExecute( - _ context.Context, - _ string, - _ string, - _ string, -) (*sqlserverflex.ListUserResponse, error) { - return &sqlserverflex.ListUserResponse{ - Pagination: nil, - Users: nil, - }, nil -} - func (a *apiClientInstanceMocked) GetDatabaseRequestExecute( _ context.Context, - _ string, - _ string, - _ string, - _ string, + projectId string, + region string, + instanceId string, + databaseName string, ) (*sqlserverflex.GetDatabaseResponse, error) { return nil, nil } func (a *apiClientInstanceMocked) GetUserRequestExecute( - _ context.Context, - _ string, - _ string, - _ string, - _ int64, + ctx context.Context, + projectId string, + region string, + instanceId string, + userId int64, ) (*sqlserverflex.GetUserResponse, error) { return nil, nil } @@ -116,10 +63,9 @@ func (a *apiClientInstanceMocked) GetInstanceRequestExecute( }, nil } func TestCreateInstanceWaitHandler(t *testing.T) { - instanceId := utils.Ptr("foo") + t.Skip("skipping - needs refactoring") tests := []struct { desc string - instanceId string instanceGetFails bool instanceState string instanceNetwork sqlserverflex.InstanceNetwork @@ -127,42 +73,40 @@ func TestCreateInstanceWaitHandler(t *testing.T) { wantErr bool wantRes *sqlserverflex.GetInstanceResponse }{ - //{ - // desc: "create_succeeded", - // instanceId: *instanceId, - // instanceGetFails: false, - // instanceState: *stateSuccess, - // instanceNetwork: sqlserverflex.InstanceNetwork{ - // AccessScope: nil, - // Acl: nil, - // InstanceAddress: utils.Ptr("10.0.0.1"), - // RouterAddress: utils.Ptr("10.0.0.2"), - // }, - // wantErr: false, - // wantRes: &sqlserverflex.GetInstanceResponse{ - // BackupSchedule: nil, - // Edition: nil, - // Encryption: nil, - // FlavorId: nil, - // Id: instanceId, - // IsDeletable: nil, - // Name: nil, - // Network: &sqlserverflex.InstanceNetwork{ - // AccessScope: nil, - // Acl: nil, - // InstanceAddress: utils.Ptr("10.0.0.1"), - // RouterAddress: utils.Ptr("10.0.0.2"), - // }, - // Replicas: nil, - // RetentionDays: nil, - // Status: sqlserverflex.GetInstanceResponseGetStatusAttributeType(stateSuccess), - // Storage: nil, - // Version: nil, - // }, - // }, + { + desc: "create_succeeded", + instanceGetFails: false, + instanceState: InstanceStateSuccess, + instanceNetwork: sqlserverflex.InstanceNetwork{ + AccessScope: nil, + Acl: nil, + InstanceAddress: utils.Ptr("10.0.0.1"), + RouterAddress: utils.Ptr("10.0.0.2"), + }, + wantErr: false, + wantRes: &sqlserverflex.GetInstanceResponse{ + BackupSchedule: nil, + Edition: nil, + Encryption: nil, + FlavorId: nil, + Id: nil, + IsDeletable: nil, + Name: nil, + Network: &sqlserverflex.InstanceNetwork{ + AccessScope: nil, + Acl: nil, + InstanceAddress: utils.Ptr("10.0.0.1"), + RouterAddress: utils.Ptr("10.0.0.2"), + }, + Replicas: nil, + RetentionDays: nil, + Status: nil, + Storage: nil, + Version: nil, + }, + }, { desc: "create_failed", - instanceId: *instanceId, instanceGetFails: false, instanceState: InstanceStateFailed, wantErr: true, @@ -170,7 +114,6 @@ func TestCreateInstanceWaitHandler(t *testing.T) { }, { desc: "create_failed_2", - instanceId: *instanceId, instanceGetFails: false, instanceState: InstanceStateEmpty, wantErr: true, @@ -178,14 +121,12 @@ func TestCreateInstanceWaitHandler(t *testing.T) { }, { desc: "instance_get_fails", - instanceId: *instanceId, instanceGetFails: true, wantErr: true, wantRes: nil, }, { desc: "timeout", - instanceId: *instanceId, instanceGetFails: false, instanceState: InstanceStateProcessing, wantErr: true, @@ -195,20 +136,22 @@ func TestCreateInstanceWaitHandler(t *testing.T) { for _, tt := range tests { t.Run( tt.desc, func(t *testing.T) { + instanceId := "foo-bar" + apiClient := &apiClientInstanceMocked{ - instanceId: tt.instanceId, + instanceId: instanceId, instanceState: tt.instanceState, instanceGetFails: tt.instanceGetFails, } - handler := CreateInstanceWaitHandler(context.Background(), apiClient, "", tt.instanceId, "") + handler := CreateInstanceWaitHandler(context.Background(), apiClient, "", instanceId, "") gotRes, err := handler.SetTimeout(10 * time.Millisecond).SetSleepBeforeWait(1 * time.Millisecond).WaitWithContext(context.Background()) if (err != nil) != tt.wantErr { t.Fatalf("handler error = %v, wantErr %v", err, tt.wantErr) } - if !reflect.DeepEqual(gotRes, tt.wantRes) { + if !cmp.Equal(gotRes, tt.wantRes) { t.Fatalf("handler gotRes = %v, want %v", gotRes, tt.wantRes) } }, diff --git a/stackit/provider.go b/stackit/provider.go index 086ae003..ce96cd47 100644 --- a/stackit/provider.go +++ b/stackit/provider.go @@ -6,7 +6,6 @@ import ( "context" "fmt" "strings" - "time" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" @@ -20,7 +19,6 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" sdkauth "github.com/stackitcloud/stackit-sdk-go/core/auth" "github.com/stackitcloud/stackit-sdk-go/core/config" - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/core" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/features" @@ -46,18 +44,6 @@ var ( _ provider.Provider = &Provider{} ) -//nolint:unused // These constants are defined for future use in retry logic for HTTP requests, which is not yet implemented. -const ( - // maxRetries is the maximum number of retries for a failed HTTP request. - maxRetries = 3 - // initialDelay is the initial delay before the first retry attempt. - initialDelay = 2 * time.Second - // maxDelay is the maximum delay between retry attempts. - maxDelay = 90 * time.Second - // perTryTimeout is the timeout for each individual HTTP request attempt. - perTryTimeout = 30 * time.Second -) - // Provider is the provider implementation. type Provider struct { version string @@ -124,7 +110,6 @@ type providerModel struct { // Schema defines the provider-level schema for configuration data. func (p *Provider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) { - //nolint:gosec // These are just descriptions, not actual credentials or sensitive information. descriptions := map[string]string{ "credentials_path": "Path of JSON from where the credentials are read. Takes precedence over the env var `STACKIT_CREDENTIALS_PATH`. Default value is `~/.stackit/credentials.json`.", "service_account_token": "Token used for authentication. If set, the token flow will be used to authenticate all operations.", @@ -480,7 +465,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, providerData.Experiments = experimentValues } - baseRoundTripper, err := sdkauth.SetupAuth(sdkConfig) + roundTripper, err := sdkauth.SetupAuth(sdkConfig) if err != nil { core.LogAndAddError( ctx, @@ -491,19 +476,9 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, return } - //nolint:gocritic // maybe later in the code - // roundTripper := core.NewRetryRoundTripper( - // baseRoundTripper, - // maxRetries, - // initialDelay, - // maxDelay, - // perTryTimeout, - //) - // Make round tripper and custom endpoints available during DataSource and Resource // type Configure methods. - // providerData.RoundTripper = roundTripper - providerData.RoundTripper = baseRoundTripper + providerData.RoundTripper = roundTripper resp.DataSourceData = providerData resp.ResourceData = providerData diff --git a/stackit/provider_acc_test.go b/stackit/provider_acc_test.go index 2230d731..208c5b25 100644 --- a/stackit/provider_acc_test.go +++ b/stackit/provider_acc_test.go @@ -1,47 +1,19 @@ package stackit_test import ( - "context" _ "embed" "fmt" - "net/http" + "log/slog" "os" - "reflect" "regexp" "testing" - "time" - - "github.com/golang-jwt/jwt/v5" - "github.com/google/go-cmp/cmp" - test "github.com/hashicorp/terraform-plugin-testing/helper/resource" //nolint:staticcheck // used for acceptance testing - "github.com/jarcoal/httpmock" - "github.com/stackitcloud/stackit-sdk-go/core/clients" - "github.com/stackitcloud/stackit-sdk-go/core/utils" - - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha" - postgresFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavor" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - tfResource "github.com/hashicorp/terraform-plugin-framework/resource" - - "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit" - postgresFlexAlphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/database" - postgresflexalphaFlavors "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/flavors" - postgresFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/instance" - postgresFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/user" - sqlserverflexalphaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/database" - sqlserverFlexAlphaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/flavor" - sqlserverFlexAlphaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/instance" - sqlserverFlexAlphaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/user" - sqlserverflexBetaDatabase "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/database" - sqlserverFlexBetaFlavor "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/flavor" - sqlserverFlexBetaInstance "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/instance" - sqlserverFlexBetaUser "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexbeta/user" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" + "github.com/joho/godotenv" "tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/internal/testutils" "github.com/hashicorp/terraform-plugin-testing/config" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" //nolint:staticcheck // used for acceptance testing + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) //go:embed testdata/provider-credentials.tf @@ -55,213 +27,56 @@ var providerValidAttributes string var testConfigProviderCredentials config.Variables +func setup() { + err := godotenv.Load() + if err != nil { + slog.Info("could not find .env file - not loading .env") + return + } + slog.Info("loaded .env file") + + testConfigProviderCredentials = config.Variables{ + "project_id": config.StringVariable(os.Getenv("TF_ACC_PROJECT_ID")), + "region": config.StringVariable(os.Getenv("TF_ACC_REGION")), + "service_account_key_path": config.StringVariable(os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE")), + "name": config.StringVariable( + fmt.Sprintf( + "tf-acc-prov%s", + acctest.RandStringFromCharSet(3, acctest.CharSetAlphaNum), + ), + ), + } +} + func TestMain(m *testing.M) { - testutils.Setup() + setup() code := m.Run() // shutdown() os.Exit(code) } -func TestMshTest(t *testing.T) { - httpmock.Activate() - defer httpmock.DeactivateAndReset() - - testutils.ActivateEnvironmentHttpMocks() - - httpmock.RegisterResponder( - "POST", `https://service-account.api.stackit.cloud/token`, - func(_ *http.Request) (*http.Response, error) { - token := jwt.NewWithClaims( - jwt.SigningMethodHS256, jwt.MapClaims{ - "foo": "bar", - "nbf": time.Date(2015, 10, 10, 12, 0, 0, 0, time.UTC).Unix(), - }, - ) - // Sign and get the complete encoded token as a string using the secret - tokenString, err := token.SignedString([]byte("mySecret")) - if err != nil { - panic(err) - } - - tR := clients.TokenResponseBody{ - AccessToken: tokenString, - ExpiresIn: 3600, - RefreshToken: "", - Scope: "", - TokenType: "", - } - - return httpmock.NewJsonResponse(http.StatusOK, tR) - }, - ) - - httpmock.RegisterResponder( - "GET", - `https://postgres-flex-service.api.eu01.stackit.cloud/v3alpha1/projects/xyz-project-id/regions/eu01/flavors?page=1&size=25&sort=id.asc`, - func(_ *http.Request) (*http.Response, error) { - res := postgresflexalpha.GetFlavorsResponse{ - Flavors: &[]postgresflexalpha.ListFlavors{ - { - Cpu: nil, - Description: nil, - Id: nil, - MaxGB: nil, - Memory: nil, - MinGB: nil, - NodeType: nil, - StorageClasses: nil, - }, - }, - Pagination: &postgresflexalpha.Pagination{ - Page: utils.Ptr(int64(1)), - Size: utils.Ptr(int64(25)), - Sort: nil, - TotalPages: utils.Ptr(int64(1)), - TotalRows: utils.Ptr(int64(0)), - }, - } - return httpmock.NewJsonResponse( - http.StatusOK, - res, - ) - }, - ) - - test.Test( - t, test.TestCase{ - IsUnitTest: true, - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []test.TestStep{ - { - ConfigVariables: map[string]config.Variable{ - "project_id": config.StringVariable("xyz-project-id"), - }, - Config: fmt.Sprintf( - ` - provider "stackitprivatepreview" { - default_region = "%[1]s" - service_account_key_path = "%[2]s" - } - variable "project_id" { - type = string - } - data "stackitprivatepreview_postgresflexalpha_flavor" "all" { - project_id = var.project_id - region = "eu01" - cpu = 2 - ram = 4 - node_type = "Single" - storage_class = "premium-perf2-stackit" - }`, - os.Getenv("TF_ACC_REGION"), - os.Getenv("TF_ACC_SERVICE_ACCOUNT_FILE"), - ), - }, - }, - }, - ) -} - -func TestUnitProviderHasChildDataSources_Basic(t *testing.T) { - expectedDataSources := []datasource.DataSource{ - postgresFlexAlphaFlavor.NewFlavorDataSource(), - // postgresFlexAlphaFlavor.NewFlavorListDataSource, - postgresFlexAlphaDatabase.NewDatabaseDataSource(), - postgresFlexAlphaInstance.NewInstanceDataSource(), - postgresFlexAlphaUser.NewUserDataSource(), - postgresflexalphaFlavors.NewFlavorsDataSource(), - - sqlserverFlexAlphaFlavor.NewFlavorDataSource(), - sqlserverFlexAlphaInstance.NewInstanceDataSource(), - sqlserverFlexAlphaUser.NewUserDataSource(), - sqlserverflexalphaDatabase.NewDatabaseDataSource(), - - sqlserverflexBetaDatabase.NewDatabaseDataSource(), - sqlserverFlexBetaInstance.NewInstanceDataSource(), - sqlserverFlexBetaUser.NewUserDataSource(), - sqlserverFlexBetaFlavor.NewFlavorDataSource(), - } - provider, ok := stackit.New("testing")().(*stackit.Provider) - if !ok { - t.Fatal("could not assert provider type") - } - datasources := provider.DataSources(context.Background()) - - expectedMap := map[string]struct{}{} - for _, d := range expectedDataSources { - expectedMap[reflect.TypeOf(d).String()] = struct{}{} - } - - actualMap := map[string]struct{}{} - for _, d := range datasources { - actualMap[reflect.TypeOf(d()).String()] = struct{}{} - } - - if diff := cmp.Diff(expectedMap, actualMap); diff != "" { - t.Errorf("DataSources mismatch (-expected +actual):\n%s", diff) - } -} - -func TestUnitProviderHasChildResources_Basic(t *testing.T) { - expectedResources := []tfResource.Resource{ - postgresFlexAlphaInstance.NewInstanceResource(), - postgresFlexAlphaUser.NewUserResource(), - postgresFlexAlphaDatabase.NewDatabaseResource(), - - sqlserverFlexAlphaInstance.NewInstanceResource(), - sqlserverFlexAlphaUser.NewUserResource(), - sqlserverflexalphaDatabase.NewDatabaseResource(), - - sqlserverFlexBetaInstance.NewInstanceResource(), - sqlserverFlexBetaUser.NewUserResource(), - sqlserverflexBetaDatabase.NewDatabaseResource(), - } - provider, ok := stackit.New("testing")().(*stackit.Provider) - if !ok { - t.Fatal("could not assert provider type") - } - resources := provider.Resources(context.Background()) - - expectedMap := map[string]struct{}{} - for _, r := range expectedResources { - expectedMap[reflect.TypeOf(r).String()] = struct{}{} - } - - actualMap := map[string]struct{}{} - for _, r := range resources { - actualMap[reflect.TypeOf(r()).String()] = struct{}{} - } - - if diff := cmp.Diff(expectedMap, actualMap); diff != "" { - t.Errorf("Resources mismatch (-expected +actual):\n%s", diff) - } -} - func TestAccEnvVarServiceAccountPathValid(t *testing.T) { - t.Skip("needs refactoring") // Check if acceptance tests should be run if v := os.Getenv(resource.EnvTfAcc); v == "" { t.Skipf( "Acceptance tests skipped unless env '%s' set", - resource.EnvTfAcc, - ) + resource.EnvTfAcc) return } + // t.Setenv("STACKIT_CREDENTIALS_PATH", "") tempHomeFolder := testutils.CreateTemporaryHome(true, t) defer testutils.CleanupTemporaryHome(tempHomeFolder, t) - resource.Test( - t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) }, - ConfigVariables: testConfigProviderCredentials, - Config: providerCredentialConfig, - }, + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) }, + ConfigVariables: testConfigProviderCredentials, + Config: providerCredentialConfig, }, }, - ) + }) } func TestAccEnvVarServiceAccountPathInvalid(t *testing.T) { @@ -269,19 +84,17 @@ func TestAccEnvVarServiceAccountPathInvalid(t *testing.T) { t.Setenv("STACKIT_CREDENTIALS_PATH", "") tempHomeFolder := testutils.CreateTemporaryHome(false, t) defer testutils.CleanupTemporaryHome(tempHomeFolder, t) - resource.Test( - t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) }, - ConfigVariables: testConfigProviderCredentials, - Config: providerCredentialConfig, - ExpectError: regexp.MustCompile(`undefined response type, status code 401`), - }, + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) }, + ConfigVariables: testConfigProviderCredentials, + Config: providerCredentialConfig, + ExpectError: regexp.MustCompile(`undefined response type, status code 401`), }, }, - ) + }) } func TestAccCredentialsFileValid(t *testing.T) { @@ -289,18 +102,16 @@ func TestAccCredentialsFileValid(t *testing.T) { t.Setenv("STACKIT_CREDENTIALS_PATH", "") tempHomeFolder := testutils.CreateTemporaryHome(true, t) defer testutils.CleanupTemporaryHome(tempHomeFolder, t) - resource.Test( - t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) }, - ConfigVariables: testConfigProviderCredentials, - Config: providerCredentialConfig, - }, + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) }, + ConfigVariables: testConfigProviderCredentials, + Config: providerCredentialConfig, }, }, - ) + }) } func TestAccCredentialsFileInvalid(t *testing.T) { @@ -308,19 +119,17 @@ func TestAccCredentialsFileInvalid(t *testing.T) { t.Setenv("STACKIT_CREDENTIALS_PATH", "") tempHomeFolder := testutils.CreateTemporaryHome(false, t) defer testutils.CleanupTemporaryHome(tempHomeFolder, t) - resource.Test( - t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) }, - ConfigVariables: testConfigProviderCredentials, - Config: providerCredentialConfig, - ExpectError: regexp.MustCompile(`Jwt is not in(\r\n|\r|\n)the form of Header.Payload.Signature`), - }, + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + PreConfig: func() { testutils.SetTemporaryHome(tempHomeFolder) }, + ConfigVariables: testConfigProviderCredentials, + Config: providerCredentialConfig, + ExpectError: regexp.MustCompile(`Jwt is not in(\r\n|\r|\n)the form of Header.Payload.Signature`), }, }, - ) + }) } func TestAccProviderConfigureValidValues(t *testing.T) { @@ -329,52 +138,43 @@ func TestAccProviderConfigureValidValues(t *testing.T) { if v := os.Getenv(resource.EnvTfAcc); v == "" { t.Skipf( "Acceptance tests skipped unless env '%s' set", - resource.EnvTfAcc, - ) + resource.EnvTfAcc) return } t.Setenv("STACKIT_CREDENTIALS_PATH", "") tempHomeFolder := testutils.CreateTemporaryHome(true, t) defer testutils.CleanupTemporaryHome(tempHomeFolder, t) - resource.Test( - t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - // valid provider attributes - ConfigVariables: testConfigProviderCredentials, - Config: providerValidAttributes, - }, + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { // valid provider attributes + ConfigVariables: testConfigProviderCredentials, + Config: providerValidAttributes, }, }, - ) + }) } func TestAccProviderConfigureAnInvalidValue(t *testing.T) { - t.Skip("needs refactoring") // Check if acceptance tests should be run if v := os.Getenv(resource.EnvTfAcc); v == "" { t.Skipf( "Acceptance tests skipped unless env '%s' set", - resource.EnvTfAcc, - ) + resource.EnvTfAcc) return } t.Setenv("STACKIT_CREDENTIALS_PATH", "") tempHomeFolder := testutils.CreateTemporaryHome(true, t) defer testutils.CleanupTemporaryHome(tempHomeFolder, t) - resource.Test( - t, resource.TestCase{ - ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - // invalid test attribute should throw an error - ConfigVariables: testConfigProviderCredentials, - Config: providerInvalidAttribute, - ExpectError: regexp.MustCompile(`An argument named "test" is not expected here\.`), - }, + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testutils.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { // invalid test attribute should throw an error + ConfigVariables: testConfigProviderCredentials, + Config: providerInvalidAttribute, + ExpectError: regexp.MustCompile(`An argument named "test" is not expected here\.`), }, }, - ) + }) } diff --git a/tools/tools.go b/tools/tools.go index e9567c7f..075c26d5 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,5 +1,3 @@ -//go:build tools - package tools // Format Terraform code for use in documentation. @@ -9,11 +7,3 @@ package tools // Generate documentation. //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-dir .. -provider-name stackitprivatepreview - -import ( - _ "github.com/golangci/golangci-lint/v2/cmd/golangci-lint" - _ "github.com/hashicorp/terraform-plugin-codegen-framework/cmd/tfplugingen-framework" - _ "github.com/hashicorp/terraform-plugin-codegen-openapi/cmd/tfplugingen-openapi" - _ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs" - _ "golang.org/x/tools/cmd/goimports" -)