Skip to content

Commit

Permalink
Removed storage config and updated boilerplate (flyteorg#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmahindrakar-oss authored and robert-ulbrich-mercedes-benz committed Jul 2, 2024
1 parent 8f6543e commit a3e6f4f
Show file tree
Hide file tree
Showing 23 changed files with 228 additions and 344 deletions.
6 changes: 2 additions & 4 deletions flytectl/boilerplate/flyte/golang_support_tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/flyteorg/boilerplate
go 1.17

require (
github.com/EngHabu/mockery v0.0.0-20220405200825-3f76291311cf
github.com/alvaroloes/enumer v1.1.2
github.com/flyteorg/flytestdlib v0.4.16
github.com/golangci/golangci-lint v1.38.0
github.com/pseudomuto/protoc-gen-doc v1.4.1
github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5
)

require (
Expand Down Expand Up @@ -152,7 +152,7 @@ require (
github.com/spf13/viper v1.7.1 // indirect
github.com/ssgreg/nlreturn/v2 v2.1.0 // indirect
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/stretchr/testify v1.7.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tdakkota/asciicheck v0.0.0-20200416200610-e657995f937b // indirect
github.com/tetafro/godot v1.4.4 // indirect
Expand Down Expand Up @@ -191,6 +191,4 @@ require (
mvdan.cc/unparam v0.0.0-20210104141923-aac4ce9116a7 // indirect
)

replace github.com/vektra/mockery => github.com/enghabu/mockery v0.0.0-20191009061720-9d0c8670c2f0

replace github.com/pseudomuto/protoc-gen-doc => github.com/flyteorg/protoc-gen-doc v1.4.2
8 changes: 4 additions & 4 deletions flytectl/boilerplate/flyte/golang_support_tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM=
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs=
github.com/EngHabu/mockery v0.0.0-20220405200825-3f76291311cf h1:M7A2Tn3R8rVgsoJHHKkmkpiNOItys4GxJj6JytRjdDg=
github.com/EngHabu/mockery v0.0.0-20220405200825-3f76291311cf/go.mod h1:Kya4Y46gyq/3TEyAzeNe5UkCk+W9apy5KbuX+5KnZ6M=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
Expand Down Expand Up @@ -194,8 +196,6 @@ github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFP
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/enghabu/mockery v0.0.0-20191009061720-9d0c8670c2f0 h1:qxIJwfSemSCqhG3/lEw1Rm+wYbegjuKsqy0ZqnIpL14=
github.com/enghabu/mockery v0.0.0-20191009061720-9d0c8670c2f0/go.mod h1:KfdIkmkpVY3n2sc1ykFj01uMviOiXH2HMhUCvA5FYGg=
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down Expand Up @@ -773,8 +773,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tdakkota/asciicheck v0.0.0-20200416200610-e657995f937b h1:HxLVTlqcHhFAz3nWUcuvpH7WuOMv8LQoCWmruLfFH2U=
Expand Down Expand Up @@ -1035,7 +1036,6 @@ golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181112210238-4b1f3b6b1646/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190110163146-51295c7ec13a/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
Expand Down
2 changes: 1 addition & 1 deletion flytectl/boilerplate/flyte/golang_support_tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package tools

import (
_ "github.com/EngHabu/mockery/cmd/mockery"
_ "github.com/alvaroloes/enumer"
_ "github.com/flyteorg/flytestdlib/cli/pflags"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc"
_ "github.com/vektra/mockery/cmd/mockery"
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ set -e
# List of tools to go get
# In the format of "<cli>:<package>" or ":<package>" if no cli
tools=(
"github.com/vektra/mockery/cmd/mockery"
"github.com/flyteorg/flytestdlib/cli/pflags"
"github.com/EngHabu/mockery/cmd/mockery"
"github.com/flyteorg/flytestdlib/cli/pflags@latest"
"github.com/golangci/golangci-lint/cmd/golangci-lint@latest"
"github.com/alvaroloes/enumer"
"github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc"
Expand Down
1 change: 0 additions & 1 deletion flytectl/cmd/config/subcommand/config/config_flags.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions flytectl/cmd/config/subcommand/config/config_flags_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions flytectl/cmd/config/subcommand/config/init_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ package config
var (
DefaultConfig = &Config{
Insecure: false,
Storage: false,
}
)

//Configs
type Config struct {
Host string `json:"host" pflag:",Endpoint of flyte admin"`
Insecure bool `json:"insecure" pflag:",Enable insecure mode"`
Storage bool `json:"storage" pflag:",Enable storage provider config"`
}
27 changes: 3 additions & 24 deletions flytectl/cmd/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"os"
"strings"

"github.com/flyteorg/flytestdlib/logger"

"github.com/flyteorg/flytectl/pkg/util"

"github.com/flyteorg/flytectl/pkg/configutil"
Expand All @@ -19,7 +17,6 @@ import (
cmdUtil "github.com/flyteorg/flytectl/pkg/commandutils"
"github.com/flyteorg/flytestdlib/config/viper"
"github.com/go-ozzo/ozzo-validation/v4/is"
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -58,11 +55,6 @@ Generate Flytectl config with a storage provider:
`
)

var prompt = promptui.Select{
Label: "Select Storage Provider",
Items: []string{"S3", "GCS"},
}

var endpointPrefix = [3]string{"dns:///", "http://", "https://"}

// CreateConfigCommand will return configuration command
Expand All @@ -80,10 +72,10 @@ func CreateConfigCommand() *cobra.Command {
}

func configInitFunc(ctx context.Context, args []string, cmdCtx cmdcore.CommandContext) error {
return initFlytectlConfig(ctx, os.Stdin)
return initFlytectlConfig(os.Stdin)
}

func initFlytectlConfig(ctx context.Context, reader io.Reader) error {
func initFlytectlConfig(reader io.Reader) error {

if err := util.SetupFlyteDir(); err != nil {
return err
Expand All @@ -93,7 +85,7 @@ func initFlytectlConfig(ctx context.Context, reader io.Reader) error {
Host: "dns:///localhost:30081",
Insecure: true,
}
templateStr := configutil.GetSandboxTemplate()
templateStr := configutil.GetTemplate()

if len(initConfig.DefaultConfig.Host) > 0 {
trimHost := trimEndpoint(initConfig.DefaultConfig.Host)
Expand All @@ -102,19 +94,6 @@ func initFlytectlConfig(ctx context.Context, reader io.Reader) error {
}
templateValues.Host = fmt.Sprintf("dns:///%s", trimHost)
templateValues.Insecure = initConfig.DefaultConfig.Insecure
templateStr = configutil.AdminConfigTemplate
if initConfig.DefaultConfig.Storage {
templateStr = configutil.GetAWSCloudTemplate()
_, result, err := prompt.Run()
if err != nil {
return err
}
if strings.ToUpper(result) == "GCS" {
templateStr = configutil.GetGoogleCloudTemplate()
}
} else {
logger.Infof(ctx, "Init flytectl config for remote cluster, Please update your storage config in %s. Learn more about the config here https://docs.flyte.org/projects/flytectl/en/latest/index.html#configure", configutil.ConfigFile)
}
}
var _err error
if _, err := os.Stat(configutil.ConfigFile); os.IsNotExist(err) {
Expand Down
12 changes: 5 additions & 7 deletions flytectl/cmd/configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ func TestSetupConfigFunc(t *testing.T) {
initConfig.DefaultConfig.Host = ""
assert.Nil(t, err)

assert.Nil(t, initFlytectlConfig(ctx, yes))
assert.Nil(t, initFlytectlConfig(ctx, yes))
assert.Nil(t, initFlytectlConfig(ctx, no))
assert.Nil(t, initFlytectlConfig(yes))
assert.Nil(t, initFlytectlConfig(no))
initConfig.DefaultConfig.Host = "flyte.org"
assert.Nil(t, initFlytectlConfig(ctx, no))
assert.Nil(t, initFlytectlConfig(no))
initConfig.DefaultConfig.Host = "localhost:30081"
assert.Nil(t, initFlytectlConfig(ctx, no))
initConfig.DefaultConfig.Storage = true
assert.NotNil(t, initFlytectlConfig(ctx, yes))
assert.Nil(t, initFlytectlConfig(no))
assert.Nil(t, initFlytectlConfig(yes))
}

func TestTrimFunc(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion flytectl/cmd/demo/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func startDemo(ctx context.Context, cli docker.Docker, g github.GHRepoService, r
Host: "localhost:30081",
Insecure: true,
}
if err := configutil.SetupConfig(configutil.ConfigFile, configutil.GetDemoTemplate(), templateValues); err != nil {
if err := configutil.SetupConfig(configutil.ConfigFile, configutil.GetTemplate(), templateValues); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion flytectl/cmd/sandbox/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func startSandbox(ctx context.Context, cli docker.Docker, g github.GHRepoService
Host: "localhost:30081",
Insecure: true,
}
if err := configutil.SetupConfig(configutil.FlytectlConfig, configutil.GetSandboxTemplate(), templateValues); err != nil {
if err := configutil.SetupConfig(configutil.FlytectlConfig, configutil.GetTemplate(), templateValues); err != nil {
return nil, err
}

Expand Down
8 changes: 4 additions & 4 deletions flytectl/cmd/update/interfaces/mocks/updater.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions flytectl/docs/source/gen/flytectl_completion.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 0 additions & 27 deletions flytectl/docs/source/index.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 2 additions & 48 deletions flytectl/pkg/configutil/configutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,6 @@ const (
logger:
show-source: true
level: 0`
StorageConfigTemplate = `
storage:
connection:
access-key: minio
auth-type: accesskey
disable-ssl: true
endpoint: http://localhost:30084
region: us-east-1
secret-key: miniostorage
type: minio
container: "my-s3-bucket"
enable-multicontainer: true`
StorageS3ConfigTemplate = `
storage:
type: stow
stow:
kind: s3
config:
auth_type: iam
region: <replace> # Example: us-east-2
container: <replace> # Example my-bucket. Flyte k8s cluster / service account for execution should have read access to this bucket`
StorageGCSConfigTemplate = `
storage:
type: stow
stow:
kind: google
config:
json: ""
project_id: <replace-me> # TODO: replace <project-id> with the GCP project ID
scopes: https://www.googleapis.com/auth/devstorage.read_write
container: <replace> # Example my-bucket. Flyte k8s cluster / service account for execution should have read access to this bucket`
)

type ConfigTemplateSpec struct {
Expand All @@ -60,26 +29,11 @@ var (
Kubeconfig = f.FilePathJoin(f.UserHomeDir(), ".flyte", "k3s", "k3s.yaml")
)

// GetSandboxTemplate return sandbox cluster config
func GetSandboxTemplate() string {
return AdminConfigTemplate + StorageConfigTemplate
}

// GetDemoTemplate return demo cluster config
func GetDemoTemplate() string {
// GetTemplate returns cluster config
func GetTemplate() string {
return AdminConfigTemplate
}

// GetAWSCloudTemplate return aws Flyte config with storage config
func GetAWSCloudTemplate() string {
return AdminConfigTemplate + StorageS3ConfigTemplate
}

// GetGoogleCloudTemplate return google Flyte config with storage config
func GetGoogleCloudTemplate() string {
return AdminConfigTemplate + StorageGCSConfigTemplate
}

// SetupConfig download the Flyte sandbox config
func SetupConfig(filename, templateStr string, templateSpec ConfigTemplateSpec) error {
tmpl := template.New("config")
Expand Down
5 changes: 1 addition & 4 deletions flytectl/pkg/configutil/configutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,5 @@ func TestSetupFlytectlConfig(t *testing.T) {
}

func TestAwsConfig(t *testing.T) {
assert.Equal(t, AdminConfigTemplate+StorageS3ConfigTemplate, GetAWSCloudTemplate())
assert.Equal(t, AdminConfigTemplate+StorageGCSConfigTemplate, GetGoogleCloudTemplate())
assert.Equal(t, AdminConfigTemplate+StorageConfigTemplate, GetSandboxTemplate())
assert.Equal(t, AdminConfigTemplate, GetDemoTemplate())
assert.Equal(t, AdminConfigTemplate, GetTemplate())
}
Loading

0 comments on commit a3e6f4f

Please sign in to comment.