diff --git a/flytectl/pkg/configutil/configutil.go b/flytectl/pkg/configutil/configutil.go index 5dcde9bd69e..3727b090846 100644 --- a/flytectl/pkg/configutil/configutil.go +++ b/flytectl/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/flytectl/pkg/configutil/configutil_test.go b/flytectl/pkg/configutil/configutil_test.go index 6a689366e09..a8f8bf4d963 100644 --- a/flytectl/pkg/configutil/configutil_test.go +++ b/flytectl/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/flytectl/pkg/sandbox/start.go b/flytectl/pkg/sandbox/start.go index 9c9c73fb06a..ee7b8bc2752 100644 --- a/flytectl/pkg/sandbox/start.go +++ b/flytectl/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