Skip to content

Commit c621001

Browse files
- All openapi logic now via any-sdk.
1 parent 5af414e commit c621001

File tree

9 files changed

+11
-145
lines changed

9 files changed

+11
-145
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21.5-bullseye AS sourceprep
1+
FROM golang:1.22-bullseye AS sourceprep
22

33
ENV SRC_DIR=/work/stackql/src
44

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ toolchain go1.22.0
77
require (
88
github.com/DATA-DOG/go-sqlmock v1.5.1
99
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
10-
github.com/getkin/kin-openapi v0.88.0
1110
github.com/google/go-jsonnet v0.17.0
1211
github.com/jackc/pgtype v1.10.0
1312
github.com/jackc/pgx/v5 v5.0.4
@@ -20,7 +19,7 @@ require (
2019
github.com/spf13/cobra v1.4.0
2120
github.com/spf13/pflag v1.0.5
2221
github.com/spf13/viper v1.10.1
23-
github.com/stackql/any-sdk v0.0.5-alpha07
22+
github.com/stackql/any-sdk v0.0.5-alpha09
2423
github.com/stackql/go-suffix-map v0.0.1-alpha01
2524
github.com/stackql/psql-wire v0.1.1-alpha07
2625
github.com/stackql/stackql-parser v0.0.14-alpha04
@@ -67,6 +66,7 @@ require (
6766
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
6867
github.com/fsnotify/fsnotify v1.5.1 // indirect
6968
github.com/gabriel-vasile/mimetype v1.4.1 // indirect
69+
github.com/getkin/kin-openapi v0.88.0 // indirect
7070
github.com/ghodss/yaml v1.0.0 // indirect
7171
github.com/go-openapi/jsonpointer v0.19.5 // indirect
7272
github.com/go-openapi/swag v0.21.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
482482
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
483483
github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk=
484484
github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU=
485-
github.com/stackql/any-sdk v0.0.5-alpha07 h1:QNhDSl3pk9I/mNwUwOisnG1PCNIPFKm2RH4M6RqPz9Q=
486-
github.com/stackql/any-sdk v0.0.5-alpha07/go.mod h1:4jYKpPoX2GWEK+qBnlGLvr8SUfndiYwHMIkg1dn9tFM=
485+
github.com/stackql/any-sdk v0.0.5-alpha09 h1:pBQZUHzhDauznd01k2RInFoh3NqL/dAK/1ZIfS0/fpQ=
486+
github.com/stackql/any-sdk v0.0.5-alpha09/go.mod h1:4jYKpPoX2GWEK+qBnlGLvr8SUfndiYwHMIkg1dn9tFM=
487487
github.com/stackql/go-suffix-map v0.0.1-alpha01 h1:TDUDS8bySu41Oo9p0eniUeCm43mnRM6zFEd6j6VUaz8=
488488
github.com/stackql/go-suffix-map v0.0.1-alpha01/go.mod h1:QAi+SKukOyf4dBtWy8UMy+hsXXV+yyEE4vmBkji2V7g=
489489
github.com/stackql/psql-wire v0.1.1-alpha07 h1:LQWVUlx4Bougk6dztDNG5tmXxpIVeeTSsInTj801xCs=

internal/stackql/astvisit/query_rewriting.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"sort"
77
"strings"
88

9-
"github.com/getkin/kin-openapi/openapi3"
109
"github.com/stackql/any-sdk/anysdk"
1110
"github.com/stackql/stackql-parser/go/vt/sqlparser"
1211

@@ -137,10 +136,7 @@ func (v *standardQueryRewriteAstVisitor) getNextAlias() string {
137136

138137
func (v *standardQueryRewriteAstVisitor) generateServerVarColumnDescriptor(
139138
k string, m anysdk.OperationStore) anysdk.ColumnDescriptor {
140-
sc := openapi3.NewSchema()
141-
sc.Type = "string"
142-
schema := anysdk.NewSchema(
143-
sc,
139+
schema := anysdk.NewStringSchema(
144140
m.GetService(),
145141
"",
146142
"",

internal/stackql/google_sdk/gcloud.go

Lines changed: 0 additions & 70 deletions
This file was deleted.

internal/stackql/provider/generic.go

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/stackql/any-sdk/pkg/logging"
1212
"github.com/stackql/stackql/internal/stackql/discovery"
1313
"github.com/stackql/stackql/internal/stackql/docparser"
14-
google_sdk "github.com/stackql/stackql/internal/stackql/google_sdk"
1514
"github.com/stackql/stackql/internal/stackql/internal_data_transfer/internaldto"
1615
"github.com/stackql/stackql/internal/stackql/methodselect"
1716
"github.com/stackql/stackql/internal/stackql/netutils"
@@ -135,17 +134,7 @@ func (gp *GenericProvider) Auth(
135134
}
136135

137136
func (gp *GenericProvider) AuthRevoke(authCtx *dto.AuthCtx) error {
138-
switch strings.ToLower(authCtx.Type) {
139-
case dto.AuthServiceAccountStr:
140-
return errors.New(constants.ServiceAccountRevokeErrStr)
141-
case dto.AuthInteractiveStr:
142-
err := google_sdk.RevokeGoogleAuth()
143-
if err == nil {
144-
gp.authUtil.DeactivateAuth(authCtx)
145-
}
146-
return err
147-
}
148-
return fmt.Errorf(`Auth revoke for Google Failed; improper auth method: "%s" specified`, authCtx.Type)
137+
return gp.authUtil.AuthRevoke(authCtx)
149138
}
150139

151140
func (gp *GenericProvider) GetMethodForAction(
@@ -226,7 +215,7 @@ func (gp *GenericProvider) ShowAuth(authCtx *dto.AuthCtx) (*anysdk.AuthMetadata,
226215
gp.authUtil.ActivateAuth(authCtx, sa.Email, dto.AuthServiceAccountStr)
227216
}
228217
case dto.AuthInteractiveStr:
229-
principal, sdkErr := google_sdk.GetCurrentAuthUser()
218+
principal, sdkErr := gp.authUtil.GetCurrentGCloudOauthUser()
230219
if sdkErr == nil {
231220
principalStr := string(principal)
232221
if principalStr != "" {
@@ -251,29 +240,7 @@ func (gp *GenericProvider) ShowAuth(authCtx *dto.AuthCtx) (*anysdk.AuthMetadata,
251240
}
252241

253242
func (gp *GenericProvider) oAuth(authCtx *dto.AuthCtx, enforceRevokeFirst bool) (*http.Client, error) {
254-
var err error
255-
var tokenBytes []byte
256-
tokenBytes, err = google_sdk.GetAccessToken()
257-
if enforceRevokeFirst && authCtx.Type == dto.AuthInteractiveStr && err == nil {
258-
return nil, fmt.Errorf(constants.OAuthInteractiveAuthErrStr) //nolint:stylecheck // happy with message
259-
}
260-
if err != nil {
261-
err = google_sdk.OAuthToGoogle()
262-
if err == nil {
263-
tokenBytes, err = google_sdk.GetAccessToken()
264-
}
265-
}
266-
if err != nil {
267-
return nil, err
268-
}
269-
gp.authUtil.ActivateAuth(authCtx, "", dto.AuthInteractiveStr)
270-
client := netutils.GetHTTPClient(gp.runtimeCtx, nil)
271-
tr, err := auth_util.NewTransport(tokenBytes, auth_util.AuthTypeBearer, authCtx.ValuePrefix, auth_util.LocationHeader, "", client.Transport)
272-
if err != nil {
273-
return nil, err
274-
}
275-
client.Transport = tr
276-
return client, nil
243+
return gp.authUtil.GCloudOAuth(gp.runtimeCtx, authCtx, enforceRevokeFirst)
277244
}
278245

279246
func (gp *GenericProvider) googleKeyFileAuth(authCtx *dto.AuthCtx) (*http.Client, error) {

internal/stackql/tablemetadata/extended_table_metadata.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package tablemetadata
33
import (
44
"fmt"
55

6-
"github.com/getkin/kin-openapi/openapi3"
76
"github.com/stackql/any-sdk/anysdk"
87
"github.com/stackql/stackql/internal/stackql/astindirect"
98
"github.com/stackql/stackql/internal/stackql/datasource/sql_datasource"
@@ -61,7 +60,6 @@ type ExtendedTableMetadata interface {
6160
IsOnClauseHoistable() bool
6261
IsPhysicalTable() bool
6362
IsMaterializedView() bool
64-
GetServerVariables() (map[string]*openapi3.ServerVariable, bool)
6563
Clone() ExtendedTableMetadata
6664
Equals(ExtendedTableMetadata) bool
6765
}
@@ -128,23 +126,6 @@ func (ex *standardExtendedTableMetadata) Equals(other ExtendedTableMetadata) boo
128126
return true
129127
}
130128

131-
func (ex *standardExtendedTableMetadata) GetServerVariables() (map[string]*openapi3.ServerVariable, bool) {
132-
m, err := ex.getMethod()
133-
if err != nil {
134-
return nil, false
135-
}
136-
rv := make(map[string]*openapi3.ServerVariable)
137-
availableServers, availableServersDoExist := m.GetServers()
138-
if availableServersDoExist {
139-
for _, s := range availableServers {
140-
for k, v := range s.Variables {
141-
rv[k] = v
142-
}
143-
}
144-
}
145-
return rv, true
146-
}
147-
148129
func (ex *standardExtendedTableMetadata) IsPhysicalTable() bool {
149130
if ex.heirarchyObjects == nil || ex.heirarchyObjects.GetHeirarchyIDs() == nil {
150131
return false

internal/stackql/util/column.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package util
22

33
import (
4-
"github.com/getkin/kin-openapi/openapi3"
54
"github.com/stackql/any-sdk/anysdk"
65
)
76

@@ -24,10 +23,7 @@ func newSimpleColumn(name string, schema anysdk.Schema) Column {
2423
}
2524

2625
func newSimpleStringColumn(name string, m anysdk.OperationStore) Column {
27-
sc := openapi3.NewSchema()
28-
sc.Type = "string"
29-
return newSimpleColumn(name, anysdk.NewSchema(
30-
sc,
26+
return newSimpleColumn(name, anysdk.NewStringSchema(
3127
m.GetService(),
3228
"",
3329
"",

internal/stackql/util/table_schema.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package util
33
import (
44
"strings"
55

6-
"github.com/getkin/kin-openapi/openapi3"
76
"github.com/stackql/any-sdk/anysdk"
87
)
98

@@ -69,10 +68,7 @@ func (ta *simpleTableSchemaAnalyzer) GetColumns() ([]Column, error) {
6968

7069
func (ta *simpleTableSchemaAnalyzer) generateServerVarColumnDescriptor(
7170
k string, m anysdk.OperationStore) anysdk.ColumnDescriptor {
72-
sc := openapi3.NewSchema()
73-
sc.Type = "string"
74-
schema := anysdk.NewSchema(
75-
sc,
71+
schema := anysdk.NewStringSchema(
7672
m.GetService(),
7773
"",
7874
"",

0 commit comments

Comments
 (0)