-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add service account authirosation and replace swagger with sdk (#…
…37) * replace stackit dns client with stackit sdk * fix zone and repository tests * fix data races * linter * add new cnofig alteration for sa key path * fix linting * add unit tests for sa key path * fix test cases that changed each other due to global variable/env manipulation * make test cases parallel and add authetication config * solve race condition by allocating more memory * add sa in config * make relevant test cases parallel * add error casting in deleteRRSet * udpate readme and helm chart for new sa authentication * add error casting in deleteRRSet * fix linting --------- Co-authored-by: Patrick Koss <[email protected]>
- Loading branch information
Showing
21 changed files
with
461 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ go.work | |
out/ | ||
bin/ | ||
stackit-cert-manager-webhook-0.1.0.tgz | ||
stackit-cert-manager-webhook-0.1.* | ||
index.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,6 @@ type Config struct { | |
AuthToken string | ||
ProjectId string | ||
HttpClient *http.Client | ||
SaKeyPath string | ||
UseSaKey bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,41 @@ | ||
package repository | ||
|
||
import ( | ||
"fmt" | ||
|
||
stackitdnsclient "github.com/stackitcloud/stackit-dns-api-client-go" | ||
stackitconfig "github.com/stackitcloud/stackit-sdk-go/core/config" | ||
stackitdnsclient "github.com/stackitcloud/stackit-sdk-go/services/dns" | ||
) | ||
|
||
func newStackitDnsClient( | ||
config Config, | ||
) *stackitdnsclient.APIClient { | ||
configClient := stackitdnsclient.NewConfiguration() | ||
configClient.DefaultHeader["Authorization"] = fmt.Sprintf("Bearer %s", config.AuthToken) | ||
configClient.BasePath = config.ApiBasePath | ||
configClient.HTTPClient = config.HttpClient | ||
stackitConfig ...stackitconfig.ConfigurationOption, | ||
) (*stackitdnsclient.APIClient, error) { | ||
return stackitdnsclient.NewAPIClient(stackitConfig...) | ||
} | ||
|
||
func newStackitDnsClientBearerToken(config Config) (*stackitdnsclient.APIClient, error) { | ||
httpClient := *config.HttpClient | ||
|
||
return newStackitDnsClient( | ||
stackitconfig.WithToken(config.AuthToken), | ||
stackitconfig.WithHTTPClient(&httpClient), | ||
stackitconfig.WithEndpoint(config.ApiBasePath), | ||
) | ||
} | ||
|
||
func newStackitDnsClientKeyPath(config Config) (*stackitdnsclient.APIClient, error) { | ||
httpClient := *config.HttpClient | ||
|
||
return newStackitDnsClient( | ||
stackitconfig.WithServiceAccountKeyPath(config.SaKeyPath), | ||
stackitconfig.WithHTTPClient(&httpClient), | ||
stackitconfig.WithEndpoint(config.ApiBasePath), | ||
) | ||
} | ||
|
||
return stackitdnsclient.NewAPIClient(configClient) | ||
func chooseNewStackitDnsClient(config Config) (*stackitdnsclient.APIClient, error) { | ||
switch { | ||
case config.UseSaKey: | ||
return newStackitDnsClientKeyPath(config) | ||
default: | ||
return newStackitDnsClientBearerToken(config) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.