mygithub.libinneed.workers.dev/stackitcloud/stackit-cli
Advanced tools
@@ -6,3 +6,3 @@ name: CI | ||
| env: | ||
| GO_VERSION: "1.21" | ||
| GO_VERSION: "1.22" | ||
@@ -9,0 +9,0 @@ jobs: |
+1
-1
@@ -15,3 +15,3 @@ # Contribute to the STACKIT CLI | ||
| - [`Go`](https://go.dev/doc/install) 1.21+ | ||
| - [`Go`](https://go.dev/doc/install) 1.22+ | ||
| - [`yamllint`](https://yamllint.readthedocs.io/en/stable/quickstart.html) | ||
@@ -18,0 +18,0 @@ |
+4
-4
| module github.com/stackitcloud/stackit-cli | ||
| go 1.21 | ||
| go 1.22 | ||
@@ -9,3 +9,3 @@ require ( | ||
| github.com/google/uuid v1.6.0 | ||
| github.com/jedib0t/go-pretty/v6 v6.5.5 | ||
| github.com/jedib0t/go-pretty/v6 v6.5.6 | ||
| github.com/spf13/cobra v1.8.0 | ||
@@ -23,3 +23,3 @@ github.com/spf13/pflag v1.0.5 | ||
| github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.3.6 | ||
| github.com/stackitcloud/stackit-sdk-go/services/ske v0.10.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/ske v0.11.0 | ||
| github.com/zalando/go-keyring v0.2.4 | ||
@@ -64,3 +64,3 @@ golang.org/x/mod v0.16.0 | ||
| google.golang.org/appengine v1.6.8 // indirect | ||
| google.golang.org/protobuf v1.32.0 // indirect | ||
| google.golang.org/protobuf v1.33.0 // indirect | ||
| gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect | ||
@@ -67,0 +67,0 @@ gopkg.in/ini.v1 v1.67.0 // indirect |
+6
-6
@@ -32,4 +32,4 @@ github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0= | ||
| github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= | ||
| github.com/jedib0t/go-pretty/v6 v6.5.5 h1:PpIU8lOjxvVYGGKule0QxxJfNysUSbC9lggQU2cpZJc= | ||
| github.com/jedib0t/go-pretty/v6 v6.5.5/go.mod h1:5LQIxa52oJ/DlDSLv0HEkWOFMDGoWkJb9ss5KqPpJBg= | ||
| github.com/jedib0t/go-pretty/v6 v6.5.6 h1:nKXVLqPfAwY7sWcYXdNZZZ2fjqDpAtj9UeWupgfUxSg= | ||
| github.com/jedib0t/go-pretty/v6 v6.5.6/go.mod h1:5LQIxa52oJ/DlDSLv0HEkWOFMDGoWkJb9ss5KqPpJBg= | ||
| github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= | ||
@@ -107,4 +107,4 @@ github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= | ||
| github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.3.6/go.mod h1:OOciROyQxPOYLo8OM/DE5ESH11+DvAyRt6wg7R+HVkg= | ||
| github.com/stackitcloud/stackit-sdk-go/services/ske v0.10.1 h1:MZABtJ8HFOKG3KCCv5duibxBSAU1zTFAO0V9bso3N9M= | ||
| github.com/stackitcloud/stackit-sdk-go/services/ske v0.10.1/go.mod h1:7M7bsVHN0REuwoZRYz5nK2yBwsMJcHTsVFHlG83QP2A= | ||
| github.com/stackitcloud/stackit-sdk-go/services/ske v0.11.0 h1:BJ1Op7f3KJPNROkEXzqAREl55JCqyIAyQJ+Gfu4LYCM= | ||
| github.com/stackitcloud/stackit-sdk-go/services/ske v0.11.0/go.mod h1:yFLjTx58pjHCp0KZTaqHlW9Qk60CY5HpnBWR/zztv8Y= | ||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
@@ -163,4 +163,4 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | ||
| google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= | ||
| google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= | ||
| google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= | ||
| google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= | ||
| google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= | ||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
@@ -167,0 +167,0 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= |
@@ -230,2 +230,13 @@ package update | ||
| { | ||
| description: "no acl flag", | ||
| argValues: fixtureArgValues(), | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, sgwAclFlag) | ||
| }), | ||
| isValid: true, | ||
| expectedModel: fixtureInputModel(func(model *inputModel) { | ||
| model.SgwAcl = nil | ||
| }), | ||
| }, | ||
| { | ||
| description: "repeated acl flags", | ||
@@ -232,0 +243,0 @@ argValues: fixtureArgValues(), |
@@ -255,2 +255,13 @@ package update | ||
| { | ||
| description: "no acl flag", | ||
| argValues: fixtureArgValues(), | ||
| flagValues: fixtureStandardFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, aclFlag) | ||
| }), | ||
| isValid: true, | ||
| expectedModel: fixtureStandardInputModel(func(model *inputModel) { | ||
| model.ACL = nil | ||
| }), | ||
| }, | ||
| { | ||
| description: "repeated acl flags", | ||
@@ -257,0 +268,0 @@ argValues: fixtureArgValues(), |
@@ -230,2 +230,13 @@ package update | ||
| { | ||
| description: "no acl flag", | ||
| argValues: fixtureArgValues(), | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, sgwAclFlag) | ||
| }), | ||
| isValid: true, | ||
| expectedModel: fixtureInputModel(func(model *inputModel) { | ||
| model.SgwAcl = nil | ||
| }), | ||
| }, | ||
| { | ||
| description: "repeated acl flags", | ||
@@ -232,0 +243,0 @@ argValues: fixtureArgValues(), |
@@ -255,2 +255,13 @@ package update | ||
| { | ||
| description: "no acl flag", | ||
| argValues: fixtureArgValues(), | ||
| flagValues: fixtureStandardFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, aclFlag) | ||
| }), | ||
| isValid: true, | ||
| expectedModel: fixtureStandardInputModel(func(model *inputModel) { | ||
| model.ACL = nil | ||
| }), | ||
| }, | ||
| { | ||
| description: "repeated acl flags", | ||
@@ -257,0 +268,0 @@ argValues: fixtureArgValues(), |
@@ -230,2 +230,13 @@ package update | ||
| { | ||
| description: "no acl flag", | ||
| argValues: fixtureArgValues(), | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, sgwAclFlag) | ||
| }), | ||
| isValid: true, | ||
| expectedModel: fixtureInputModel(func(model *inputModel) { | ||
| model.SgwAcl = nil | ||
| }), | ||
| }, | ||
| { | ||
| description: "repeated acl flags", | ||
@@ -232,0 +243,0 @@ argValues: fixtureArgValues(), |
@@ -230,2 +230,13 @@ package update | ||
| { | ||
| description: "no acl flag", | ||
| argValues: fixtureArgValues(), | ||
| flagValues: fixtureFlagValues(func(flagValues map[string]string) { | ||
| delete(flagValues, sgwAclFlag) | ||
| }), | ||
| isValid: true, | ||
| expectedModel: fixtureInputModel(func(model *inputModel) { | ||
| model.SgwAcl = nil | ||
| }), | ||
| }, | ||
| { | ||
| description: "repeated acl flags", | ||
@@ -232,0 +243,0 @@ argValues: fixtureArgValues(), |
@@ -12,3 +12,2 @@ package auth | ||
| "net/http" | ||
| "net/url" | ||
| "os" | ||
@@ -27,3 +26,2 @@ "os/exec" | ||
| clientId = "stackit-cli-client-id" | ||
| redirectURL = "http://localhost:8000" | ||
| loginSuccessPath = "/login-successful" | ||
@@ -44,2 +42,12 @@ stackitLandingPage = "https://www.stackit.de" | ||
| func AuthorizeUser() error { | ||
| listener, err := net.Listen("tcp", ":0") | ||
| if err != nil { | ||
| return fmt.Errorf("bind port for login redirect: %w", err) | ||
| } | ||
| address, ok := listener.Addr().(*net.TCPAddr) | ||
| if !ok { | ||
| return fmt.Errorf("assert listener address type to TCP address") | ||
| } | ||
| redirectURL := fmt.Sprintf("http://localhost:%d", address.Port) | ||
| conf := &oauth2.Config{ | ||
@@ -152,15 +160,2 @@ ClientID: clientId, | ||
| // Parse the redirect URL for the port number | ||
| u, err := url.Parse(redirectURL) | ||
| if err != nil { | ||
| return fmt.Errorf("parse redirect URL: %w", err) | ||
| } | ||
| // Set up a listener on the redirect port | ||
| port := fmt.Sprintf(":%s", u.Port()) | ||
| l, err := net.Listen("tcp", port) | ||
| if err != nil { | ||
| return fmt.Errorf("listen to port %s: %w", port, err) | ||
| } | ||
| // Open a browser window to the authorizationURL | ||
@@ -174,3 +169,3 @@ err = openBrowser(authorizationURL) | ||
| // It will exit when the handlers get fired and call server.Close() | ||
| err = server.Serve(l) | ||
| err = server.Serve(listener) | ||
| if !errors.Is(err, http.ErrServerClosed) { | ||
@@ -177,0 +172,0 @@ return fmt.Errorf("server for PKCE flow closed unexpectedly: %w", err) |