Skip to content

Commit 509001e

Browse files
authored
Merge branch 'main' into update-user-login
2 parents 9c3251a + ac6919d commit 509001e

File tree

1,026 files changed

+24354
-24487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,026 files changed

+24354
-24487
lines changed

.github/docs/contribution-guide/client.go

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,12 @@ package client
22

33
import (
44
"github.com/spf13/viper"
5-
"github.com/stackitcloud/stackit-cli/internal/pkg/auth"
6-
"github.com/stackitcloud/stackit-cli/internal/pkg/config"
7-
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
5+
genericclient "github.com/stackitcloud/stackit-cli/internal/pkg/generic-client"
86
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
9-
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
10-
sdkConfig "github.com/stackitcloud/stackit-sdk-go/core/config"
117
"github.com/stackitcloud/stackit-sdk-go/services/foo"
128
// (...)
139
)
1410

1511
func ConfigureClient(p *print.Printer, cliVersion string) (*foo.APIClient, error) {
16-
authCfgOption, err := auth.AuthenticationConfig(p, auth.AuthorizeUser)
17-
if err != nil {
18-
return nil, &errors.AuthError{}
19-
}
20-
21-
region := viper.GetString(config.RegionKey)
22-
cfgOptions := []sdkConfig.ConfigurationOption{
23-
utils.UserAgentConfigOption(cliVersion),
24-
sdkConfig.WithRegion(region), // Configuring region is needed if "foo" is a regional API
25-
authCfgOption,
26-
}
27-
28-
customEndpoint := viper.GetString(config.fooCustomEndpointKey)
29-
30-
if customEndpoint != "" {
31-
cfgOptions = append(cfgOptions, sdkConfig.WithEndpoint(customEndpoint))
32-
}
33-
34-
if p.IsVerbosityDebug() {
35-
cfgOptions = append(cfgOptions,
36-
sdkConfig.WithMiddleware(print.RequestResponseCapturer(p, nil)),
37-
)
38-
}
39-
40-
apiClient, err := foo.NewAPIClient(cfgOptions...)
41-
if err != nil {
42-
p.Debug(print.ErrorLevel, "create new API client: %v", err)
43-
return nil, &errors.AuthError{}
44-
}
45-
46-
return apiClient, nil
12+
return genericclient.ConfigureClientGeneric(p, cliVersion, viper.GetString(config.fooCustomEndpointKey), false, genericclient.CreateApiClient[*foo.APIClient](foo.NewAPIClient))
4713
}

.github/docs/contribution-guide/cmd.go

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package bar
22

33
import (
44
"context"
5-
"encoding/json"
65
"fmt"
76

7+
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
8+
89
"github.com/spf13/cobra"
9-
"github.com/stackitcloud/stackit-cli/internal/cmd/params"
1010
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1111
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
1212
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
@@ -17,7 +17,6 @@ import (
1717
"github.com/stackitcloud/stackit-cli/internal/pkg/services/alb/client"
1818
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
1919
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
20-
"gopkg.in/yaml.v2"
2120
// (...)
2221
)
2322

@@ -35,7 +34,7 @@ type inputModel struct {
3534
}
3635

3736
// "bar" command constructor
38-
func NewCmd(params *params.CmdParams) *cobra.Command {
37+
func NewCmd(params *types.CmdParams) *cobra.Command {
3938
cmd := &cobra.Command{
4039
Use: "bar",
4140
Short: "Short description of the command (is shown in the help of parent command)",
@@ -118,22 +117,8 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *foo.APIClie
118117

119118
// Output result based on the configured output format
120119
func outputResult(p *print.Printer, cmd *cobra.Command, outputFormat string, resources []foo.Resource) error {
121-
switch outputFormat {
122-
case print.JSONOutputFormat:
123-
details, err := json.MarshalIndent(resources, "", " ")
124-
if err != nil {
125-
return fmt.Errorf("marshal resource list: %w", err)
126-
}
127-
p.Outputln(string(details))
128-
return nil
129-
case print.YAMLOutputFormat:
130-
details, err := yaml.Marshal(resources)
131-
if err != nil {
132-
return fmt.Errorf("marshal resource list: %w", err)
133-
}
134-
p.Outputln(string(details))
135-
return nil
136-
default:
120+
// the output result handles JSON/YAML output, you can pass your own callback func for pretty (default) output format
121+
return p.OutputResult(outputFormat, resources, func() error {
137122
table := tables.NewTable()
138123
table.SetHeader("ID", "NAME", "STATE")
139124
for i := range resources {
@@ -145,5 +130,5 @@ func outputResult(p *print.Printer, cmd *cobra.Command, outputFormat string, res
145130
return fmt.Errorf("render table: %w", err)
146131
}
147132
return nil
148-
}
133+
})
149134
}

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v5
20+
uses: actions/checkout@v6
2121

2222
- name: Install go
2323
uses: actions/setup-go@v6
@@ -36,7 +36,7 @@ jobs:
3636
run: make test
3737

3838
- name: Archive code coverage results
39-
uses: actions/upload-artifact@v4
39+
uses: actions/upload-artifact@v6
4040
with:
4141
name: ${{ env.CODE_COVERAGE_ARTIFACT_NAME }}
4242
path: ${{ env.CODE_COVERAGE_FILE_NAME }}
@@ -47,7 +47,7 @@ jobs:
4747
runs-on: ubuntu-latest
4848
steps:
4949
- name: Checkout
50-
uses: actions/checkout@v5
50+
uses: actions/checkout@v6
5151

5252
- name: Check GoReleaser
5353
uses: goreleaser/goreleaser-action@v6

.github/workflows/release.yaml

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
2424
steps:
2525
- name: Checkout
26-
uses: actions/checkout@v5
26+
uses: actions/checkout@v6
2727
with:
2828
# Allow goreleaser to access older tag information.
2929
fetch-depth: 0
@@ -41,6 +41,15 @@ jobs:
4141
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
4242
passphrase: ${{ secrets.GPG_PASSPHRASE }}
4343

44+
# nfpm-rpm signing needs gpg provided as filepath
45+
# https://goreleaser.com/customization/nfpm/
46+
- name: Create GPG key file
47+
run: |
48+
KEY_PATH="$RUNNER_TEMP/gpg-private-key.asc"
49+
printf '%s' "${{ secrets.GPG_PRIVATE_KEY }}" > "$KEY_PATH"
50+
chmod 600 "$KEY_PATH"
51+
echo "GPG_KEY_PATH=$KEY_PATH" >> "$GITHUB_ENV"
52+
4453
- name: Set up keychain
4554
run: |
4655
echo -n $SIGNING_CERTIFICATE_BASE64 | base64 -d -o ./ApplicationID.p12
@@ -71,15 +80,22 @@ jobs:
7180
env:
7281
GITHUB_TOKEN: ${{ secrets.CLI_RELEASE }}
7382
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
83+
GPG_KEY_PATH: ${{ env.GPG_KEY_PATH }}
84+
# nfpm-rpm signing needs this env to be set.
85+
NFPM_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
7486

75-
# artifacts need to be passed to the "publish-apt" job somehow
87+
- name: Clean up GPG key file
88+
if: always()
89+
run: |
90+
rm -f "$GPG_KEY_PATH"
91+
7692
- name: Upload artifacts to workflow
77-
uses: actions/upload-artifact@v4
93+
uses: actions/upload-artifact@v6
7894
with:
7995
name: goreleaser-dist-temp
8096
path: dist
8197
retention-days: 1
82-
98+
8399
publish-apt:
84100
name: Publish APT
85101
runs-on: macOS-latest
@@ -90,11 +106,11 @@ jobs:
90106
AWS_SECRET_ACCESS_KEY: ${{ secrets.OBJECT_STORAGE_SECRET_ACCESS_KEY }}
91107
steps:
92108
- name: Checkout
93-
uses: actions/checkout@v5
109+
uses: actions/checkout@v6
94110

95111
# use the artifacts from the "goreleaser" job
96112
- name: Download artifacts from workflow
97-
uses: actions/download-artifact@v5
113+
uses: actions/download-artifact@v6
98114
with:
99115
name: goreleaser-dist-temp
100116
path: dist
@@ -115,3 +131,42 @@ jobs:
115131
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
116132
GPG_PRIVATE_KEY_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
117133
run: ./scripts/publish-apt-packages.sh
134+
135+
publish-rpm:
136+
name: Publish RPM
137+
runs-on: ubuntu-latest
138+
needs: [goreleaser]
139+
env:
140+
# Needed to publish new packages to our S3-hosted RPM repo
141+
AWS_ACCESS_KEY_ID: ${{ secrets.OBJECT_STORAGE_ACCESS_KEY_ID }}
142+
AWS_SECRET_ACCESS_KEY: ${{ secrets.OBJECT_STORAGE_SECRET_ACCESS_KEY }}
143+
AWS_DEFAULT_REGION: eu01
144+
AWS_ENDPOINT_URL: https://object.storage.eu01.onstackit.cloud
145+
steps:
146+
- name: Checkout
147+
uses: actions/checkout@v6
148+
149+
- name: Download artifacts from workflow
150+
uses: actions/download-artifact@v6
151+
with:
152+
name: goreleaser-dist-temp
153+
path: dist
154+
155+
- name: Install RPM tools
156+
run: |
157+
sudo apt-get update
158+
sudo apt-get install -y createrepo-c
159+
160+
- name: Import GPG key
161+
uses: crazy-max/ghaction-import-gpg@v6
162+
id: import_gpg
163+
with:
164+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
165+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
166+
167+
- name: Publish RPM packages
168+
if: contains(github.ref_name, '-') == false
169+
env:
170+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
171+
GPG_PRIVATE_KEY_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
172+
run: ./scripts/publish-rpm-packages.sh

.github/workflows/renovate.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@v5
14+
uses: actions/checkout@v6
1515
- name: Self-hosted Renovate
16-
uses: renovatebot/github-action@v43.0.16
16+
uses: renovatebot/github-action@v44.0.5
1717
with:
1818
configurationFile: .github/renovate.json
1919
token: ${{ secrets.RENOVATE_TOKEN }}

.goreleaser.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,10 @@ nfpms:
9999
- deb
100100
- rpm
101101

102-
signs:
103-
- artifacts: package
104-
args:
105-
[
106-
"-u",
107-
"{{ .Env.GPG_FINGERPRINT }}",
108-
"--output",
109-
"${signature}",
110-
"--detach-sign",
111-
"${artifact}",
112-
]
102+
rpm:
103+
# The package is signed if a key_file is set
104+
signature:
105+
key_file: "{{ .Env.GPG_KEY_PATH }}"
113106

114107
homebrew_casks:
115108
- name: stackit

AUTHENTICATION.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This document describes how you can configure authentication for the STACKIT CLI
44

55
## Service account
66

7-
You can use a [service account](https://docs.stackit.cloud/stackit/en/service-accounts-134415819.html) to authenticate to the STACKIT CLI.
7+
You can use a [service account](https://docs.stackit.cloud/platform/access-and-identity/service-accounts/) to authenticate to the STACKIT CLI.
88
The CLI will search for service account credentials similarly to the [STACKIT SDK](https://github.com/stackitcloud/stackit-sdk-go) and [STACKIT Terraform Provider](https://github.com/stackitcloud/terraform-provider-stackit), so if you have already set up your environment for those tools, you can just run:
99

1010
```bash
@@ -47,14 +47,14 @@ To use the key flow, you need to have a service account key, which must have an
4747

4848
When creating the service account key, a new RSA key-pair can be created automatically, which will be included in the service account key. This will make it much easier to configure the key flow authentication in the CLI, by just providing the service account key.
4949

50-
**Optionally**, you can provide your own private key when creating the service account key, which will then require you to also provide it explicitly to the CLI, additionally to the service account key. Check the STACKIT Knowledge Base for an [example of how to create your own key-pair](https://docs.stackit.cloud/stackit/en/usage-of-the-service-account-keys-in-stackit-175112464.html#UsageoftheserviceaccountkeysinSTACKIT-CreatinganRSAkey-pair).
50+
**Optionally**, you can provide your own private key when creating the service account key, which will then require you to also provide it explicitly to the CLI, additionally to the service account key. Check the STACKIT Docs for an [example of how to create your own key-pair](https://docs.stackit.cloud/platform/access-and-identity/service-accounts/how-tos/manage-service-account-keys/).
5151

5252
To configure the key flow, follow this steps:
5353

5454
1. Create a service account key:
5555

5656
- In the CLI, run `stackit service-account key create --email <SERVICE_ACCOUNT_EMAIL>`
57-
- As an alternative, use the [STACKIT Portal](https://portal.stackit.cloud/): go to the `Service Accounts` tab, choose a `Service Account` and go to `Service Account Keys` to create a key. For more details, see [Create a service account key](https://docs.stackit.cloud/stackit/en/create-a-service-account-key-175112456.html)
57+
- As an alternative, use the [STACKIT Portal](https://portal.stackit.cloud/): go to the `Service Accounts` tab, choose a `Service Account` and go to `Service Account Keys` to create a key. For more details, see [Create a service account key](https://docs.stackit.cloud/platform/access-and-identity/service-accounts/how-tos/manage-service-account-keys/)
5858

5959
2. Save the content of the service account key by copying it and saving it in a JSON file.
6060

INSTALLATION.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,54 @@ asset_filters=["stackit-cli_", "_linux_amd64.tar.gz"]
130130
eget stackitcloud/stackit-cli
131131
```
132132

133-
#### RPM package via dnf, yum and zypper
133+
#### RHEL/Fedora/Rocky/Alma/openSUSE/... (`DNF/YUM/Zypper`)
134134

135-
The STACKIT CLI is available as [RPM Package](https://github.com/stackitcloud/stackit-cli/releases) and can be installed via dnf, yum and zypper package manager.
135+
The STACKIT CLI can be installed through the [`DNF/YUM`](https://docs.fedoraproject.org/en-US/fedora/f40/system-administrators-guide/package-management/DNF/) / [`Zypper`](https://de.opensuse.org/Zypper) package managers.
136136

137-
Just download the rpm package from the [release page](https://github.com/stackitcloud/stackit-cli/releases) and run the install command like the following:
137+
> Requires rpm version 4.15 or newer to support Ed25519 signatures.
138+
139+
> `$basearch` is supported by modern distributions. On older systems that don't expand `$basearch`, replace it in the `baseurl` with your architecture explicitly (for example, `.../rpm/cli/x86_64` or `.../rpm/cli/aarch64`).
140+
141+
##### Installation via DNF/YUM
142+
143+
1. Add the repository:
144+
145+
```shell
146+
sudo tee /etc/yum.repos.d/stackit.repo > /dev/null << 'EOF'
147+
[stackit]
148+
name=STACKIT CLI
149+
baseurl=https://packages.stackit.cloud/rpm/cli/$basearch
150+
enabled=1
151+
gpgcheck=1
152+
gpgkey=https://packages.stackit.cloud/keys/key.gpg
153+
EOF
154+
```
155+
156+
2. Install the CLI:
157+
158+
```shell
159+
sudo dnf install stackit
160+
```
161+
162+
##### Installation via Zypper
163+
164+
1. Add the repository:
165+
166+
```shell
167+
sudo tee /etc/zypp/repos.d/stackit.repo > /dev/null << 'EOF'
168+
[stackit]
169+
name=STACKIT CLI
170+
baseurl=https://packages.stackit.cloud/rpm/cli/$basearch
171+
enabled=1
172+
gpgcheck=1
173+
gpgkey=https://packages.stackit.cloud/keys/key.gpg
174+
EOF
175+
```
176+
177+
2. Install the CLI:
138178

139179
```shell
140-
dnf install stackitcli.rpm
141-
yum install stackitcli.rpm
142-
zypper install stackitcli.rpm
180+
sudo zypper install stackit
143181
```
144182

145183
#### Any distribution

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ROOT_DIR ?= $(shell git rev-parse --show-toplevel)
22
SCRIPTS_BASE ?= $(ROOT_DIR)/scripts
33
GOLANG_CI_YAML_PATH ?= ${ROOT_DIR}/golang-ci.yaml
4-
GOLANG_CI_ARGS ?= --allow-parallel-runners --timeout=5m --config=${GOLANG_CI_YAML_PATH}
4+
GOLANG_CI_ARGS ?= --allow-parallel-runners --config=${GOLANG_CI_YAML_PATH}
55

66
# Build
77
build:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,6 @@ Apache 2.0
202202

203203
- [STACKIT](https://www.stackit.de/en/)
204204

205-
- [STACKIT Knowledge Base](https://docs.stackit.cloud/stackit/en/knowledge-base-85301704.html)
205+
- [STACKIT Docs](https://docs.stackit.cloud/)
206206

207207
- [STACKIT Terraform Provider](https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs)

0 commit comments

Comments
 (0)