diff --git a/cmd/init.go b/cmd/init.go index 5f5a2d329e..a41a59db7d 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -506,15 +506,17 @@ echo 'Anyone using this project can invoke it via "devspace run migrate-db"'`, // Add pipeline: dev config.Pipelines["dev"] = &latest.Pipeline{ Run: `run_dependencies --all # 1. Deploy any projects this project needs (see "dependencies") -create_deployments --all # 2. Deploy Helm charts and manifests specfied as "deployments" -start_dev ` + imageName + ` # 3. Start dev mode "` + imageName + `" (see "dev" section)`, +ensure_pull_secrets --all # 2. Ensure pull secrets +create_deployments --all # 3. Deploy Helm charts and manifests specfied as "deployments" +start_dev ` + imageName + ` # 4. Start dev mode "` + imageName + `" (see "dev" section)`, } // Add pipeline: dev config.Pipelines["deploy"] = &latest.Pipeline{ Run: `run_dependencies --all # 1. Deploy any projects this project needs (see "dependencies") -build_images --all -t $(git describe --always) # 2. Build, tag (git commit hash) and push all images (see "images") -create_deployments --all # 3. Deploy Helm charts and manifests specfied as "deployments"`, +ensure_pull_secrets --all # 2. Ensure pull secrets +build_images --all -t $(git describe --always) # 3. Build, tag (git commit hash) and push all images (see "images") +create_deployments --all # 4. Deploy Helm charts and manifests specfied as "deployments"`, } // Save config @@ -661,19 +663,6 @@ func annotateConfig(configPath string) error { # tag: v1.0.0 # ui: # path: ./ui # Path-based dependencies (for monorepos) -`)...) - - annotatedConfig = append(annotatedConfig, []byte(` -# Customize local registry settings -# localRegistry: -# enabled: true # Always use local registry, remove to only use the local registry when required -# name: registry -# namespace: ${devspace.namespace} # Uses the current kube context's namespace (can be removed) -# image: registry:2.8.1 -# port: 5000 -# persistence: -# enabled: false -# size: 5Gi `)...) err = os.WriteFile(configPath, annotatedConfig, os.ModePerm) @@ -784,7 +773,7 @@ func (cmd *InitCmd) addDevConfig(config *latest.Config, imageName, image string, Command: "helm", }, { - Command: "git", + GitCredentials: true, }, }...) diff --git a/cmd/run.go b/cmd/run.go index 21d1aec43a..080afdafaa 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -109,12 +109,6 @@ func (cmd *RunCmd) RunRun(f factory.Factory, args []string) error { // Set config root configOptions := cmd.ToConfigOptions() - configOptions.Vars = append([]string{ - "devspace.namespace=" + cmd.Namespace, - "DEVSPACE_NAMESPACE=" + cmd.Namespace, - "devspace.context=" + cmd.KubeContext, - "DEVSPACE_CONTEXT=" + cmd.KubeContext, - }, configOptions.Vars...) configLoader, err := f.NewConfigLoader(cmd.ConfigPath) if err != nil { return err @@ -127,7 +121,7 @@ func (cmd *RunCmd) RunRun(f factory.Factory, args []string) error { } // load the config - ctx, err := LoadCommandsConfig(configLoader, configOptions, f.GetLog()) + ctx, err := cmd.LoadCommandsConfig(f, configLoader, configOptions, f.GetLog()) if err != nil { return err } @@ -241,21 +235,29 @@ func ParseArgs(cobraCmd *cobra.Command, globalFlags *flags.GlobalFlags, log log. } // LoadCommandsConfig loads the commands config -func LoadCommandsConfig(configLoader loader.ConfigLoader, configOptions *loader.ConfigOptions, log log.Logger) (devspacecontext.Context, error) { +func (cmd *RunCmd) LoadCommandsConfig(f factory.Factory, configLoader loader.ConfigLoader, configOptions *loader.ConfigOptions, log log.Logger) (devspacecontext.Context, error) { // load generated localCache, err := configLoader.LoadLocalCache() if err != nil { return nil, err } + // try to load client + client, err := f.NewKubeClientFromContext(cmd.KubeContext, cmd.Namespace) + if err != nil { + log.Debugf("Unable to create new kubectl client: %v", err) + client = nil + } + // Parse commands - commandsInterface, err := configLoader.LoadWithParser(context.Background(), localCache, nil, loader.NewCommandsParser(), configOptions, log) + commandsInterface, err := configLoader.LoadWithParser(context.Background(), localCache, client, loader.NewCommandsParser(), configOptions, log) if err != nil { return nil, err } // create context return devspacecontext.NewContext(context.Background(), commandsInterface.Variables(), log). + WithKubeClient(client). WithConfig(commandsInterface), nil }