From 1350bfa10018ab4b14990ceefe88b1caf49aba9e Mon Sep 17 00:00:00 2001 From: Ketan Umare <16888709+kumare3@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:46:42 -0700 Subject: [PATCH] #minor Updated Sandbox config, with automated data configuration (#440) * Updated Sandbox config, with automated data configuration Signed-off-by: Ketan Umare * updated password Signed-off-by: Ketan Umare * updated Signed-off-by: Ketan Umare * Fix tests Signed-off-by: Eduardo Apolinario * Add unit-test Signed-off-by: Eduardo Apolinario --------- Signed-off-by: Ketan Umare Signed-off-by: Eduardo Apolinario Co-authored-by: Eduardo Apolinario --- pkg/configutil/configutil.go | 29 ++++++++++++++++------ pkg/configutil/configutil_test.go | 41 +++++++++++++++++++++++++------ pkg/sandbox/start.go | 6 ++++- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/pkg/configutil/configutil.go b/pkg/configutil/configutil.go index 5dcde9bd..3727b090 100644 --- a/pkg/configutil/configutil.go +++ b/pkg/configutil/configutil.go @@ -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 ( diff --git a/pkg/configutil/configutil_test.go b/pkg/configutil/configutil_test.go index 6a689366..a8f8bf4d 100644 --- a/pkg/configutil/configutil_test.go +++ b/pkg/configutil/configutil_test.go @@ -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()) @@ -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 diff --git a/pkg/sandbox/start.go b/pkg/sandbox/start.go index 9c9c73fb..ee7b8bc2 100644 --- a/pkg/sandbox/start.go +++ b/pkg/sandbox/start.go @@ -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