Skip to content

Commit 0575554

Browse files
committed
fix merge conflicts
1 parent c5f71ab commit 0575554

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

core/auth/auth.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,14 @@ func KeyAuth(cfg *config.Configuration) (http.RoundTripper, error) {
235235
}
236236

237237
// StackitCliAuth configures the [clients.STACKITCLIFlow] and returns an http.RoundTripper
238-
func StackitCliAuth(_ *config.Configuration) (http.RoundTripper, error) {
238+
func StackitCliAuth(cfg *config.Configuration) (http.RoundTripper, error) {
239+
cliCfg := clients.STACKITCLIFlowConfig{}
240+
if cfg.HTTPClient != nil && cfg.HTTPClient.Transport != nil {
241+
cliCfg.HTTPTransport = cfg.HTTPClient.Transport
242+
}
243+
239244
client := &clients.STACKITCLIFlow{}
240-
if err := client.Init(&clients.STACKITCLIFlowConfig{}); err != nil {
245+
if err := client.Init(&cliCfg); err != nil {
241246
return nil, fmt.Errorf("error initializing client: %w", err)
242247
}
243248

core/clients/stackit_cli_flow.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"errors"
7+
"net/http"
78
"os"
89
"os/exec"
910
"runtime"
@@ -17,25 +18,25 @@ type STACKITCLIFlow struct {
1718
}
1819

1920
// STACKITCLIFlowConfig is the flow config
20-
type STACKITCLIFlowConfig struct{}
21+
type STACKITCLIFlowConfig struct {
22+
HTTPTransport http.RoundTripper
23+
}
2124

2225
// GetConfig returns the flow configuration
2326
func (c *STACKITCLIFlow) GetConfig() STACKITCLIFlowConfig {
2427
return STACKITCLIFlowConfig{}
2528
}
2629

27-
func (c *STACKITCLIFlow) Init(_ *STACKITCLIFlowConfig) error {
30+
func (c *STACKITCLIFlow) Init(cfg *STACKITCLIFlowConfig) error {
2831
token, err := c.getTokenFromCLI()
2932
if err != nil {
3033
return err
3134
}
3235

33-
c.config = &TokenFlowConfig{
36+
return c.TokenFlow.Init(&TokenFlowConfig{
3437
ServiceAccountToken: strings.TrimSpace(token),
35-
}
36-
37-
c.configureHTTPClient()
38-
return c.validate()
38+
HTTPTransport: cfg.HTTPTransport,
39+
})
3940
}
4041

4142
func (c *STACKITCLIFlow) getTokenFromCLI() (string, error) {

core/clients/stackit_cli_flow_test.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package clients
22

33
import (
4+
"context"
45
"fmt"
56
"io"
67
"net/http"
@@ -24,23 +25,25 @@ func TestSTACKITCLIFlow_Init(t *testing.T) {
2425
}
2526
for _, tt := range tests {
2627
t.Run(tt.name, func(t *testing.T) {
28+
ctx := context.TODO()
29+
2730
c := &STACKITCLIFlow{}
2831

29-
_, _ = runSTACKITCLICommand(t.Context(), "stackit config profile delete test-stackit-cli-flow-init -y")
30-
_, err := runSTACKITCLICommand(t.Context(), "stackit config profile create test-stackit-cli-flow-init")
32+
_, _ = runSTACKITCLICommand(ctx, "stackit config profile delete test-stackit-cli-flow-init -y")
33+
_, err := runSTACKITCLICommand(ctx, "stackit config profile create test-stackit-cli-flow-init")
3134
if err != nil {
3235
t.Errorf("runSTACKITCLICommand() error = %v", err)
3336
return
3437
}
3538

36-
_, err = runSTACKITCLICommand(t.Context(), "stackit auth activate-service-account --service-account-token="+testServiceAccountToken)
39+
_, err = runSTACKITCLICommand(ctx, "stackit auth activate-service-account --service-account-token="+testServiceAccountToken)
3740
if err != nil {
3841
t.Errorf("runSTACKITCLICommand() error = %v", err)
3942
return
4043
}
4144

4245
defer func() {
43-
_, _ = runSTACKITCLICommand(t.Context(), "stackit config profile delete test-stackit-cli-flow-init -y")
46+
_, _ = runSTACKITCLICommand(ctx, "stackit config profile delete test-stackit-cli-flow-init -y")
4447
}()
4548

4649
if err := c.Init(tt.args.cfg); (err != nil) != tt.wantErr {
@@ -70,21 +73,23 @@ func TestSTACKITCLIFlow_Do(t *testing.T) {
7073
}
7174
for _, tt := range tests {
7275
t.Run(tt.name, func(t *testing.T) {
73-
_, _ = runSTACKITCLICommand(t.Context(), "stackit config profile delete test-stackit-cli-flow-do -y")
74-
_, err := runSTACKITCLICommand(t.Context(), "stackit config profile create test-stackit-cli-flow-do")
76+
ctx := context.TODO()
77+
78+
_, _ = runSTACKITCLICommand(ctx, "stackit config profile delete test-stackit-cli-flow-do -y")
79+
_, err := runSTACKITCLICommand(ctx, "stackit config profile create test-stackit-cli-flow-do")
7580
if err != nil {
7681
t.Errorf("runSTACKITCLICommand() error = %v", err)
7782
return
7883
}
7984

80-
_, err = runSTACKITCLICommand(t.Context(), "stackit auth activate-service-account --service-account-token="+testServiceAccountToken)
85+
_, err = runSTACKITCLICommand(ctx, "stackit auth activate-service-account --service-account-token="+testServiceAccountToken)
8186
if err != nil {
8287
t.Errorf("runSTACKITCLICommand() error = %v", err)
8388
return
8489
}
8590

8691
defer func() {
87-
_, _ = runSTACKITCLICommand(t.Context(), "stackit config profile delete test-stackit-cli-flow-do -y")
92+
_, _ = runSTACKITCLICommand(ctx, "stackit config profile delete test-stackit-cli-flow-do -y")
8893
}()
8994

9095
c := &STACKITCLIFlow{}

0 commit comments

Comments
 (0)