Skip to content

Commit

Permalink
Bump golden-retriever to allow multiple tokens for a single host (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriehSchneier authored Jul 16, 2024
1 parent 1c6f5de commit 6cbdd24
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 474 deletions.
47 changes: 23 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/anz-bank/sysl

go 1.20
go 1.21

require (
aqwari.net/xml v0.0.0-20210331023308-d9421b293817
github.com/alecthomas/assert v1.0.0
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20211115101625-aeaa445b4d4f
github.com/anz-bank/decimal v1.0.0
github.com/anz-bank/golden-retriever v0.30.0
github.com/anz-bank/golden-retriever v0.38.0
github.com/anz-bank/mermaid-go v0.1.1
github.com/anz-bank/pkg v0.0.48
github.com/arr-ai/arrai v0.319.0
Expand All @@ -19,31 +19,31 @@ require (
github.com/cornelk/hashmap v1.0.1
github.com/getkin/kin-openapi v0.124.0
github.com/ghodss/yaml v1.0.0
github.com/go-git/go-git/v5 v5.11.0
github.com/go-git/go-git/v5 v5.12.0
github.com/go-openapi/spec v0.20.4
github.com/go-openapi/swag v0.22.8
github.com/golang/protobuf v1.5.2
github.com/golang/protobuf v1.5.3
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/hcl v1.0.0
github.com/imdario/mergo v0.3.15
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
github.com/rjeczalik/notify v0.9.2
github.com/sirupsen/logrus v1.9.3
github.com/spf13/afero v1.9.2
github.com/stretchr/testify v1.8.4
github.com/spf13/afero v1.11.0
github.com/stretchr/testify v1.9.0
github.com/tidwall/gjson v1.11.0
golang.org/x/sync v0.6.0
golang.org/x/text v0.15.0
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f
google.golang.org/grpc v1.49.0
google.golang.org/protobuf v1.28.1
golang.org/x/sync v0.7.0
golang.org/x/text v0.16.0
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
Expand All @@ -53,9 +53,10 @@ require (
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 // indirect
github.com/chromedp/cdproto v0.0.0-20200209033844-7e00b02ea7d2 // indirect
github.com/chromedp/chromedp v0.5.3 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/chzyer/logex v1.2.1 // indirect
github.com/cloudflare/circl v1.3.9 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dchest/siphash v1.1.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
Expand Down Expand Up @@ -85,23 +86,21 @@ require (
github.com/richardlehane/mscfb v1.0.3 // indirect
github.com/richardlehane/msoleps v1.0.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/urfave/cli/v2 v2.2.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3 // indirect
github.com/xuri/excelize/v2 v2.4.1 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/tools v0.17.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sys v0.21.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220902135211-223410557253 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
494 changes: 62 additions & 432 deletions go.sum

Large diffs are not rendered by default.

Binary file modified internal/bundles/assets/import_openapi_cli.arraiz
Binary file not shown.
Binary file modified internal/bundles/assets/import_proto_cli.arraiz
Binary file not shown.
Binary file modified internal/bundles/assets/import_sql_cli.arraiz
Binary file not shown.
Binary file modified internal/bundles/assets/transformer_cli.arraiz
Binary file not shown.
Binary file modified internal/bundles/exporters/proto/transform.arraiz
Binary file not shown.
Binary file modified internal/bundles/exporters/spanner/transform.arraiz
Binary file not shown.
Binary file modified internal/bundles/importers/jsonschema/transform.arraiz
Binary file not shown.
30 changes: 12 additions & 18 deletions pkg/parse/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (
"path/filepath"
"strings"

"github.com/anz-bank/golden-retriever/retriever"
"github.com/anz-bank/sysl/pkg/env"
"github.com/anz-bank/sysl/pkg/syslutil"

"github.com/anz-bank/golden-retriever/reader"
"github.com/anz-bank/golden-retriever/reader/filesystem"
"github.com/anz-bank/golden-retriever/reader/remotefs"
"github.com/anz-bank/golden-retriever/retriever"
"github.com/anz-bank/golden-retriever/retriever/git"
"github.com/spf13/afero"

"github.com/anz-bank/sysl/pkg/env"
"github.com/anz-bank/sysl/pkg/syslutil"
)

const SyslRootMarker = ".sysl"
Expand All @@ -32,23 +32,18 @@ func NewReader(fs afero.Fs) (reader.Reader, error) {
}

func NewPinner(fs afero.Fs) (retriever.Retriever, error) {
tokens := make(map[string]string)
auth := &git.AuthOptions{}

if tokensStr := env.SYSL_TOKENS.Value(); tokensStr != "" {
hostTokens := strings.Split(tokensStr, ",")
for _, t := range hostTokens {
arr := strings.Split(t, ":")
if len(arr) != 2 {
return nil, fmt.Errorf(
"envvar %s is invalid, should be in format `hosta:<tokena>,hostb:<tokenb>`",
env.SYSL_TOKENS,
)
}
tokens[arr[0]] = arr[1]
var err error
auth, err = auth.WithTokensFromString(tokensStr)
if err != nil {
return nil, fmt.Errorf("envvar %s is invalid: %w`", env.SYSL_TOKENS, err)
}
}

keys := make(map[string]git.SSHKey)
if keysStr := env.SYSL_SSH_KEYS.Value(); keysStr != "" {
auth.SSHKeys = make(map[string]git.SSHKey)
hostKeys := strings.Split(keysStr, ",")
for _, k := range hostKeys {
arr := strings.Split(k, ":")
Expand All @@ -58,14 +53,13 @@ func NewPinner(fs afero.Fs) (retriever.Retriever, error) {
env.SYSL_SSH_KEYS,
)
}
keys[arr[0]] = git.SSHKey{
auth.SSHKeys[arr[0]] = git.SSHKey{
PrivateKey: arr[1],
PrivateKeyPassword: arr[2],
}
}
}

auth := &git.AuthOptions{Tokens: tokens, SSHKeys: keys}
// If a modules.yaml file already exists, use it. Otherwise use a caching Git retriever without
// pinning remote imports.
pinnerPath := filepath.Join(SyslRootDir(fs), "modules.yaml")
Expand Down
Binary file modified pkg/plugins/integration_model_plugin.arraiz
Binary file not shown.

0 comments on commit 6cbdd24

Please sign in to comment.