chore: work save

This commit is contained in:
Marcel S. Henselin 2026-01-29 10:05:13 +01:00
parent 3e3f13d36d
commit 9752d63f7e
19 changed files with 1003 additions and 209 deletions

View file

@ -4,14 +4,31 @@ description: "Build pipeline"
inputs: inputs:
go-version: go-version:
description: "Go version to install" description: "Go version to install"
default: '1.25'
required: true required: true
golang-cilint-version:
description: "Golangci-lint version to install"
default: "2.7.2"
required: true
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Install Go ${{ inputs.go-version }} - name: Install Go ${{ inputs.go-version }}
uses: actions/setup-go@v5 uses: actions/setup-go@v6
with: with:
go-version: ${{ inputs.go-version }} go-version: ${{ inputs.go-version }}
- name: Install project tools and dependencies check-latest: true
go-version-file: 'go.mod'
# - name: Run golangci-lint
# uses: golangci/golangci-lint-action@v9
# with:
# version: ${{ inputs.golang-cilint-version }}
- name: Install needed tools
shell: bash shell: bash
run: make project-tools run: |
set -e
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${{ inputs.golang-cilint-version }}
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.24.0

View file

@ -13,7 +13,7 @@ env:
CODE_COVERAGE_ARTIFACT_NAME: "code-coverage" CODE_COVERAGE_ARTIFACT_NAME: "code-coverage"
jobs: jobs:
main: prep:
name: prepare name: prepare
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
@ -22,6 +22,11 @@ jobs:
contents: read # Required to checkout repository. contents: read # Required to checkout repository.
pull-requests: write # Required to add PR comment. pull-requests: write # Required to add PR comment.
steps: steps:
- name: Install prerequisites
run: |
apt-get -qq -y update
apt-get -qq -y install unzip zip
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
@ -46,15 +51,15 @@ jobs:
# - run: echo ${{ steps.plan.outputs.exitcode }} # - run: echo ${{ steps.plan.outputs.exitcode }}
# Run plan by default, or apply on merge. # Run plan by default, or apply on merge.
- uses: op5dev/tf-via-pr@v13 # - uses: op5dev/tf-via-pr@v13
with: # with:
working-directory: path/to/directory # working-directory: path/to/directory
command: ${{ github.event_name == 'push' && 'apply' || 'plan' }} # command: ${{ github.event_name == 'push' && 'apply' || 'plan' }}
arg-lock: ${{ github.event_name == 'push' }} # arg-lock: ${{ github.event_name == 'push' }}
arg-backend-config: env/dev.tfbackend # arg-backend-config: env/dev.tfbackend
arg-var-file: env/dev.tfvars # arg-var-file: env/dev.tfvars
arg-workspace: dev-use1 # arg-workspace: dev-use1
plan-encrypt: ${{ secrets.PASSPHRASE }} # plan-encrypt: ${{ secrets.PASSPHRASE }}
# - name: "Ensure docs are up-to-date" # - name: "Ensure docs are up-to-date"
# if: ${{ github.event_name == 'pull_request' }} # if: ${{ github.event_name == 'pull_request' }}
@ -65,15 +70,15 @@ jobs:
# if: ${{ github.event_name == 'pull_request' }} # if: ${{ github.event_name == 'pull_request' }}
# run: go mod tidy # run: go mod tidy
- name: golangci-lint # - name: golangci-lint
uses: golangci/golangci-lint-action@v9 # uses: golangci/golangci-lint-action@v9
with: # with:
version: v2.7 # version: v2.7
args: --config=golang-ci.yaml --allow-parallel-runners --timeout=5m # args: --config=golang-ci.yaml --allow-parallel-runners --timeout=5m
# - name: Lint # - name: Lint
# run: make lint # run: make lint
# - name: Test # - name: Test
# run: make test # run: make test
@ -99,9 +104,9 @@ jobs:
code_coverage: code_coverage:
name: "Code coverage report" name: "Code coverage report"
if: github.event_name == 'pull_request' # Do not run when workflow is triggered by push to main branch if: github.event_name == 'pull_request' || (github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: main needs: prep
permissions: permissions:
contents: read contents: read
actions: read # to download code coverage results from "main" job actions: read # to download code coverage results from "main" job
@ -116,20 +121,87 @@ jobs:
root-package: 'tfregistry.sysops.stackit.rocks/mhenselin/stackitprivatepreview' root-package: 'tfregistry.sysops.stackit.rocks/mhenselin/stackitprivatepreview'
publish: publish:
name: "Publish artifact" name: "Publish provider"
# if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
if: github.event_name == 'push'
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
actions: read # Required to identify workflow run.
checks: write # Required to add status summary.
contents: read # Required to checkout repository.
pull-requests: write # Required to add PR comment.
steps: steps:
- name: Set up S3cmd cli tool - name: Install needed tools
uses: s3-actions/s3cmd@v2.0.1
with:
provider: aws # default is linode
region: 'eu01'
access_key: ${{ secrets.S3_ACCESS_KEY }}
secret_key: ${{ secrets.S3_SECRET_KEY }}
- name: Interact with object storage
run: | run: |
s3cmd ls apt-get -y -qq update
# s3cmd sync --recursive --acl-public dist s3://awesome.blog/ apt-get -y -qq install jq python3 python3-pip python-is-python3 s3cmd git make wget
# s3cmd put dist/style.css --mime-type 'text/css' --acl-public s3://awesome.blog/style.css
s3cmd info s3://awesome.blog - name: Checkout
uses: actions/checkout@v6
- name: Install Go ${{ env.GO_VERSION }}
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
- uses: actions/setup-java@v5
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'
- name: Run build pkg directory
run: |
go run cmd/main.go build
- name: Set up s3cfg
run: |
cat <<'EOF' >> ~/.s3cfg
[default]
host_base = https://object.storage.eu01.onstackit.cloud
host_bucket = https://%(bucket).object.storage.eu01.onstackit.cloud
check_ssl_certificate = False
access_key = ${{ secrets.S3_ACCESS_KEY }}
secret_key = ${{ secrets.S3_SECRET_KEY }}
EOF
- name: Import GPG key
run: |
gpg --import private.key
- name: Run GoReleaser
id: goreleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
uses: goreleaser/goreleaser-action@v6
with:
args: release --skip publish --clean --snapshot
- name: Prepare key file
run: |
echo $(echo ${{ secrets.KEY_FILE_B64 }} | base64 -d) >public_key.pem
- name: Prepare provider directory structure
run: |
VERSION=$(jq -c .version < dist/metadata.json)
go run main.go \
-ns=mhenselin \
-p=stackitprivatepreview \
-r=terraform-provider-stackitprivatepreview \
-d=tfregistry.sysops.stackit.rocks \
-gf=${{ secrets.GPG_FINGERPRINT }} \
-gk=public_key.pem \
-v=${VERSION}
- name: Publish provider to S3
run: |
set -e
cd release/
s3cmd put --recursive v1 s3://terraform-provider-privatepreview/
s3cmd put --recursive .well-known s3://terraform-provider-privatepreview/

4
.gitignore vendored
View file

@ -40,4 +40,6 @@ coverage.out
coverage.html coverage.html
generated generated
stackit-sdk-generator stackit-sdk-generator
dist dist
.secrets

17
cmd/cmd/buildCmd.go Normal file
View file

@ -0,0 +1,17 @@
package cmd
import (
"github.com/mhenselin/terraform-provider-stackitprivatepreview/tools"
"github.com/spf13/cobra"
)
func NewBuildCmd() *cobra.Command {
return &cobra.Command{
Use: "build",
Short: "Build the necessary boilerplate",
Long: `...`,
RunE: func(cmd *cobra.Command, args []string) error {
return tools.Build()
},
}
}

498
cmd/cmd/publishCmd.go Normal file
View file

@ -0,0 +1,498 @@
package cmd
import (
"bufio"
"errors"
"fmt"
"io"
"io/fs"
"log"
"os"
"path"
"path/filepath"
"strings"
"github.com/spf13/cobra"
)
var (
namespace string
domain string
providerName string
distPath string
repoName string
version string
gpgFingerprint string
gpgPubKeyFile string
)
var rootCmd = &cobra.Command{
Use: "publish",
Short: "Publish terraform provider",
Long: `...`,
RunE: func(cmd *cobra.Command, args []string) error {
return publish()
},
}
func init() { // nolint: gochecknoinits
rootCmd.Flags().StringVarP(&namespace, "namespace", "n", "", "Namespace for the Terraform registry.")
rootCmd.Flags().StringVarP(&domain, "domain", "d", "", "Domain for the Terraform registry.")
rootCmd.Flags().StringVarP(&providerName, "providerName", "p", "", "ProviderName for the Terraform registry.")
rootCmd.Flags().StringVarP(&distPath, "distPath", "x", "dist", "Dist Path for the Terraform registry.")
rootCmd.Flags().StringVarP(&repoName, "repoName", "r", "", "RepoName for the Terraform registry.")
rootCmd.Flags().StringVarP(&version, "version", "v", "", "Version for the Terraform registry.")
rootCmd.Flags().StringVarP(&gpgFingerprint, "gpgFingerprint", "f", "", "GPG Fingerprint for the Terraform registry.")
rootCmd.Flags().StringVarP(&gpgPubKeyFile, "gpgPubKeyFile", "k", "", "GPG PubKey file name for the Terraform registry.")
err := rootCmd.MarkFlagRequired("namespace")
if err != nil {
return
}
err = rootCmd.MarkFlagRequired("domain")
if err != nil {
return
}
err = rootCmd.MarkFlagRequired("providerName")
if err != nil {
return
}
err = rootCmd.MarkFlagRequired("gpgFingerprint")
if err != nil {
return
}
err = rootCmd.MarkFlagRequired("gpgPubKeyFile")
if err != nil {
return
}
err = rootCmd.MarkFlagRequired("repoName")
if err != nil {
return
}
err = rootCmd.MarkFlagRequired("version")
if err != nil {
return
}
err = rootCmd.MarkFlagRequired("gpgFingerprint")
if err != nil {
return
}
err = rootCmd.MarkFlagRequired("gpgPubKeyFile")
if err != nil {
return
}
}
func NewPublishCmd() *cobra.Command {
return rootCmd
}
func publish() error {
log.Println("📦 Packaging Terraform Provider for private registry...")
distPath = filepath.Clean(distPath) + "/"
// Create release dir - only the contents of this need to be uploaded to S3
err := createDir("release")
if err != nil {
return fmt.Errorf("error creating 'release' dir: %s", err)
}
// Create .wellKnown directory and terraform.json file
err = wellKnown()
if err != nil {
return fmt.Errorf("error creating '.wellKnown' dir: %s", err)
}
// Create v1 directory
err = provider(namespace, providerName, distPath, repoName, version, gpgFingerprint, gpgPubKeyFile, domain)
if err != nil {
return fmt.Errorf("error creating 'v1' dir: %s", err)
}
log.Println("📦 Packaged Terraform Provider for private registry.")
return nil
}
// This establishes the "API" as a TF provider by responding with the correct JSON payload, by using static files
func wellKnown() error {
log.Println("* Creating .well-known directory")
err := createDir("release/.well-known")
if err != nil {
return err
}
terraformJson := []byte(`{"providers.v1": "/v1/providers/"}`)
log.Println(" - Writing to .well-known/terraform.json file")
err = writeFile("release/.well-known/terraform.json", terraformJson)
if err != nil {
return err
}
return nil
}
// provider is the Terraform name
// repoName is the Repository name
func provider(namespace, provider, distPath, repoName, version, gpgFingerprint, gpgPubKeyFile, domain string) error {
// Path to semantic version dir
versionPath := providerDirs(namespace, provider, version)
// Files to create under v1/providers/[namespace]/[provider_name]
err := createVersionsFile(namespace, provider, distPath, repoName, version)
if err != nil {
return err
} // Creates version file one above download, which is why downloadPath isn't used
// Files/Directories to create under v1/providers/[namespace]/[provider_name]/[version]
copyShaFiles(versionPath, distPath, repoName, version)
downloadPath, err := createDownloadsDir(versionPath)
if err != nil {
return err
}
// Create darwin, freebsd, linux, windows dirs
err = createTargetDirs(*downloadPath)
if err != nil {
return err
}
// Copy all zips
err = copyBuildZips(*downloadPath, distPath, repoName, version)
if err != nil {
return err
}
// Create all individual files for build targets and each architecture for the build targets
err = createArchitectureFiles(namespace, provider, distPath, repoName, version, gpgFingerprint, gpgPubKeyFile, domain)
if err != nil {
return err
}
return nil
}
// Create the directories with a path format v1/providers/[namespace]/[provider_name]/[version]
func providerDirs(namespace, repoName, version string) string {
log.Println("* Creating release/v1/providers/[namespace]/[repo]/[version] directories")
providerPathArr := [6]string{"release", "v1", "providers", namespace, repoName, version}
var currentPath string
for _, v := range providerPathArr {
currentPath = currentPath + v + "/"
err := createDir(currentPath)
if err != nil {
return ""
}
}
return currentPath
}
// Create the versions file under v1/providers/[namespace]/[provider_name]
func createVersionsFile(namespace, provider, distPath, repoName, version string) error {
log.Println("* Writing to release/v1/providers/[namespace]/[repo]/versions file")
versionPath := fmt.Sprintf("release/v1/providers/%s/%s/versions", namespace, provider)
shaSumContents, err := getShaSumContents(distPath, repoName, version)
if err != nil {
return err
}
// Build the versions file...
platforms := ""
for _, line := range shaSumContents {
fileName := line[1] // zip file name
// get os and arch from filename
removeFileExtension := strings.Split(fileName, ".zip")
fileNameSplit := strings.Split(removeFileExtension[0], "_")
// Get build target and architecture from the zip file name
target := fileNameSplit[2]
arch := fileNameSplit[3]
platforms += "{"
platforms += fmt.Sprintf(`"os": "%s",`, target)
platforms += fmt.Sprintf(`"arch": "%s"`, arch)
platforms += "}"
platforms += ","
}
platforms = strings.TrimRight(platforms, ",") // remove trailing comma, json does not allow
var versions = []byte(fmt.Sprintf(`
{
"versions": [
{
"version": "%s",
"protocols": [
"4.0",
"5.1",
"6.0"
],
"platform": [
%s
]
}
]
}
`, version, platforms))
err = writeFile(versionPath, versions)
if err != nil {
return err
}
return nil
}
func copyShaFiles(destPath, srcPath, repoName, version string) {
log.Printf("* Copying SHA files in %s directory", srcPath)
// Copy files from srcPath
shaSum := repoName + "_" + version + "_SHA256SUMS"
shaSumPath := srcPath + "/" + shaSum
// _SHA256SUMS file
_, err := copyFile(shaSumPath, destPath+shaSum)
if err != nil {
log.Println(err)
}
// _SHA256SUMS.sig file
_, err = copyFile(shaSumPath+".sig", destPath+shaSum+".sig")
if err != nil {
log.Println(err)
}
}
func createDownloadsDir(destPath string) (*string, error) {
log.Printf("* Creating download/ in %s directory", destPath)
downloadPath := path.Join(destPath, "download")
err := createDir(downloadPath)
if err != nil {
return nil, err
}
return &downloadPath, nil
}
func createTargetDirs(destPath string) error {
log.Printf("* Creating target dirs in %s directory", destPath)
targets := [4]string{"darwin", "freebsd", "linux", "windows"}
for _, v := range targets {
err := createDir(destPath + v)
if err != nil {
return err
}
}
return nil
}
func copyBuildZips(destPath, distPath, repoName, version string) error {
log.Println("* Copying build zips")
shaSumContents, err := getShaSumContents(distPath, repoName, version)
if err != nil {
return err
}
// Loop through and copy each
for _, v := range shaSumContents {
zipName := v[1]
zipSrcPath := distPath + zipName
zipDestPath := destPath + zipName
log.Printf(" - Zip Source: %s", zipSrcPath)
log.Printf(" - Zip Dest: %s", zipDestPath)
// Copy the zip
_, err := copyFile(zipSrcPath, zipDestPath)
if err != nil {
return err
}
}
return nil
}
func getShaSumContents(distPath, repoName, version string) ([][]string, error) {
shaSumFileName := repoName + "_" + version + "_SHA256SUMS"
shaSumPath := distPath + "/" + shaSumFileName
shaSumLine, err := readFile(shaSumPath)
if err != nil {
return nil, err
}
buildsAndShaSums := [][]string{}
for _, line := range shaSumLine {
lineSplit := strings.Split(line, " ")
row := []string{lineSplit[0], lineSplit[1]}
buildsAndShaSums = append(buildsAndShaSums, row)
}
// log.Println(buildsAndShaSums)
return buildsAndShaSums, nil
}
// Create architecture files for each build target
func createArchitectureFiles(namespace, provider, distPath, repoName, version, gpgFingerprint, gpgPubKeyFile, domain string) error {
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)
pathPrefix := fmt.Sprintf("release/%s", prefix)
urlPrefix := fmt.Sprintf("https://%s/%s", domain, prefix)
// download url = https://example.com/v1/providers/namespace/provider/0.0.1/download/terraform-provider_0.0.1_darwin_amd64.zip
downloadUrlPrefix := urlPrefix + "download/"
downloadPathPrefix := pathPrefix + "download/"
// shasums url = https://example.com/v1/providers/namespace/provider/0.0.1/terraform-provider_0.0.1_SHA256SUMS
shasumsUrl := urlPrefix + fmt.Sprintf("%s_%s_SHA256SUMS", repoName, version)
// shasums_signature_url = https://example.com/v1/providers/namespace/provider/0.0.1/terraform-provider_0.0.1_SHA256SUMS.sig
shasumsSigUrl := shasumsUrl + ".sig"
shaSumContents, err := getShaSumContents(distPath, repoName, version)
if err != nil {
return err
}
// Get contents of GPG key
gpgFile, err := readFile(gpgPubKeyFile)
if err != nil {
log.Printf("Error reading '%s' file: %s", gpgPubKeyFile, err)
}
// loop through every line and stick with \\n
gpgAsciiPub := ""
for _, line := range gpgFile {
gpgAsciiPub = gpgAsciiPub + line + "\\n"
}
// log.Println(gpgAsciiPub)
for _, line := range shaSumContents {
shasum := line[0] // shasum of the zip
fileName := line[1] // zip file name
downloadUrl := downloadUrlPrefix + fileName
// get os and arch from filename
removeFileExtension := strings.Split(fileName, ".zip")
fileNameSplit := strings.Split(removeFileExtension[0], "_")
// Get build target and architecture from the zip file name
target := fileNameSplit[2]
arch := fileNameSplit[3]
// build filepath
archFileName := downloadPathPrefix + target + "/" + arch
var architectureTemplate = []byte(fmt.Sprintf(`
{
"protocols": [
"4.0",
"5.1"
],
"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)
err := writeFile(archFileName, architectureTemplate)
if err != nil {
return err
}
}
return nil
}
func createDir(path string) error {
log.Printf("* Creating %s directory", path)
err := os.Mkdir(path, os.ModePerm)
if errors.Is(err, fs.ErrExist) {
return nil
}
return err
}
func copyFile(src, dst string) (int64, error) {
sourceFileStat, err := os.Stat(src)
if err != nil {
return 0, err
}
if !sourceFileStat.Mode().IsRegular() {
return 0, fmt.Errorf("%s is not a regular file", src)
}
source, err := os.Open(src)
if err != nil {
return 0, err
}
defer source.Close()
destination, err := os.Create(dst)
if err != nil {
return 0, err
}
defer destination.Close()
nBytes, err := io.Copy(destination, source)
return nBytes, err
}
func readFile(filePath string) ([]string, error) {
rFile, err := os.Open(filePath)
if err != nil {
return nil, err
}
fileScanner := bufio.NewScanner(rFile)
fileScanner.Split(bufio.ScanLines)
var fileLines []string
for fileScanner.Scan() {
fileLines = append(fileLines, fileScanner.Text())
}
rFile.Close()
return fileLines, nil
}
func writeFile(fileName string, fileContents []byte) error {
err := os.WriteFile(fileName, fileContents, 0644)
return err
}

23
cmd/cmd/rootCmd.go Normal file
View file

@ -0,0 +1,23 @@
package cmd
import (
"github.com/spf13/cobra"
)
func NewRootCmd() *cobra.Command {
return &cobra.Command{
Use: "build-tools",
Short: "...",
Long: "...",
SilenceErrors: true, // Error is beautified in a custom way before being printed
SilenceUsage: true,
DisableAutoGenTag: true,
RunE: func(cmd *cobra.Command, _ []string) error {
err := cmd.Help()
if err != nil {
return err
}
return nil
},
}
}

View file

@ -4,29 +4,23 @@ import (
"log" "log"
"os" "os"
"github.com/mhenselin/terraform-provider-stackitprivatepreview/tools" "github.com/mhenselin/terraform-provider-stackitprivatepreview/cmd/cmd"
"github.com/spf13/cobra"
) )
func NewRootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "builder",
Short: "...",
Long: "...",
SilenceErrors: true, // Error is beautified in a custom way before being printed
SilenceUsage: true,
DisableAutoGenTag: true,
RunE: func(_ *cobra.Command, _ []string) error {
return tools.Build()
},
}
cmd.SetOut(os.Stdout)
return cmd
}
func main() { func main() {
cmd := NewRootCmd() rootCmd := cmd.NewRootCmd()
err := cmd.Execute() //rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
//rootCmd.PersistentFlags().StringP("author", "a", "YOUR NAME", "author name for copyright attribution")
//rootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "name of license for the project")
rootCmd.SetOut(os.Stdout)
rootCmd.AddCommand(
cmd.NewBuildCmd(),
cmd.NewPublishCmd(),
)
err := rootCmd.Execute()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View file

@ -1,96 +0,0 @@
# This file contains all available configuration options
# with their default values.
# options for analysis running
run:
# default concurrency is a available CPU number
concurrency: 4
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
linters-settings:
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/freiheit-com/nmww
depguard:
rules:
main:
list-mode: lax # Everything is allowed unless it is denied
deny:
- pkg: "github.com/stretchr/testify"
desc: Do not use a testing framework
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: US
# golint:
# min-confidence: 0.8
gosec:
excludes:
# Suppressions: (see https://github.com/securego/gosec#available-rules for details)
- G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck
- G102 # "Bind to all interfaces" -> since this is normal in k8s
- G304 # "File path provided as taint input" -> too many false positives
- G307 # "Deferring unsafe method "Close" on type "io.ReadCloser" -> false positive when calling defer resp.Body.Close()
nakedret:
max-func-lines: 0
revive:
ignore-generated-header: true
severity: error
# https://github.com/mgechev/revive
rules:
- name: errorf
- name: context-as-argument
- name: error-return
- name: increment-decrement
- name: indent-error-flow
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: atomic
- name: empty-lines
- name: early-return
gocritic:
enabled-tags:
- performance
- style
- experimental
disabled-checks:
- wrapperFunc
- typeDefFirst
- ifElseChain
- dupImport # https://github.com/go-critic/go-critic/issues/845
linters:
enable:
# https://golangci-lint.run/usage/linters/
# default linters
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
# additional linters
- errorlint
- gochecknoinits
- gocritic
- gofmt
- goimports
- gosec
- misspell
- nakedret
- revive
- depguard
- bodyclose
- sqlclosecheck
- wastedassign
- forcetypeassert
- errcheck
disable:
- noctx # false positive: finds errors with http.NewRequest that dont make sense
- unparam # false positives
issues:
exclude-use-default: false

View file

@ -410,8 +410,7 @@ type Key struct {
// This date is set when a key is pending deletion and refers to the scheduled date of deletion // This date is set when a key is pending deletion and refers to the scheduled date of deletion
DeletionDate KeyGetDeletionDateAttributeType `json:"deletionDate,omitempty"` DeletionDate KeyGetDeletionDateAttributeType `json:"deletionDate,omitempty"`
// A user chosen description to distinguish multiple keys. // A user chosen description to distinguish multiple keys.
// REQUIRED Description KeyGetDescriptionAttributeType `json:"description,omitempty"`
Description KeyGetDescriptionAttributeType `json:"description" required:"true"`
// The display name to distinguish multiple keys. // The display name to distinguish multiple keys.
// REQUIRED // REQUIRED
DisplayName KeyGetDisplayNameAttributeType `json:"displayName" required:"true"` DisplayName KeyGetDisplayNameAttributeType `json:"displayName" required:"true"`
@ -439,13 +438,12 @@ type _Key Key
// This constructor will assign default values to properties that have it defined, // This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments // and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed // will change when the set of required properties is changed
func NewKey(accessScope KeyGetAccessScopeArgType, algorithm KeyGetAlgorithmArgType, backend KeyGetBackendArgType, createdAt KeyGetCreatedAtArgType, description KeyGetDescriptionArgType, displayName KeyGetDisplayNameArgType, id KeyGetIdArgType, importOnly KeygetImportOnlyArgType, keyRingId KeyGetKeyRingIdArgType, protection KeyGetProtectionArgType, purpose KeyGetPurposeArgType, state KeyGetStateArgType) *Key { func NewKey(accessScope KeyGetAccessScopeArgType, algorithm KeyGetAlgorithmArgType, backend KeyGetBackendArgType, createdAt KeyGetCreatedAtArgType, displayName KeyGetDisplayNameArgType, id KeyGetIdArgType, importOnly KeygetImportOnlyArgType, keyRingId KeyGetKeyRingIdArgType, protection KeyGetProtectionArgType, purpose KeyGetPurposeArgType, state KeyGetStateArgType) *Key {
this := Key{} this := Key{}
setKeyGetAccessScopeAttributeType(&this.AccessScope, accessScope) setKeyGetAccessScopeAttributeType(&this.AccessScope, accessScope)
setKeyGetAlgorithmAttributeType(&this.Algorithm, algorithm) setKeyGetAlgorithmAttributeType(&this.Algorithm, algorithm)
setKeyGetBackendAttributeType(&this.Backend, backend) setKeyGetBackendAttributeType(&this.Backend, backend)
setKeyGetCreatedAtAttributeType(&this.CreatedAt, createdAt) setKeyGetCreatedAtAttributeType(&this.CreatedAt, createdAt)
setKeyGetDescriptionAttributeType(&this.Description, description)
setKeyGetDisplayNameAttributeType(&this.DisplayName, displayName) setKeyGetDisplayNameAttributeType(&this.DisplayName, displayName)
setKeyGetIdAttributeType(&this.Id, id) setKeyGetIdAttributeType(&this.Id, id)
setKeygetImportOnlyAttributeType(&this.ImportOnly, importOnly) setKeygetImportOnlyAttributeType(&this.ImportOnly, importOnly)
@ -562,19 +560,25 @@ func (o *Key) SetDeletionDate(v KeyGetDeletionDateRetType) {
setKeyGetDeletionDateAttributeType(&o.DeletionDate, v) setKeyGetDeletionDateAttributeType(&o.DeletionDate, v)
} }
// GetDescription returns the Description field value // GetDescription returns the Description field value if set, zero value otherwise.
func (o *Key) GetDescription() (ret KeyGetDescriptionRetType) { func (o *Key) GetDescription() (res KeyGetDescriptionRetType) {
ret, _ = o.GetDescriptionOk() res, _ = o.GetDescriptionOk()
return ret return
} }
// GetDescriptionOk returns a tuple with the Description field value // GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
// and a boolean to check if the value has been set. // and a boolean to check if the value has been set.
func (o *Key) GetDescriptionOk() (ret KeyGetDescriptionRetType, ok bool) { func (o *Key) GetDescriptionOk() (ret KeyGetDescriptionRetType, ok bool) {
return getKeyGetDescriptionAttributeTypeOk(o.Description) return getKeyGetDescriptionAttributeTypeOk(o.Description)
} }
// SetDescription sets field value // HasDescription returns a boolean if a field has been set.
func (o *Key) HasDescription() bool {
_, ok := o.GetDescriptionOk()
return ok
}
// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *Key) SetDescription(v KeyGetDescriptionRetType) { func (o *Key) SetDescription(v KeyGetDescriptionRetType) {
setKeyGetDescriptionAttributeType(&o.Description, v) setKeyGetDescriptionAttributeType(&o.Description, v)
} }

View file

@ -234,8 +234,7 @@ type KeyRing struct {
// REQUIRED // REQUIRED
CreatedAt KeyRingGetCreatedAtAttributeType `json:"createdAt" required:"true"` CreatedAt KeyRingGetCreatedAtAttributeType `json:"createdAt" required:"true"`
// A user chosen description to distinguish multiple key rings. // A user chosen description to distinguish multiple key rings.
// REQUIRED Description KeyRingGetDescriptionAttributeType `json:"description,omitempty"`
Description KeyRingGetDescriptionAttributeType `json:"description" required:"true"`
// The display name to distinguish multiple key rings. // The display name to distinguish multiple key rings.
// REQUIRED // REQUIRED
DisplayName KeyRingGetDisplayNameAttributeType `json:"displayName" required:"true"` DisplayName KeyRingGetDisplayNameAttributeType `json:"displayName" required:"true"`
@ -253,10 +252,9 @@ type _KeyRing KeyRing
// This constructor will assign default values to properties that have it defined, // This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments // and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed // will change when the set of required properties is changed
func NewKeyRing(createdAt KeyRingGetCreatedAtArgType, description KeyRingGetDescriptionArgType, displayName KeyRingGetDisplayNameArgType, id KeyRingGetIdArgType, state KeyRingGetStateArgType) *KeyRing { func NewKeyRing(createdAt KeyRingGetCreatedAtArgType, displayName KeyRingGetDisplayNameArgType, id KeyRingGetIdArgType, state KeyRingGetStateArgType) *KeyRing {
this := KeyRing{} this := KeyRing{}
setKeyRingGetCreatedAtAttributeType(&this.CreatedAt, createdAt) setKeyRingGetCreatedAtAttributeType(&this.CreatedAt, createdAt)
setKeyRingGetDescriptionAttributeType(&this.Description, description)
setKeyRingGetDisplayNameAttributeType(&this.DisplayName, displayName) setKeyRingGetDisplayNameAttributeType(&this.DisplayName, displayName)
setKeyRingGetIdAttributeType(&this.Id, id) setKeyRingGetIdAttributeType(&this.Id, id)
setKeyRingGetStateAttributeType(&this.State, state) setKeyRingGetStateAttributeType(&this.State, state)
@ -288,19 +286,25 @@ func (o *KeyRing) SetCreatedAt(v KeyRingGetCreatedAtRetType) {
setKeyRingGetCreatedAtAttributeType(&o.CreatedAt, v) setKeyRingGetCreatedAtAttributeType(&o.CreatedAt, v)
} }
// GetDescription returns the Description field value // GetDescription returns the Description field value if set, zero value otherwise.
func (o *KeyRing) GetDescription() (ret KeyRingGetDescriptionRetType) { func (o *KeyRing) GetDescription() (res KeyRingGetDescriptionRetType) {
ret, _ = o.GetDescriptionOk() res, _ = o.GetDescriptionOk()
return ret return
} }
// GetDescriptionOk returns a tuple with the Description field value // GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
// and a boolean to check if the value has been set. // and a boolean to check if the value has been set.
func (o *KeyRing) GetDescriptionOk() (ret KeyRingGetDescriptionRetType, ok bool) { func (o *KeyRing) GetDescriptionOk() (ret KeyRingGetDescriptionRetType, ok bool) {
return getKeyRingGetDescriptionAttributeTypeOk(o.Description) return getKeyRingGetDescriptionAttributeTypeOk(o.Description)
} }
// SetDescription sets field value // HasDescription returns a boolean if a field has been set.
func (o *KeyRing) HasDescription() bool {
_, ok := o.GetDescriptionOk()
return ok
}
// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *KeyRing) SetDescription(v KeyRingGetDescriptionRetType) { func (o *KeyRing) SetDescription(v KeyRingGetDescriptionRetType) {
setKeyRingGetDescriptionAttributeType(&o.Description, v) setKeyRingGetDescriptionAttributeType(&o.Description, v)
} }

View file

@ -407,8 +407,7 @@ type WrappingKey struct {
// REQUIRED // REQUIRED
CreatedAt WrappingKeyGetCreatedAtAttributeType `json:"createdAt" required:"true"` CreatedAt WrappingKeyGetCreatedAtAttributeType `json:"createdAt" required:"true"`
// A user chosen description to distinguish multiple wrapping keys. // A user chosen description to distinguish multiple wrapping keys.
// REQUIRED Description WrappingKeyGetDescriptionAttributeType `json:"description,omitempty"`
Description WrappingKeyGetDescriptionAttributeType `json:"description" required:"true"`
// The display name to distinguish multiple wrapping keys. // The display name to distinguish multiple wrapping keys.
// REQUIRED // REQUIRED
DisplayName WrappingKeyGetDisplayNameAttributeType `json:"displayName" required:"true"` DisplayName WrappingKeyGetDisplayNameAttributeType `json:"displayName" required:"true"`
@ -438,13 +437,12 @@ type _WrappingKey WrappingKey
// This constructor will assign default values to properties that have it defined, // This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments // and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed // will change when the set of required properties is changed
func NewWrappingKey(accessScope WrappingKeyGetAccessScopeArgType, algorithm WrappingKeyGetAlgorithmArgType, backend WrappingKeyGetBackendArgType, createdAt WrappingKeyGetCreatedAtArgType, description WrappingKeyGetDescriptionArgType, displayName WrappingKeyGetDisplayNameArgType, expiresAt WrappingKeyGetExpiresAtArgType, id WrappingKeyGetIdArgType, keyRingId WrappingKeyGetKeyRingIdArgType, protection WrappingKeyGetProtectionArgType, purpose WrappingKeyGetPurposeArgType, state WrappingKeyGetStateArgType) *WrappingKey { func NewWrappingKey(accessScope WrappingKeyGetAccessScopeArgType, algorithm WrappingKeyGetAlgorithmArgType, backend WrappingKeyGetBackendArgType, createdAt WrappingKeyGetCreatedAtArgType, displayName WrappingKeyGetDisplayNameArgType, expiresAt WrappingKeyGetExpiresAtArgType, id WrappingKeyGetIdArgType, keyRingId WrappingKeyGetKeyRingIdArgType, protection WrappingKeyGetProtectionArgType, purpose WrappingKeyGetPurposeArgType, state WrappingKeyGetStateArgType) *WrappingKey {
this := WrappingKey{} this := WrappingKey{}
setWrappingKeyGetAccessScopeAttributeType(&this.AccessScope, accessScope) setWrappingKeyGetAccessScopeAttributeType(&this.AccessScope, accessScope)
setWrappingKeyGetAlgorithmAttributeType(&this.Algorithm, algorithm) setWrappingKeyGetAlgorithmAttributeType(&this.Algorithm, algorithm)
setWrappingKeyGetBackendAttributeType(&this.Backend, backend) setWrappingKeyGetBackendAttributeType(&this.Backend, backend)
setWrappingKeyGetCreatedAtAttributeType(&this.CreatedAt, createdAt) setWrappingKeyGetCreatedAtAttributeType(&this.CreatedAt, createdAt)
setWrappingKeyGetDescriptionAttributeType(&this.Description, description)
setWrappingKeyGetDisplayNameAttributeType(&this.DisplayName, displayName) setWrappingKeyGetDisplayNameAttributeType(&this.DisplayName, displayName)
setWrappingKeyGetExpiresAtAttributeType(&this.ExpiresAt, expiresAt) setWrappingKeyGetExpiresAtAttributeType(&this.ExpiresAt, expiresAt)
setWrappingKeyGetIdAttributeType(&this.Id, id) setWrappingKeyGetIdAttributeType(&this.Id, id)
@ -536,19 +534,25 @@ func (o *WrappingKey) SetCreatedAt(v WrappingKeyGetCreatedAtRetType) {
setWrappingKeyGetCreatedAtAttributeType(&o.CreatedAt, v) setWrappingKeyGetCreatedAtAttributeType(&o.CreatedAt, v)
} }
// GetDescription returns the Description field value // GetDescription returns the Description field value if set, zero value otherwise.
func (o *WrappingKey) GetDescription() (ret WrappingKeyGetDescriptionRetType) { func (o *WrappingKey) GetDescription() (res WrappingKeyGetDescriptionRetType) {
ret, _ = o.GetDescriptionOk() res, _ = o.GetDescriptionOk()
return ret return
} }
// GetDescriptionOk returns a tuple with the Description field value // GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise
// and a boolean to check if the value has been set. // and a boolean to check if the value has been set.
func (o *WrappingKey) GetDescriptionOk() (ret WrappingKeyGetDescriptionRetType, ok bool) { func (o *WrappingKey) GetDescriptionOk() (ret WrappingKeyGetDescriptionRetType, ok bool) {
return getWrappingKeyGetDescriptionAttributeTypeOk(o.Description) return getWrappingKeyGetDescriptionAttributeTypeOk(o.Description)
} }
// SetDescription sets field value // HasDescription returns a boolean if a field has been set.
func (o *WrappingKey) HasDescription() bool {
_, ok := o.GetDescriptionOk()
return ok
}
// SetDescription gets a reference to the given string and assigns it to the Description field.
func (o *WrappingKey) SetDescription(v WrappingKeyGetDescriptionRetType) { func (o *WrappingKey) SetDescription(v WrappingKeyGetDescriptionRetType) {
setWrappingKeyGetDescriptionAttributeType(&o.Description, v) setWrappingKeyGetDescriptionAttributeType(&o.Description, v)
} }

View file

@ -38,6 +38,26 @@ func setGetInstanceResponseGetBackupScheduleAttributeType(arg *GetInstanceRespon
type GetInstanceResponseGetBackupScheduleArgType = string type GetInstanceResponseGetBackupScheduleArgType = string
type GetInstanceResponseGetBackupScheduleRetType = string type GetInstanceResponseGetBackupScheduleRetType = string
/*
types and functions for connectionInfo
*/
// isModel
type GetInstanceResponseGetConnectionInfoAttributeType = *InstanceConnectionInfo
type GetInstanceResponseGetConnectionInfoArgType = InstanceConnectionInfo
type GetInstanceResponseGetConnectionInfoRetType = InstanceConnectionInfo
func getGetInstanceResponseGetConnectionInfoAttributeTypeOk(arg GetInstanceResponseGetConnectionInfoAttributeType) (ret GetInstanceResponseGetConnectionInfoRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setGetInstanceResponseGetConnectionInfoAttributeType(arg *GetInstanceResponseGetConnectionInfoAttributeType, val GetInstanceResponseGetConnectionInfoRetType) {
*arg = &val
}
/* /*
types and functions for encryption types and functions for encryption
*/ */
@ -267,6 +287,8 @@ type GetInstanceResponse struct {
// The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule. // The schedule for on what time and how often the database backup will be created. The schedule is written as a cron schedule.
// REQUIRED // REQUIRED
BackupSchedule GetInstanceResponseGetBackupScheduleAttributeType `json:"backupSchedule" required:"true"` BackupSchedule GetInstanceResponseGetBackupScheduleAttributeType `json:"backupSchedule" required:"true"`
// REQUIRED
ConnectionInfo GetInstanceResponseGetConnectionInfoAttributeType `json:"connectionInfo" required:"true"`
Encryption GetInstanceResponseGetEncryptionAttributeType `json:"encryption,omitempty"` Encryption GetInstanceResponseGetEncryptionAttributeType `json:"encryption,omitempty"`
// The id of the instance flavor. // The id of the instance flavor.
// REQUIRED // REQUIRED
@ -303,9 +325,10 @@ type _GetInstanceResponse GetInstanceResponse
// This constructor will assign default values to properties that have it defined, // This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments // and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed // will change when the set of required properties is changed
func NewGetInstanceResponse(backupSchedule GetInstanceResponseGetBackupScheduleArgType, flavorId GetInstanceResponseGetFlavorIdArgType, id GetInstanceResponseGetIdArgType, isDeletable GetInstanceResponsegetIsDeletableArgType, name GetInstanceResponseGetNameArgType, network GetInstanceResponseGetNetworkArgType, replicas GetInstanceResponseGetReplicasArgType, retentionDays GetInstanceResponseGetRetentionDaysArgType, status GetInstanceResponseGetStatusArgType, storage GetInstanceResponseGetStorageArgType, version GetInstanceResponseGetVersionArgType) *GetInstanceResponse { func NewGetInstanceResponse(backupSchedule GetInstanceResponseGetBackupScheduleArgType, connectionInfo GetInstanceResponseGetConnectionInfoArgType, flavorId GetInstanceResponseGetFlavorIdArgType, id GetInstanceResponseGetIdArgType, isDeletable GetInstanceResponsegetIsDeletableArgType, name GetInstanceResponseGetNameArgType, network GetInstanceResponseGetNetworkArgType, replicas GetInstanceResponseGetReplicasArgType, retentionDays GetInstanceResponseGetRetentionDaysArgType, status GetInstanceResponseGetStatusArgType, storage GetInstanceResponseGetStorageArgType, version GetInstanceResponseGetVersionArgType) *GetInstanceResponse {
this := GetInstanceResponse{} this := GetInstanceResponse{}
setGetInstanceResponseGetBackupScheduleAttributeType(&this.BackupSchedule, backupSchedule) setGetInstanceResponseGetBackupScheduleAttributeType(&this.BackupSchedule, backupSchedule)
setGetInstanceResponseGetConnectionInfoAttributeType(&this.ConnectionInfo, connectionInfo)
setGetInstanceResponseGetFlavorIdAttributeType(&this.FlavorId, flavorId) setGetInstanceResponseGetFlavorIdAttributeType(&this.FlavorId, flavorId)
setGetInstanceResponseGetIdAttributeType(&this.Id, id) setGetInstanceResponseGetIdAttributeType(&this.Id, id)
setGetInstanceResponsegetIsDeletableAttributeType(&this.IsDeletable, isDeletable) setGetInstanceResponsegetIsDeletableAttributeType(&this.IsDeletable, isDeletable)
@ -344,6 +367,23 @@ func (o *GetInstanceResponse) SetBackupSchedule(v GetInstanceResponseGetBackupSc
setGetInstanceResponseGetBackupScheduleAttributeType(&o.BackupSchedule, v) setGetInstanceResponseGetBackupScheduleAttributeType(&o.BackupSchedule, v)
} }
// GetConnectionInfo returns the ConnectionInfo field value
func (o *GetInstanceResponse) GetConnectionInfo() (ret GetInstanceResponseGetConnectionInfoRetType) {
ret, _ = o.GetConnectionInfoOk()
return ret
}
// GetConnectionInfoOk returns a tuple with the ConnectionInfo field value
// and a boolean to check if the value has been set.
func (o *GetInstanceResponse) GetConnectionInfoOk() (ret GetInstanceResponseGetConnectionInfoRetType, ok bool) {
return getGetInstanceResponseGetConnectionInfoAttributeTypeOk(o.ConnectionInfo)
}
// SetConnectionInfo sets field value
func (o *GetInstanceResponse) SetConnectionInfo(v GetInstanceResponseGetConnectionInfoRetType) {
setGetInstanceResponseGetConnectionInfoAttributeType(&o.ConnectionInfo, v)
}
// GetEncryption returns the Encryption field value if set, zero value otherwise. // GetEncryption returns the Encryption field value if set, zero value otherwise.
func (o *GetInstanceResponse) GetEncryption() (res GetInstanceResponseGetEncryptionRetType) { func (o *GetInstanceResponse) GetEncryption() (res GetInstanceResponseGetEncryptionRetType) {
res, _ = o.GetEncryptionOk() res, _ = o.GetEncryptionOk()
@ -542,6 +582,12 @@ func (o GetInstanceResponse) ToMap() (map[string]interface{}, error) {
if val, ok := getGetInstanceResponseGetBackupScheduleAttributeTypeOk(o.BackupSchedule); ok { if val, ok := getGetInstanceResponseGetBackupScheduleAttributeTypeOk(o.BackupSchedule); ok {
toSerialize["BackupSchedule"] = val toSerialize["BackupSchedule"] = val
} }
if val, ok := getGetInstanceResponseGetConnectionInfoAttributeTypeOk(o.ConnectionInfo); ok {
toSerialize["ConnectionInfo"] = val
}
if val, ok := getGetInstanceResponseGetEncryptionAttributeTypeOk(o.Encryption); ok {
toSerialize["Encryption"] = val
}
if val, ok := getGetInstanceResponseGetFlavorIdAttributeTypeOk(o.FlavorId); ok { if val, ok := getGetInstanceResponseGetFlavorIdAttributeTypeOk(o.FlavorId); ok {
toSerialize["FlavorId"] = val toSerialize["FlavorId"] = val
} }

View file

@ -354,6 +354,7 @@ type ApiGetVPNGatewayStatusRequest interface {
} }
type ApiListGatewayConnectionsRequest interface { type ApiListGatewayConnectionsRequest interface {
LabelSelector(labelSelector map[string]string) ApiListGatewayConnectionsRequest
Execute() (*ConnectionList, error) Execute() (*ConnectionList, error)
} }
@ -1860,11 +1861,17 @@ func (a *APIClient) GetVPNGatewayStatusExecute(ctx context.Context, projectId st
} }
type ListGatewayConnectionsRequest struct { type ListGatewayConnectionsRequest struct {
ctx context.Context ctx context.Context
apiService *DefaultApiService apiService *DefaultApiService
projectId string projectId string
region Region region Region
gatewayName string gatewayName string
labelSelector *map[string]string
}
func (r ListGatewayConnectionsRequest) LabelSelector(labelSelector map[string]string) ApiListGatewayConnectionsRequest {
r.labelSelector = &labelSelector
return r
} }
func (r ListGatewayConnectionsRequest) Execute() (*ConnectionList, error) { func (r ListGatewayConnectionsRequest) Execute() (*ConnectionList, error) {
@ -1893,6 +1900,9 @@ func (r ListGatewayConnectionsRequest) Execute() (*ConnectionList, error) {
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
localVarFormParams := url.Values{} localVarFormParams := url.Values{}
if r.labelSelector != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "label_selector", r.labelSelector, "")
}
// to determine the Content-Type header // to determine the Content-Type header
localVarHTTPContentTypes := []string{} localVarHTTPContentTypes := []string{}

View file

@ -37,6 +37,26 @@ func setConnectiongetEnabledAttributeType(arg *ConnectiongetEnabledAttributeType
*arg = &val *arg = &val
} }
/*
types and functions for labels
*/
// isContainer
type ConnectionGetLabelsAttributeType = *map[string]string
type ConnectionGetLabelsArgType = map[string]string
type ConnectionGetLabelsRetType = map[string]string
func getConnectionGetLabelsAttributeTypeOk(arg ConnectionGetLabelsAttributeType) (ret ConnectionGetLabelsRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setConnectionGetLabelsAttributeType(arg *ConnectionGetLabelsAttributeType, val ConnectionGetLabelsRetType) {
*arg = &val
}
/* /*
types and functions for localSubnets types and functions for localSubnets
*/ */
@ -142,6 +162,8 @@ func setConnectionGetTunnel2AttributeType(arg *ConnectionGetTunnel2AttributeType
type Connection struct { type Connection struct {
// This flag decides whether this connection should be enabled or disabled // This flag decides whether this connection should be enabled or disabled
Enabled ConnectiongetEnabledAttributeType `json:"enabled,omitempty"` Enabled ConnectiongetEnabledAttributeType `json:"enabled,omitempty"`
// Map of custom labels. Key and values must be max 63 chars, start/end with alphanumeric.
Labels ConnectionGetLabelsAttributeType `json:"labels,omitempty"`
// List of local subnets (IPv4 CIDR). // List of local subnets (IPv4 CIDR).
// REQUIRED // REQUIRED
LocalSubnets ConnectionGetLocalSubnetsAttributeType `json:"localSubnets" required:"true"` LocalSubnets ConnectionGetLocalSubnetsAttributeType `json:"localSubnets" required:"true"`
@ -204,6 +226,29 @@ func (o *Connection) SetEnabled(v ConnectiongetEnabledRetType) {
setConnectiongetEnabledAttributeType(&o.Enabled, v) setConnectiongetEnabledAttributeType(&o.Enabled, v)
} }
// GetLabels returns the Labels field value if set, zero value otherwise.
func (o *Connection) GetLabels() (res ConnectionGetLabelsRetType) {
res, _ = o.GetLabelsOk()
return
}
// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Connection) GetLabelsOk() (ret ConnectionGetLabelsRetType, ok bool) {
return getConnectionGetLabelsAttributeTypeOk(o.Labels)
}
// HasLabels returns a boolean if a field has been set.
func (o *Connection) HasLabels() bool {
_, ok := o.GetLabelsOk()
return ok
}
// SetLabels gets a reference to the given map[string]string and assigns it to the Labels field.
func (o *Connection) SetLabels(v ConnectionGetLabelsRetType) {
setConnectionGetLabelsAttributeType(&o.Labels, v)
}
// GetLocalSubnets returns the LocalSubnets field value // GetLocalSubnets returns the LocalSubnets field value
func (o *Connection) GetLocalSubnets() (ret ConnectionGetLocalSubnetsRetType) { func (o *Connection) GetLocalSubnets() (ret ConnectionGetLocalSubnetsRetType) {
ret, _ = o.GetLocalSubnetsOk() ret, _ = o.GetLocalSubnetsOk()
@ -294,6 +339,9 @@ func (o Connection) ToMap() (map[string]interface{}, error) {
if val, ok := getConnectiongetEnabledAttributeTypeOk(o.Enabled); ok { if val, ok := getConnectiongetEnabledAttributeTypeOk(o.Enabled); ok {
toSerialize["Enabled"] = val toSerialize["Enabled"] = val
} }
if val, ok := getConnectionGetLabelsAttributeTypeOk(o.Labels); ok {
toSerialize["Labels"] = val
}
if val, ok := getConnectionGetLocalSubnetsAttributeTypeOk(o.LocalSubnets); ok { if val, ok := getConnectionGetLocalSubnetsAttributeTypeOk(o.LocalSubnets); ok {
toSerialize["LocalSubnets"] = val toSerialize["LocalSubnets"] = val
} }

View file

@ -37,6 +37,26 @@ func setConnectionRequestgetEnabledAttributeType(arg *ConnectionRequestgetEnable
*arg = &val *arg = &val
} }
/*
types and functions for labels
*/
// isContainer
type ConnectionRequestGetLabelsAttributeType = *map[string]string
type ConnectionRequestGetLabelsArgType = map[string]string
type ConnectionRequestGetLabelsRetType = map[string]string
func getConnectionRequestGetLabelsAttributeTypeOk(arg ConnectionRequestGetLabelsAttributeType) (ret ConnectionRequestGetLabelsRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setConnectionRequestGetLabelsAttributeType(arg *ConnectionRequestGetLabelsAttributeType, val ConnectionRequestGetLabelsRetType) {
*arg = &val
}
/* /*
types and functions for localSubnets types and functions for localSubnets
*/ */
@ -142,6 +162,8 @@ func setConnectionRequestGetTunnel2AttributeType(arg *ConnectionRequestGetTunnel
type ConnectionRequest struct { type ConnectionRequest struct {
// This flag decides whether this connection should be enabled or disabled // This flag decides whether this connection should be enabled or disabled
Enabled ConnectionRequestgetEnabledAttributeType `json:"enabled,omitempty"` Enabled ConnectionRequestgetEnabledAttributeType `json:"enabled,omitempty"`
// Map of custom labels. Key and values must be max 63 chars, start/end with alphanumeric.
Labels ConnectionRequestGetLabelsAttributeType `json:"labels,omitempty"`
// List of local subnets (IPv4 CIDR). // List of local subnets (IPv4 CIDR).
// REQUIRED // REQUIRED
LocalSubnets ConnectionRequestGetLocalSubnetsAttributeType `json:"localSubnets" required:"true"` LocalSubnets ConnectionRequestGetLocalSubnetsAttributeType `json:"localSubnets" required:"true"`
@ -204,6 +226,29 @@ func (o *ConnectionRequest) SetEnabled(v ConnectionRequestgetEnabledRetType) {
setConnectionRequestgetEnabledAttributeType(&o.Enabled, v) setConnectionRequestgetEnabledAttributeType(&o.Enabled, v)
} }
// GetLabels returns the Labels field value if set, zero value otherwise.
func (o *ConnectionRequest) GetLabels() (res ConnectionRequestGetLabelsRetType) {
res, _ = o.GetLabelsOk()
return
}
// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ConnectionRequest) GetLabelsOk() (ret ConnectionRequestGetLabelsRetType, ok bool) {
return getConnectionRequestGetLabelsAttributeTypeOk(o.Labels)
}
// HasLabels returns a boolean if a field has been set.
func (o *ConnectionRequest) HasLabels() bool {
_, ok := o.GetLabelsOk()
return ok
}
// SetLabels gets a reference to the given map[string]string and assigns it to the Labels field.
func (o *ConnectionRequest) SetLabels(v ConnectionRequestGetLabelsRetType) {
setConnectionRequestGetLabelsAttributeType(&o.Labels, v)
}
// GetLocalSubnets returns the LocalSubnets field value // GetLocalSubnets returns the LocalSubnets field value
func (o *ConnectionRequest) GetLocalSubnets() (ret ConnectionRequestGetLocalSubnetsRetType) { func (o *ConnectionRequest) GetLocalSubnets() (ret ConnectionRequestGetLocalSubnetsRetType) {
ret, _ = o.GetLocalSubnetsOk() ret, _ = o.GetLocalSubnetsOk()
@ -294,6 +339,9 @@ func (o ConnectionRequest) ToMap() (map[string]interface{}, error) {
if val, ok := getConnectionRequestgetEnabledAttributeTypeOk(o.Enabled); ok { if val, ok := getConnectionRequestgetEnabledAttributeTypeOk(o.Enabled); ok {
toSerialize["Enabled"] = val toSerialize["Enabled"] = val
} }
if val, ok := getConnectionRequestGetLabelsAttributeTypeOk(o.Labels); ok {
toSerialize["Labels"] = val
}
if val, ok := getConnectionRequestGetLocalSubnetsAttributeTypeOk(o.LocalSubnets); ok { if val, ok := getConnectionRequestGetLocalSubnetsAttributeTypeOk(o.LocalSubnets); ok {
toSerialize["LocalSubnets"] = val toSerialize["LocalSubnets"] = val
} }

View file

@ -37,6 +37,26 @@ func setCreateGatewayConnectionPayloadgetEnabledAttributeType(arg *CreateGateway
*arg = &val *arg = &val
} }
/*
types and functions for labels
*/
// isContainer
type CreateGatewayConnectionPayloadGetLabelsAttributeType = *map[string]string
type CreateGatewayConnectionPayloadGetLabelsArgType = map[string]string
type CreateGatewayConnectionPayloadGetLabelsRetType = map[string]string
func getCreateGatewayConnectionPayloadGetLabelsAttributeTypeOk(arg CreateGatewayConnectionPayloadGetLabelsAttributeType) (ret CreateGatewayConnectionPayloadGetLabelsRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setCreateGatewayConnectionPayloadGetLabelsAttributeType(arg *CreateGatewayConnectionPayloadGetLabelsAttributeType, val CreateGatewayConnectionPayloadGetLabelsRetType) {
*arg = &val
}
/* /*
types and functions for localSubnets types and functions for localSubnets
*/ */
@ -142,6 +162,8 @@ func setCreateGatewayConnectionPayloadGetTunnel2AttributeType(arg *CreateGateway
type CreateGatewayConnectionPayload struct { type CreateGatewayConnectionPayload struct {
// This flag decides whether this connection should be enabled or disabled // This flag decides whether this connection should be enabled or disabled
Enabled CreateGatewayConnectionPayloadgetEnabledAttributeType `json:"enabled,omitempty"` Enabled CreateGatewayConnectionPayloadgetEnabledAttributeType `json:"enabled,omitempty"`
// Map of custom labels. Key and values must be max 63 chars, start/end with alphanumeric.
Labels CreateGatewayConnectionPayloadGetLabelsAttributeType `json:"labels,omitempty"`
// List of local subnets (IPv4 CIDR). // List of local subnets (IPv4 CIDR).
// REQUIRED // REQUIRED
LocalSubnets CreateGatewayConnectionPayloadGetLocalSubnetsAttributeType `json:"localSubnets" required:"true"` LocalSubnets CreateGatewayConnectionPayloadGetLocalSubnetsAttributeType `json:"localSubnets" required:"true"`
@ -204,6 +226,29 @@ func (o *CreateGatewayConnectionPayload) SetEnabled(v CreateGatewayConnectionPay
setCreateGatewayConnectionPayloadgetEnabledAttributeType(&o.Enabled, v) setCreateGatewayConnectionPayloadgetEnabledAttributeType(&o.Enabled, v)
} }
// GetLabels returns the Labels field value if set, zero value otherwise.
func (o *CreateGatewayConnectionPayload) GetLabels() (res CreateGatewayConnectionPayloadGetLabelsRetType) {
res, _ = o.GetLabelsOk()
return
}
// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CreateGatewayConnectionPayload) GetLabelsOk() (ret CreateGatewayConnectionPayloadGetLabelsRetType, ok bool) {
return getCreateGatewayConnectionPayloadGetLabelsAttributeTypeOk(o.Labels)
}
// HasLabels returns a boolean if a field has been set.
func (o *CreateGatewayConnectionPayload) HasLabels() bool {
_, ok := o.GetLabelsOk()
return ok
}
// SetLabels gets a reference to the given map[string]string and assigns it to the Labels field.
func (o *CreateGatewayConnectionPayload) SetLabels(v CreateGatewayConnectionPayloadGetLabelsRetType) {
setCreateGatewayConnectionPayloadGetLabelsAttributeType(&o.Labels, v)
}
// GetLocalSubnets returns the LocalSubnets field value // GetLocalSubnets returns the LocalSubnets field value
func (o *CreateGatewayConnectionPayload) GetLocalSubnets() (ret CreateGatewayConnectionPayloadGetLocalSubnetsRetType) { func (o *CreateGatewayConnectionPayload) GetLocalSubnets() (ret CreateGatewayConnectionPayloadGetLocalSubnetsRetType) {
ret, _ = o.GetLocalSubnetsOk() ret, _ = o.GetLocalSubnetsOk()
@ -294,6 +339,9 @@ func (o CreateGatewayConnectionPayload) ToMap() (map[string]interface{}, error)
if val, ok := getCreateGatewayConnectionPayloadgetEnabledAttributeTypeOk(o.Enabled); ok { if val, ok := getCreateGatewayConnectionPayloadgetEnabledAttributeTypeOk(o.Enabled); ok {
toSerialize["Enabled"] = val toSerialize["Enabled"] = val
} }
if val, ok := getCreateGatewayConnectionPayloadGetLabelsAttributeTypeOk(o.Labels); ok {
toSerialize["Labels"] = val
}
if val, ok := getCreateGatewayConnectionPayloadGetLocalSubnetsAttributeTypeOk(o.LocalSubnets); ok { if val, ok := getCreateGatewayConnectionPayloadGetLocalSubnetsAttributeTypeOk(o.LocalSubnets); ok {
toSerialize["LocalSubnets"] = val toSerialize["LocalSubnets"] = val
} }

View file

@ -37,6 +37,26 @@ func setUpdateGatewayConnectionPayloadgetEnabledAttributeType(arg *UpdateGateway
*arg = &val *arg = &val
} }
/*
types and functions for labels
*/
// isContainer
type UpdateGatewayConnectionPayloadGetLabelsAttributeType = *map[string]string
type UpdateGatewayConnectionPayloadGetLabelsArgType = map[string]string
type UpdateGatewayConnectionPayloadGetLabelsRetType = map[string]string
func getUpdateGatewayConnectionPayloadGetLabelsAttributeTypeOk(arg UpdateGatewayConnectionPayloadGetLabelsAttributeType) (ret UpdateGatewayConnectionPayloadGetLabelsRetType, ok bool) {
if arg == nil {
return ret, false
}
return *arg, true
}
func setUpdateGatewayConnectionPayloadGetLabelsAttributeType(arg *UpdateGatewayConnectionPayloadGetLabelsAttributeType, val UpdateGatewayConnectionPayloadGetLabelsRetType) {
*arg = &val
}
/* /*
types and functions for localSubnets types and functions for localSubnets
*/ */
@ -142,6 +162,8 @@ func setUpdateGatewayConnectionPayloadGetTunnel2AttributeType(arg *UpdateGateway
type UpdateGatewayConnectionPayload struct { type UpdateGatewayConnectionPayload struct {
// This flag decides whether this connection should be enabled or disabled // This flag decides whether this connection should be enabled or disabled
Enabled UpdateGatewayConnectionPayloadgetEnabledAttributeType `json:"enabled,omitempty"` Enabled UpdateGatewayConnectionPayloadgetEnabledAttributeType `json:"enabled,omitempty"`
// Map of custom labels. Key and values must be max 63 chars, start/end with alphanumeric.
Labels UpdateGatewayConnectionPayloadGetLabelsAttributeType `json:"labels,omitempty"`
// List of local subnets (IPv4 CIDR). // List of local subnets (IPv4 CIDR).
// REQUIRED // REQUIRED
LocalSubnets UpdateGatewayConnectionPayloadGetLocalSubnetsAttributeType `json:"localSubnets" required:"true"` LocalSubnets UpdateGatewayConnectionPayloadGetLocalSubnetsAttributeType `json:"localSubnets" required:"true"`
@ -204,6 +226,29 @@ func (o *UpdateGatewayConnectionPayload) SetEnabled(v UpdateGatewayConnectionPay
setUpdateGatewayConnectionPayloadgetEnabledAttributeType(&o.Enabled, v) setUpdateGatewayConnectionPayloadgetEnabledAttributeType(&o.Enabled, v)
} }
// GetLabels returns the Labels field value if set, zero value otherwise.
func (o *UpdateGatewayConnectionPayload) GetLabels() (res UpdateGatewayConnectionPayloadGetLabelsRetType) {
res, _ = o.GetLabelsOk()
return
}
// GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UpdateGatewayConnectionPayload) GetLabelsOk() (ret UpdateGatewayConnectionPayloadGetLabelsRetType, ok bool) {
return getUpdateGatewayConnectionPayloadGetLabelsAttributeTypeOk(o.Labels)
}
// HasLabels returns a boolean if a field has been set.
func (o *UpdateGatewayConnectionPayload) HasLabels() bool {
_, ok := o.GetLabelsOk()
return ok
}
// SetLabels gets a reference to the given map[string]string and assigns it to the Labels field.
func (o *UpdateGatewayConnectionPayload) SetLabels(v UpdateGatewayConnectionPayloadGetLabelsRetType) {
setUpdateGatewayConnectionPayloadGetLabelsAttributeType(&o.Labels, v)
}
// GetLocalSubnets returns the LocalSubnets field value // GetLocalSubnets returns the LocalSubnets field value
func (o *UpdateGatewayConnectionPayload) GetLocalSubnets() (ret UpdateGatewayConnectionPayloadGetLocalSubnetsRetType) { func (o *UpdateGatewayConnectionPayload) GetLocalSubnets() (ret UpdateGatewayConnectionPayloadGetLocalSubnetsRetType) {
ret, _ = o.GetLocalSubnetsOk() ret, _ = o.GetLocalSubnetsOk()
@ -294,6 +339,9 @@ func (o UpdateGatewayConnectionPayload) ToMap() (map[string]interface{}, error)
if val, ok := getUpdateGatewayConnectionPayloadgetEnabledAttributeTypeOk(o.Enabled); ok { if val, ok := getUpdateGatewayConnectionPayloadgetEnabledAttributeTypeOk(o.Enabled); ok {
toSerialize["Enabled"] = val toSerialize["Enabled"] = val
} }
if val, ok := getUpdateGatewayConnectionPayloadGetLabelsAttributeTypeOk(o.Labels); ok {
toSerialize["Labels"] = val
}
if val, ok := getUpdateGatewayConnectionPayloadGetLocalSubnetsAttributeTypeOk(o.LocalSubnets); ok { if val, ok := getUpdateGatewayConnectionPayloadGetLocalSubnetsAttributeTypeOk(o.LocalSubnets); ok {
toSerialize["LocalSubnets"] = val toSerialize["LocalSubnets"] = val
} }

View file

@ -67,6 +67,9 @@ func CreateInstanceWaitHandler(
if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil { if s == nil || s.Id == nil || *s.Id != instanceId || s.Status == nil {
return false, nil, nil return false, nil, nil
} }
tflog.Debug(ctx, "waiting for instance ready", map[string]interface{}{
"status": *s.Status,
})
switch *s.Status { switch *s.Status {
default: default:
return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status) return true, s, fmt.Errorf("instance with id %s has unexpected status %s", instanceId, *s.Status)
@ -92,17 +95,19 @@ func CreateInstanceWaitHandler(
if extendedTimeout < 3 { if extendedTimeout < 3 {
maxWait = maxWait + time.Minute*5 maxWait = maxWait + time.Minute*5
extendedTimeout = extendedTimeout + 1 extendedTimeout = extendedTimeout + 1
if s.Network == nil || s.Network.InstanceAddress == nil { if *s.Network.AccessScope == "SNA" {
tflog.Warn(ctx, "Waiting for instance_address") ready := true
return false, nil, nil if s.Network == nil || s.Network.InstanceAddress == nil {
} tflog.Warn(ctx, "Waiting for instance_address")
if s.Network.RouterAddress == nil { ready = false
tflog.Warn(ctx, "Waiting for router_address") }
return false, nil, nil if s.Network.RouterAddress == nil {
} tflog.Warn(ctx, "Waiting for router_address")
if s.Status == nil { ready = false
tflog.Warn(ctx, "Waiting for status") }
return false, nil, nil if !ready {
return false, nil, nil
}
} }
if s.IsDeletable == nil { if s.IsDeletable == nil {
tflog.Warn(ctx, "Waiting for is_deletable") tflog.Warn(ctx, "Waiting for is_deletable")
@ -113,13 +118,15 @@ func CreateInstanceWaitHandler(
instanceCreated = true instanceCreated = true
instanceGetResponse = s instanceGetResponse = s
case InstanceStateSuccess: case InstanceStateSuccess:
if s.Network == nil || s.Network.InstanceAddress == nil { if *s.Network.AccessScope == "SNA" {
tflog.Warn(ctx, "Waiting for instance_address") if s.Network == nil || s.Network.InstanceAddress == nil {
return false, nil, nil tflog.Warn(ctx, "Waiting for instance_address")
} return false, nil, nil
if s.Network.RouterAddress == nil { }
tflog.Info(ctx, "Waiting for router_address") if s.Network.RouterAddress == nil {
return false, nil, nil tflog.Info(ctx, "Waiting for router_address")
return false, nil, nil
}
} }
instanceCreated = true instanceCreated = true
instanceGetResponse = s instanceGetResponse = s

View file

@ -135,7 +135,7 @@ func Build() error {
if err = cmd.Wait(); err != nil { if err = cmd.Wait(); err != nil {
var exitErr *exec.ExitError var exitErr *exec.ExitError
if errors.As(err, &exitErr) { if errors.As(err, &exitErr) {
slog.Error("cmd.Wait", "code", exitErr.ExitCode()) slog.Error("cmd.Wait", "code", exitErr.ExitCode(), "error", err, "stdout", stdOut.String(), "stderr", stdErr.String())
return fmt.Errorf("%s", stdErr.String()) return fmt.Errorf("%s", stdErr.String())
} }
if err != nil { if err != nil {
@ -486,7 +486,7 @@ func generateServiceFiles(rootDir, generatorDir string) error {
if err = cmd2.Wait(); err != nil { if err = cmd2.Wait(); err != nil {
var exitErr *exec.ExitError var exitErr *exec.ExitError
if errors.As(err, &exitErr) { if errors.As(err, &exitErr) {
slog.Error("cmd.Wait", "code", exitErr.ExitCode()) slog.Error("cmd.Wait", "code", exitErr.ExitCode(), "error", err)
return fmt.Errorf("%s", stdErr.String()) return fmt.Errorf("%s", stdErr.String())
} }
if err != nil { if err != nil {
@ -528,7 +528,7 @@ func generateServiceFiles(rootDir, generatorDir string) error {
if err = cmd3.Wait(); err != nil { if err = cmd3.Wait(); err != nil {
var exitErr *exec.ExitError var exitErr *exec.ExitError
if errors.As(err, &exitErr) { if errors.As(err, &exitErr) {
slog.Error("cmd.Wait", "code", exitErr.ExitCode()) slog.Error("cmd.Wait", "code", exitErr.ExitCode(), "error", err)
return fmt.Errorf("%s", stdErr.String()) return fmt.Errorf("%s", stdErr.String())
} }
if err != nil { if err != nil {