Skip to content

Commit 198a9b6

Browse files
committed
cmd: add the upgrade command
1 parent d916440 commit 198a9b6

12 files changed

Lines changed: 353 additions & 221 deletions

File tree

cmd/hasura-ndc-go/command/internal/connector.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"go/types"
1010
"io"
1111
"os"
12-
"path"
12+
"path/filepath"
1313
"runtime/trace"
1414
"slices"
1515
"strings"
@@ -138,7 +138,7 @@ func ParseAndGenerateConnector(args ConnectorGenerationArguments, moduleName str
138138
}
139139

140140
func (cg *connectorGenerator) loadConnectorPackage() (string, error) {
141-
connectorPath := path.Join(cg.basePath, cg.connectorDir)
141+
connectorPath := filepath.Join(cg.basePath, cg.connectorDir)
142142
fset := token.NewFileSet()
143143
cfg := &packages.Config{
144144
Dir: connectorPath,
@@ -181,7 +181,7 @@ func (cg *connectorGenerator) generateConnector(name string) error {
181181
}
182182
}
183183

184-
schemaPath := path.Join(cg.basePath, cg.connectorDir, schemaOutputFile)
184+
schemaPath := filepath.Join(cg.basePath, cg.connectorDir, schemaOutputFile)
185185
if err := os.WriteFile(schemaPath, schemaBytes, 0o644); err != nil {
186186
return err
187187
}
@@ -191,7 +191,7 @@ func (cg *connectorGenerator) generateConnector(name string) error {
191191
}
192192

193193
if !cg.typeOnly {
194-
targetPath := path.Join(cg.basePath, cg.connectorDir, connectorOutputFile)
194+
targetPath := filepath.Join(cg.basePath, cg.connectorDir, connectorOutputFile)
195195

196196
f, err := os.Create(targetPath)
197197
if err != nil {
@@ -292,7 +292,7 @@ func (cg *connectorGenerator) genTypeMethods() error {
292292
}
293293

294294
relativePath := strings.TrimPrefix(packagePath, cg.moduleName)
295-
schemaPath := path.Join(cg.basePath, relativePath, typeMethodsOutputFile)
295+
schemaPath := filepath.Join(cg.basePath, relativePath, typeMethodsOutputFile)
296296
log.Debug().
297297
Str("package_name", builder.packageName).
298298
Str("package_path", packagePath).

cmd/hasura-ndc-go/command/internal/connector_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestConnectorGeneration(t *testing.T) {
8383
)
8484
assert.NilError(t, err)
8585

86-
srcDir := path.Join(tc.BasePath, "source")
86+
srcDir := filepath.Join(tc.BasePath, "source")
8787
t.Chdir(srcDir)
8888

8989
err = ParseAndGenerateConnector(ConnectorGenerationArguments{
@@ -173,7 +173,7 @@ func TestConnectorGeneration(t *testing.T) {
173173
assert.NilError(t, err)
174174
}
175175

176-
srcDir := path.Join(tc.BasePath, "source")
176+
srcDir := filepath.Join(tc.BasePath, "source")
177177
t.Chdir(srcDir)
178178
err = ParseAndGenerateConnector(ConnectorGenerationArguments{
179179
ConnectorDir: tc.ConnectorDir,

cmd/hasura-ndc-go/command/internal/schema_parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func parseRawConnectorSchemaFromGoCode(
8484
directories := make(map[string]bool)
8585

8686
for _, dir := range tempDirs {
87-
for _, globPath := range []string{path.Join(filePath, dir, "*.go"), path.Join(filePath, dir, "**", "*.go")} {
87+
for _, globPath := range []string{path.Join(filePath, dir, "*.go"), filepath.Join(filePath, dir, "**", "*.go")} {
8888
goFiles, err := filepath.Glob(globPath)
8989
if err != nil {
9090
return nil, fmt.Errorf(
@@ -121,7 +121,7 @@ func parseRawConnectorSchemaFromGoCode(
121121

122122
for folder := range directories {
123123
_, parseCodeTask := trace.NewTask(ctx, fmt.Sprintf("parse_%s_code", folder))
124-
folderPath := path.Join(filePath, folder)
124+
folderPath := filepath.Join(filePath, folder)
125125
cfg := &packages.Config{
126126
Mode: packages.NeedSyntax | packages.NeedTypes,
127127
Dir: folderPath,

cmd/hasura-ndc-go/command/internal/templates/new/.hasura-connector/connector-metadata.yaml.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ packagingDefinition:
33
supportedEnvironmentVariables: []
44
commands:
55
update: hasura-ndc-go update
6-
upgradeConfiguration: hasura-ndc-go update
6+
upgradeConfiguration: hasura-ndc-go upgrade
77
nativeToolchainDefinition:
88
commands:
99
start:

cmd/hasura-ndc-go/command/internal/testdata/duplicated_func/source/go.mod

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,48 @@ go 1.24
55
require github.com/hasura/ndc-sdk-go v1.10.0
66

77
require (
8-
github.com/Masterminds/semver/v3 v3.3.1 // indirect
9-
github.com/alecthomas/kong v1.11.0 // indirect
8+
github.com/Masterminds/semver/v3 v3.4.0 // indirect
9+
github.com/alecthomas/kong v1.12.1 // indirect
1010
github.com/beorn7/perks v1.0.1 // indirect
11-
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
11+
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
1212
github.com/cespare/xxhash/v2 v2.3.0 // indirect
1313
github.com/go-logr/logr v1.4.3 // indirect
1414
github.com/go-logr/stdr v1.2.2 // indirect
15-
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
15+
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
1616
github.com/google/uuid v1.6.0 // indirect
17-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
17+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect
18+
github.com/klauspost/compress v1.18.0 // indirect
1819
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
19-
github.com/prometheus/client_golang v1.22.0 // indirect
20+
github.com/prometheus/client_golang v1.23.0 // indirect
2021
github.com/prometheus/client_model v0.6.2 // indirect
21-
github.com/prometheus/common v0.64.0 // indirect
22-
github.com/prometheus/procfs v0.16.1 // indirect
22+
github.com/prometheus/common v0.65.0 // indirect
23+
github.com/prometheus/procfs v0.17.0 // indirect
2324
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
24-
go.opentelemetry.io/contrib/bridges/otelslog v0.11.0 // indirect
25-
go.opentelemetry.io/contrib/propagators/b3 v1.36.0 // indirect
26-
go.opentelemetry.io/otel v1.36.0 // indirect
27-
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.12.2 // indirect
28-
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.12.2 // indirect
29-
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.36.0 // indirect
30-
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.36.0 // indirect
31-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0 // indirect
32-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.36.0 // indirect
33-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.36.0 // indirect
34-
go.opentelemetry.io/otel/exporters/prometheus v0.58.0 // indirect
35-
go.opentelemetry.io/otel/log v0.12.2 // indirect
36-
go.opentelemetry.io/otel/metric v1.36.0 // indirect
37-
go.opentelemetry.io/otel/sdk v1.36.0 // indirect
38-
go.opentelemetry.io/otel/sdk/log v0.12.2 // indirect
39-
go.opentelemetry.io/otel/sdk/metric v1.36.0 // indirect
40-
go.opentelemetry.io/otel/trace v1.36.0 // indirect
41-
go.opentelemetry.io/proto/otlp v1.6.0 // indirect
42-
golang.org/x/net v0.40.0 // indirect
43-
golang.org/x/sys v0.33.0 // indirect
44-
golang.org/x/text v0.25.0 // indirect
45-
google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a // indirect
46-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
47-
google.golang.org/grpc v1.72.2 // indirect
48-
google.golang.org/protobuf v1.36.6 // indirect
25+
go.opentelemetry.io/contrib/bridges/otelslog v0.12.0 // indirect
26+
go.opentelemetry.io/contrib/propagators/b3 v1.37.0 // indirect
27+
go.opentelemetry.io/otel v1.37.0 // indirect
28+
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.13.0 // indirect
29+
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.13.0 // indirect
30+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.37.0 // indirect
31+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.37.0 // indirect
32+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 // indirect
33+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.37.0 // indirect
34+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.37.0 // indirect
35+
go.opentelemetry.io/otel/exporters/prometheus v0.59.0 // indirect
36+
go.opentelemetry.io/otel/log v0.13.0 // indirect
37+
go.opentelemetry.io/otel/metric v1.37.0 // indirect
38+
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
39+
go.opentelemetry.io/otel/sdk/log v0.13.0 // indirect
40+
go.opentelemetry.io/otel/sdk/metric v1.37.0 // indirect
41+
go.opentelemetry.io/otel/trace v1.37.0 // indirect
42+
go.opentelemetry.io/proto/otlp v1.7.1 // indirect
43+
golang.org/x/net v0.43.0 // indirect
44+
golang.org/x/sys v0.35.0 // indirect
45+
golang.org/x/text v0.28.0 // indirect
46+
google.golang.org/genproto/googleapis/api v0.0.0-20250811160224-6b04f9b4fc78 // indirect
47+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250811160224-6b04f9b4fc78 // indirect
48+
google.golang.org/grpc v1.74.2 // indirect
49+
google.golang.org/protobuf v1.36.7 // indirect
4950
)
5051

5152
replace github.com/hasura/ndc-sdk-go => ../../../../../../../

0 commit comments

Comments
 (0)