Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
#minor Updated Sandbox config, with automated data configuration (#440)
Browse files Browse the repository at this point in the history
* Updated Sandbox config, with automated data configuration

Signed-off-by: Ketan Umare <[email protected]>

* updated password

Signed-off-by: Ketan Umare <[email protected]>

* updated

Signed-off-by: Ketan Umare <[email protected]>

* Fix tests

Signed-off-by: Eduardo Apolinario <[email protected]>

* Add unit-test

Signed-off-by: Eduardo Apolinario <[email protected]>

---------

Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Co-authored-by: Eduardo Apolinario <[email protected]>
  • Loading branch information
kumare3 and eapolinario committed Nov 1, 2023
1 parent d297945 commit 1350bfa
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 16 deletions.
29 changes: 22 additions & 7 deletions pkg/configutil/configutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,36 @@ const (
AdminConfigTemplate = `admin:
# For GRPC endpoints you might want to use dns:///flyte.myexample.com
endpoint: {{.Host}}
authType: Pkce
insecure: {{.Insecure}}
{{- if .Console}}
console:
endpoint: {{.Console}}
{{- end}}
logger:
show-source: true
level: 0`
{{- if .DataConfig}}
# This is not a needed configuration, only useful if you want to explore the data in sandbox. For non sandbox, please
# do not use this configuration, instead prefer to use aws, gcs, azure sessions. Flytekit, should use fsspec to
# auto select the right backend to pull data as long as the sessions are configured. For Sandbox, this is special, as
# minio is s3 compatible and we ship with minio in sandbox.
storage:
connection:
endpoint: {{.DataConfig.Endpoint}}
access-key: {{.DataConfig.AccessKey}}
secret-key: {{.DataConfig.SecretKey}}
{{- end}}
`
)

type DataConfig struct {
Endpoint string
AccessKey string
SecretKey string
}

type ConfigTemplateSpec struct {
Host string
Insecure bool
Console string
Host string
Insecure bool
Console string
DataConfig *DataConfig
}

var (
Expand Down
41 changes: 33 additions & 8 deletions pkg/configutil/configutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ func TestSetupConfig(t *testing.T) {
expected := `admin:
# For GRPC endpoints you might want to use dns:///flyte.myexample.com
endpoint: dns:///localhost:30081
authType: Pkce
insecure: true
logger:
show-source: true
level: 0`
`
assert.Equal(t, expected, string(configBytes))

file, err = os.Create(file.Name())
Expand All @@ -46,13 +43,41 @@ logger:
expected = `admin:
# For GRPC endpoints you might want to use dns:///flyte.myexample.com
endpoint: dns:///admin.example.com
authType: Pkce
insecure: true
console:
endpoint: https://console.example.com
logger:
show-source: true
level: 0`
`
assert.Equal(t, expected, string(configBytes))

file, err = os.Create(file.Name())
require.NoError(t, err)
templateValue = ConfigTemplateSpec{
Host: "dns:///admin.example.com",
Insecure: true,
DataConfig: &DataConfig{
Endpoint: "http://localhost:9000",
AccessKey: "my-access-key",
SecretKey: "my-secret-key",
},
}
err = SetupConfig(file.Name(), AdminConfigTemplate, templateValue)
assert.NoError(t, err)
configBytes, err = ioutil.ReadAll(file)
assert.NoError(t, err)
expected = `admin:
# For GRPC endpoints you might want to use dns:///flyte.myexample.com
endpoint: dns:///admin.example.com
insecure: true
# This is not a needed configuration, only useful if you want to explore the data in sandbox. For non sandbox, please
# do not use this configuration, instead prefer to use aws, gcs, azure sessions. Flytekit, should use fsspec to
# auto select the right backend to pull data as long as the sessions are configured. For Sandbox, this is special, as
# minio is s3 compatible and we ship with minio in sandbox.
storage:
connection:
endpoint: http://localhost:9000
access-key: my-access-key
secret-key: my-secret-key
`
assert.Equal(t, expected, string(configBytes))

// Cleanup
Expand Down
6 changes: 5 additions & 1 deletion pkg/sandbox/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ func startSandbox(ctx context.Context, cli docker.Docker, g github.GHRepoService
templateValues := configutil.ConfigTemplateSpec{
Host: "localhost:30080",
Insecure: true,
Console: fmt.Sprintf("http://localhost:%d", consolePort),
DataConfig: &configutil.DataConfig{
Endpoint: "http://localhost:30002",
AccessKey: "minio",
SecretKey: "miniostorage",
},
}
if err := configutil.SetupConfig(configutil.FlytectlConfig, configutil.GetTemplate(), templateValues); err != nil {
return nil, err
Expand Down

0 comments on commit 1350bfa

Please sign in to comment.