diff --git a/flytectl/cmd/compile/compile.go b/flytectl/cmd/compile/compile.go index d64f079152..f8f6957b10 100644 --- a/flytectl/cmd/compile/compile.go +++ b/flytectl/cmd/compile/compile.go @@ -29,8 +29,8 @@ func compileTasks(tasks []*core.TaskTemplate) ([]*core.CompiledTask, error) { } /* - Utility to compile a packaged workflow locally. - compilation is done locally so no flyte cluster is required. +Utility to compile a packaged workflow locally. +compilation is done locally so no flyte cluster is required. */ func compileFromPackage(packagePath string) error { args := []string{packagePath} diff --git a/flytectl/cmd/completion.go b/flytectl/cmd/completion.go index a243c7f0c1..b404cb57dd 100644 --- a/flytectl/cmd/completion.go +++ b/flytectl/cmd/completion.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/flytectl/cmd/config/subcommand/config/init_flags.go b/flytectl/cmd/config/subcommand/config/init_flags.go index 1e14634711..22427f0964 100755 --- a/flytectl/cmd/config/subcommand/config/init_flags.go +++ b/flytectl/cmd/config/subcommand/config/init_flags.go @@ -7,7 +7,7 @@ var ( } ) -//Configs +// Configs type Config struct { Host string `json:"host" pflag:",Endpoint of flyte admin"` Insecure bool `json:"insecure" pflag:",Enable insecure mode"` diff --git a/flytectl/cmd/config/subcommand/project/project_config.go b/flytectl/cmd/config/subcommand/project/project_config.go index 36e6c41cb9..0cf927f67a 100644 --- a/flytectl/cmd/config/subcommand/project/project_config.go +++ b/flytectl/cmd/config/subcommand/project/project_config.go @@ -44,7 +44,7 @@ var DefaultProjectConfig = &ConfigProject{ Labels: map[string]string{}, } -//GetProjectSpec return project spec from a file/flags +// GetProjectSpec return project spec from a file/flags func (c *ConfigProject) GetProjectSpec(id string) (*admin.Project, error) { projectSpec := admin.Project{} if len(c.File) > 0 { @@ -71,7 +71,7 @@ func (c *ConfigProject) GetProjectSpec(id string) (*admin.Project, error) { return &projectSpec, nil } -//MapToAdminState return project spec from a file/flags +// MapToAdminState return project spec from a file/flags func (c *ConfigProject) MapToAdminState() (admin.Project_ProjectState, error) { if c.ActivateProject { c.Activate = c.ActivateProject diff --git a/flytectl/cmd/config/subcommand/sandbox/config_flags.go b/flytectl/cmd/config/subcommand/sandbox/config_flags.go index 426e24204b..eaa7c88091 100755 --- a/flytectl/cmd/config/subcommand/sandbox/config_flags.go +++ b/flytectl/cmd/config/subcommand/sandbox/config_flags.go @@ -58,5 +58,6 @@ func (cfg Config) GetPFlagSet(prefix string) *pflag.FlagSet { cmdFlags.Var(&DefaultConfig.ImagePullPolicy, fmt.Sprintf("%v%v", prefix, "imagePullPolicy"), "Optional. Defines the image pull behavior [Always/IfNotPresent/Never]") cmdFlags.StringVar(&DefaultConfig.ImagePullOptions.RegistryAuth, fmt.Sprintf("%v%v", prefix, "imagePullOptions.registryAuth"), DefaultConfig.ImagePullOptions.RegistryAuth, "The base64 encoded credentials for the registry.") cmdFlags.StringVar(&DefaultConfig.ImagePullOptions.Platform, fmt.Sprintf("%v%v", prefix, "imagePullOptions.platform"), DefaultConfig.ImagePullOptions.Platform, "Forces a specific platform's image to be pulled.'") + cmdFlags.BoolVar(&DefaultConfig.Dev, fmt.Sprintf("%v%v", prefix, "dev"), DefaultConfig.Dev, "Optional. Only start minio and postgres in the sandbox.") return cmdFlags } diff --git a/flytectl/cmd/config/subcommand/sandbox/config_flags_test.go b/flytectl/cmd/config/subcommand/sandbox/config_flags_test.go index 3fdc64ba40..39dc790cfe 100755 --- a/flytectl/cmd/config/subcommand/sandbox/config_flags_test.go +++ b/flytectl/cmd/config/subcommand/sandbox/config_flags_test.go @@ -209,4 +209,18 @@ func TestConfig_SetFlags(t *testing.T) { } }) }) + t.Run("Test_dev", func(t *testing.T) { + + t.Run("Override", func(t *testing.T) { + testValue := "1" + + cmdFlags.Set("dev", testValue) + if vBool, err := cmdFlags.GetBool("dev"); err == nil { + testDecodeJson_Config(t, fmt.Sprintf("%v", vBool), &actual.Dev) + + } else { + assert.FailNow(t, err.Error()) + } + }) + }) } diff --git a/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go b/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go index 44f76f614c..c2d37c6407 100644 --- a/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go +++ b/flytectl/cmd/config/subcommand/sandbox/sandbox_config.go @@ -2,7 +2,7 @@ package sandbox import "github.com/flyteorg/flytectl/pkg/docker" -//Config holds configuration flags for sandbox command. +// Config holds configuration flags for sandbox command. type Config struct { Source string `json:"source" pflag:",Path of your source code"` @@ -27,6 +27,9 @@ type Config struct { ImagePullPolicy docker.ImagePullPolicy `json:"imagePullPolicy" pflag:",Optional. Defines the image pull behavior [Always/IfNotPresent/Never]"` ImagePullOptions docker.ImagePullOptions `json:"imagePullOptions" pflag:",Optional. Defines image pull options (e.g. auth)"` + + // It's used for development. Users are able to start flyte locally via single binary and save the data to the minio or postgres in the sandbox. + Dev bool `json:"dev" pflag:",Optional. Only start minio and postgres in the sandbox."` } //go:generate pflags Config --default-var DefaultConfig --bind-default-var diff --git a/flytectl/cmd/demo/start.go b/flytectl/cmd/demo/start.go index a1e3113398..1300496a2a 100644 --- a/flytectl/cmd/demo/start.go +++ b/flytectl/cmd/demo/start.go @@ -20,6 +20,11 @@ Starts the demo cluster without any source code: flytectl demo start +Runs a dev cluster, which only has minio and postgres pod. +:: + + flytectl demo start --dev + Mounts your source code repository inside the demo cluster: :: @@ -45,7 +50,7 @@ Runs a specific version of Flyte. Flytectl demo only supports Flyte version avai .. note:: Flytectl demo is only supported for Flyte versions >= v1.0.0 -Runs the latest pre release of Flyte. +Runs the latest pre release of Flyte. :: flytectl demo start --pre diff --git a/flytectl/cmd/upgrade/upgrade_test.go b/flytectl/cmd/upgrade/upgrade_test.go index 7b5b211e41..44095a5c13 100644 --- a/flytectl/cmd/upgrade/upgrade_test.go +++ b/flytectl/cmd/upgrade/upgrade_test.go @@ -44,7 +44,6 @@ func TestUpgradeCommand(t *testing.T) { assert.Equal(t, cmdNouns[0].Long, upgradeCmdLong) } -// func TestUpgrade(t *testing.T) { _ = util.WriteIntoFile([]byte("data"), tempExt) stdlibversion.Version = version diff --git a/flytectl/pkg/docker/docker_util.go b/flytectl/pkg/docker/docker_util.go index de7adda9b9..404db17fbc 100644 --- a/flytectl/pkg/docker/docker_util.go +++ b/flytectl/pkg/docker/docker_util.go @@ -96,6 +96,17 @@ func RemoveSandbox(ctx context.Context, cli Docker, reader io.Reader) error { return nil } +// GetDevPorts will return dev cluster (minio + postgres) ports +func GetDevPorts() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { + return nat.ParsePortSpecs([]string{ + "0.0.0.0:30082:30082", // K8s Dashboard Port + "0.0.0.0:30084:30084", // Minio API Port + "0.0.0.0:30086:30086", // K8s cluster + "0.0.0.0:30088:30088", // Minio Console Port + "0.0.0.0:30089:30089", // Postgres Port + }) +} + // GetSandboxPorts will return sandbox ports func GetSandboxPorts() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error) { return nat.ParsePortSpecs([]string{ diff --git a/flytectl/pkg/sandbox/start.go b/flytectl/pkg/sandbox/start.go index 012f104b41..94cb21c0e0 100644 --- a/flytectl/pkg/sandbox/start.go +++ b/flytectl/pkg/sandbox/start.go @@ -193,10 +193,14 @@ func startSandbox(ctx context.Context, cli docker.Docker, g github.GHRepoService if err := docker.PullDockerImage(ctx, cli, sandboxImage, sandboxConfig.ImagePullPolicy, sandboxConfig.ImagePullOptions); err != nil { return nil, err } + sandboxEnv := sandboxConfig.Env + if sandboxConfig.Dev { + sandboxEnv = append(sandboxEnv, "FLYTE_DEV=True") + } fmt.Printf("%v booting Flyte-sandbox container\n", emoji.FactoryWorker) ID, err := docker.StartContainer(ctx, cli, volumes, exposedPorts, portBindings, docker.FlyteSandboxClusterName, - sandboxImage, sandboxConfig.Env) + sandboxImage, sandboxEnv) if err != nil { fmt.Printf("%v Something went wrong: Failed to start Sandbox container %v, Please check your docker client and try again. \n", emoji.GrimacingFace, emoji.Whale) @@ -281,6 +285,9 @@ func StartDemoCluster(ctx context.Context, args []string, sandboxConfig *sandbox primePod := true sandboxImagePrefix := "sha" exposedPorts, portBindings, err := docker.GetDemoPorts() + if sandboxConfig.Dev { + exposedPorts, portBindings, err = docker.GetDevPorts() + } if err != nil { return err }