Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.10.1
github.com/stackql-labs/omnisdk v0.1.3-alpha05
github.com/stackql-labs/omnisdk v0.1.3-beta03
github.com/stackql/any-sdk v0.6.0-alpha01
github.com/stackql/go-suffix-map v0.0.1-alpha01
github.com/stackql/psql-wire v0.1.3-beta01
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk=
github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU=
github.com/spiffe/go-spiffe/v2 v2.7.0 h1:uXe1MflJoHw58wAUvxVlcM7WpKtijWG7I1UidcGh6g4=
github.com/spiffe/go-spiffe/v2 v2.7.0/go.mod h1:47Q0Q9/AqGha8QLHp+kxpH4Wca7X7EnOtlIJy3mxZ3U=
github.com/stackql-labs/omnisdk v0.1.3-alpha05 h1:pAqzYLtmowbDuo2B9ssvrhbyISsu+kTajog6p6JnxX4=
github.com/stackql-labs/omnisdk v0.1.3-alpha05/go.mod h1:WzvNj/bVv53yGFsVJpYWCJC1xAEdmQSFJl9eVpkRpCY=
github.com/stackql-labs/omnisdk v0.1.3-beta03 h1:VAzd8cix45oiRLbexCEBfOGHrYsnmsvqjRcBqroW96o=
github.com/stackql-labs/omnisdk v0.1.3-beta03/go.mod h1:WzvNj/bVv53yGFsVJpYWCJC1xAEdmQSFJl9eVpkRpCY=
github.com/stackql/any-sdk v0.6.0-alpha01 h1:mqy0bmZ1wghr7mUgLyaexoRU6rsUZCWXU9Mf60fC8dg=
github.com/stackql/any-sdk v0.6.0-alpha01/go.mod h1:ahkRgwHHEn7RTmSfKrshPVk6i4X1BdHknSeBflSyRac=
github.com/stackql/go-suffix-map v0.0.1-alpha01 h1:TDUDS8bySu41Oo9p0eniUeCm43mnRM6zFEd6j6VUaz8=
Expand Down
24 changes: 18 additions & 6 deletions internal/stackql/intrinsic/omnisdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func openStream(
input := previewCfg
args := omnisdk.Args{
Params: params,
Auth: omnisdkAuth(providerAuthContext(ctx, resourcePath)),
AuthByProvider: providerAuthByProvider(ctx, resourcePath),
Endpoint: input.getEndpoint(),
InsecureSkipTLSVerify: input.getInsecureSkipTLSVerify(),
}
Expand Down Expand Up @@ -572,18 +572,30 @@ var cloudProviders = map[string]string{ //nolint:gochecknoglobals // fixed mappi
// resource. It carries both the credentials and the tuning values.
func providerAuthContext(ctx queryContext, resourcePath string) *dto.AuthCtx {
cloud, _, _ := strings.Cut(resourcePath, ".")
providerName, ok := cloudProviders[cloud]
if !ok {
// A document-driven provider is addressed by its own stackql name.
providerName = cloud
}
providerName := authProviderName(cloud)
authCtx, err := ctx.GetAuthContext(providerName)
if err != nil {
return nil
}
return authCtx
}

func authProviderName(cloud string) string {
if providerName, ok := cloudProviders[cloud]; ok {
return providerName
}
// A document-driven provider is addressed by its own stackql name.
return cloud
}

func providerAuthByProvider(ctx queryContext, cloud string) map[string]*omnisdk.Auth {
authCtx := providerAuthContext(ctx, cloud)
if authCtx == nil {
return nil
}
return map[string]*omnisdk.Auth{authProviderName(cloud): omnisdkAuth(authCtx)}
}

func omnisdkAuth(authCtx *dto.AuthCtx) *omnisdk.Auth {
if authCtx == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/stackql/intrinsic/preview_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func previewArgs(ctx queryContext, cloud string, params map[string]string) omnis
input := previewCfg
return omnisdk.Args{
Params: params,
Auth: omnisdkAuth(providerAuthContext(ctx, cloud)),
AuthByProvider: providerAuthByProvider(ctx, cloud),
Endpoint: input.getEndpoint(),
InsecureSkipTLSVerify: input.getInsecureSkipTLSVerify(),
}
Expand Down