Skip to content

Commit

Permalink
fix: align the default config output (#5947)
Browse files Browse the repository at this point in the history
Signed-off-by: terry.hung <[email protected]>
  • Loading branch information
Terryhung authored Nov 1, 2024
1 parent e5f8421 commit 704f8eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
11 changes: 0 additions & 11 deletions flytectl/pkg/configutil/configutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ const (
console:
endpoint: {{.Console}}
{{- end}}
{{- 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}}
`
)

Expand Down
18 changes: 5 additions & 13 deletions flytectl/pkg/configutil/configutil_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package configutil

import (
"io"
"io/ioutil"
"os"
"testing"
Expand All @@ -20,7 +21,7 @@ func TestSetupConfig(t *testing.T) {
}
err = SetupConfig(file.Name(), AdminConfigTemplate, templateValue)
assert.NoError(t, err)
configBytes, err := ioutil.ReadAll(file)
configBytes, err := io.ReadAll(file)
assert.NoError(t, err)
expected := `admin:
# For GRPC endpoints you might want to use dns:///flyte.myexample.com
Expand Down Expand Up @@ -62,21 +63,12 @@ console:
}
err = SetupConfig(file.Name(), AdminConfigTemplate, templateValue)
assert.NoError(t, err)
configBytes, err = ioutil.ReadAll(file)
configBytes, err = io.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))

Expand All @@ -91,8 +83,8 @@ func TestConfigCleanup(t *testing.T) {
if os.IsNotExist(err) {
_ = os.MkdirAll(f.FilePathJoin(f.UserHomeDir(), ".flyte"), 0755)
}
_ = ioutil.WriteFile(FlytectlConfig, []byte("string"), 0600)
_ = ioutil.WriteFile(Kubeconfig, []byte("string"), 0600)
_ = os.WriteFile(FlytectlConfig, []byte("string"), 0600)
_ = os.WriteFile(Kubeconfig, []byte("string"), 0600)

err = ConfigCleanup()
assert.Nil(t, err)
Expand Down
7 changes: 1 addition & 6 deletions flytectl/pkg/sandbox/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,8 @@ func startSandbox(ctx context.Context, cli docker.Docker, g github.GHRepoService
}

templateValues := configutil.ConfigTemplateSpec{
Host: "localhost:30080",
Host: "dns:///localhost:30080",
Insecure: true,
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 704f8eb

Please sign in to comment.