Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package okteto for openSUSE:Factory checked in at 2022-07-07 12:57:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/okteto (Old) and /work/SRC/openSUSE:Factory/.okteto.new.1523 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "okteto" Thu Jul 7 12:57:36 2022 rev:22 rq:987361 version:2.4.2 Changes: -------- --- /work/SRC/openSUSE:Factory/okteto/okteto.changes 2022-07-01 13:45:44.106968462 +0200 +++ /work/SRC/openSUSE:Factory/.okteto.new.1523/okteto.changes 2022-07-07 12:57:53.639370589 +0200 @@ -1,0 +2,7 @@ +Thu Jul 07 07:08:21 UTC 2022 - ka...@b1-systems.de + +- Update to version 2.4.2: + * fix configmap filename file path (#2864) (#2900) + * fix github actions release script (#2865) + +------------------------------------------------------------------- Old: ---- okteto-2.4.1.tar.gz New: ---- okteto-2.4.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ okteto.spec ++++++ --- /var/tmp/diff_new_pack.Eaft7B/_old 2022-07-07 12:57:54.471371828 +0200 +++ /var/tmp/diff_new_pack.Eaft7B/_new 2022-07-07 12:57:54.475371834 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: okteto -Version: 2.4.1 +Version: 2.4.2 Release: 0 Summary: Develop your applications directly in your Kubernetes Cluster License: Apache-2.0 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.Eaft7B/_old 2022-07-07 12:57:54.499371870 +0200 +++ /var/tmp/diff_new_pack.Eaft7B/_new 2022-07-07 12:57:54.503371876 +0200 @@ -3,10 +3,10 @@ <param name="url">https://github.com/okteto/okteto</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">2.4.1</param> + <param name="revision">2.4.2</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> - <param name="match-tag">2.4.1</param> + <param name="match-tag">2.4.2</param> </service> <service name="set_version" mode="disabled"> <param name="basename">okteto</param> @@ -16,7 +16,7 @@ <param name="compression">gz</param> </service> <service name="go_modules" mode="disabled"> - <param name="archive">okteto-2.4.1.tar.gz</param> + <param name="archive">okteto-2.4.2.tar.gz</param> </service> </services> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.Eaft7B/_old 2022-07-07 12:57:54.519371899 +0200 +++ /var/tmp/diff_new_pack.Eaft7B/_new 2022-07-07 12:57:54.519371899 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/okteto/okteto</param> - <param name="changesrevision">8db8f6de327c3883617b0c6db115e5e668c313be</param></service></servicedata> + <param name="changesrevision">abaf67e53a4eef3660d27fd36e17c6e45d552a7c</param></service></servicedata> (No newline at EOF) ++++++ okteto-2.4.1.tar.gz -> okteto-2.4.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/cmd/context/utils_test.go new/okteto-2.4.2/cmd/context/utils_test.go --- old/okteto-2.4.1/cmd/context/utils_test.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/cmd/context/utils_test.go 2022-07-06 18:00:19.000000000 +0200 @@ -176,7 +176,6 @@ Icon: "", Dev: model.ManifestDevs{}, Type: model.OktetoManifestType, - Filename: "", Dependencies: model.ManifestDependencies{ "one": &model.Dependency{ Repository: "https://repo.url", @@ -211,7 +210,6 @@ if tt.expectedErr { assert.NotNil(t, err) } else { - m.Filename = "" m.Manifest = nil assert.EqualValues(t, tt.expectedManifest, m) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/cmd/deploy/deploy.go new/okteto-2.4.2/cmd/deploy/deploy.go --- old/okteto-2.4.1/cmd/deploy/deploy.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/cmd/deploy/deploy.go 2022-07-06 18:00:19.000000000 +0200 @@ -41,6 +41,7 @@ oktetoLog "github.com/okteto/okteto/pkg/log" "github.com/okteto/okteto/pkg/model" "github.com/okteto/okteto/pkg/okteto" + oktetoPath "github.com/okteto/okteto/pkg/path" "github.com/okteto/okteto/pkg/types" "github.com/spf13/cobra" giturls "github.com/whilp/git-urls" @@ -58,6 +59,11 @@ // Options options for deploy command type Options struct { + // ManifestPathFlag is the option -f as introduced by the user when executing this command. + // This is stored at the configmap as filename to redeploy from the ui. + ManifestPathFlag string + // ManifestPath is the patah to the manifest used though the command execution. + // This might change its value during execution ManifestPath string Name string Namespace string @@ -123,11 +129,24 @@ // deploy command. If not, we could be proxying a proxy and we would be applying the incorrect deployed-by label os.Setenv(model.OktetoSkipConfigCredentialsUpdate, "false") if options.ManifestPath != "" { - workdir := model.GetWorkdirFromManifestPath(options.ManifestPath) - if err := os.Chdir(workdir); err != nil { + // if path is absolute, its transformed to rel from root + initialCWD, err := os.Getwd() + if err != nil { + return fmt.Errorf("failed to get the current working directory: %w", err) + } + manifestPathFlag, err := oktetoPath.GetRelativePathFromCWD(initialCWD, options.ManifestPath) + if err != nil { + return err + } + // as the installer uses root for executing the pipeline, we save the rel path from root as ManifestPathFlag option + options.ManifestPathFlag = manifestPathFlag + + // when the manifest path is set by the cmd flag, we are moving cwd so the cmd is executed from that dir + uptManifestPath, err := model.UpdateCWDtoManifestPath(options.ManifestPath) + if err != nil { return err } - options.ManifestPath = model.GetManifestPathFromWorkdir(options.ManifestPath, workdir) + options.ManifestPath = uptManifestPath } if err := contextCMD.LoadManifestV2WithContext(ctx, options.Namespace, options.K8sContext, options.ManifestPath); err != nil { if err.Error() == fmt.Errorf(oktetoErrors.ErrNotLogged, okteto.CloudURL).Error() { @@ -344,7 +363,7 @@ Namespace: deployOptions.Manifest.Namespace, Repository: os.Getenv(model.GithubRepositoryEnvVar), Branch: os.Getenv(model.OktetoGitBranchEnvVar), - Filename: deployOptions.Manifest.Filename, + Filename: deployOptions.ManifestPathFlag, Status: pipeline.ProgressingStatus, Manifest: deployOptions.Manifest.Manifest, Icon: deployOptions.Manifest.Icon, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/cmd/destroy/destroy.go new/okteto-2.4.2/cmd/destroy/destroy.go --- old/okteto-2.4.1/cmd/destroy/destroy.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/cmd/destroy/destroy.go 2022-07-06 18:00:19.000000000 +0200 @@ -38,6 +38,7 @@ oktetoLog "github.com/okteto/okteto/pkg/log" "github.com/okteto/okteto/pkg/model" "github.com/okteto/okteto/pkg/okteto" + oktetoPath "github.com/okteto/okteto/pkg/path" "github.com/spf13/cobra" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/labels" @@ -63,6 +64,11 @@ // Options destroy commands options type Options struct { + // ManifestPathFlag is the option -f as introduced by the user when executing this command. + // This is stored at the configmap as filename to redeploy from the ui. + ManifestPathFlag string + // ManifestPath is the patah to the manifest used though the command execution. + // This might change its value during execution ManifestPath string Name string Variables []string @@ -95,11 +101,24 @@ Args: utils.NoArgsAccepted("https://okteto.com/docs/reference/cli/#destroy"), RunE: func(cmd *cobra.Command, args []string) error { if options.ManifestPath != "" { - workdir := model.GetWorkdirFromManifestPath(options.ManifestPath) - if err := os.Chdir(workdir); err != nil { + // if path is absolute, its transformed to rel from root + initialCWD, err := os.Getwd() + if err != nil { + return fmt.Errorf("failed to get the current working directory: %w", err) + } + manifestPathFlag, err := oktetoPath.GetRelativePathFromCWD(initialCWD, options.ManifestPath) + if err != nil { + return err + } + // as the installer uses root for executing the pipeline, we save the rel path from root as ManifestPathFlag option + options.ManifestPathFlag = manifestPathFlag + + // when the manifest path is set by the cmd flag, we are moving cwd so the cmd is executed from that dir + uptManifestPath, err := model.UpdateCWDtoManifestPath(options.ManifestPath) + if err != nil { return err } - options.ManifestPath = model.GetManifestPathFromWorkdir(options.ManifestPath, workdir) + options.ManifestPath = uptManifestPath } if err := contextCMD.LoadManifestV2WithContext(ctx, options.Namespace, options.K8sContext, options.ManifestPath); err != nil { return err @@ -220,7 +239,7 @@ Name: opts.Name, Namespace: namespace, Status: pipeline.DestroyingStatus, - Filename: manifest.Filename, + Filename: opts.ManifestPathFlag, } cfg, err := pipeline.TranslateConfigMapAndDeploy(ctx, data, c) if err != nil { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/cmd/manifest/init-v2.go new/okteto-2.4.2/cmd/manifest/init-v2.go --- old/okteto-2.4.1/cmd/manifest/init-v2.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/cmd/manifest/init-v2.go 2022-07-06 18:00:19.000000000 +0200 @@ -415,7 +415,6 @@ }, Dev: model.ManifestDevs{}, Build: model.ManifestBuild{}, - Filename: composePath, IsV2: true, } cwd, err := os.Getwd() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/cmd/up/activate.go new/okteto-2.4.2/cmd/up/activate.go --- old/okteto-2.4.1/cmd/up/activate.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/cmd/up/activate.go 2022-07-06 18:00:19.000000000 +0200 @@ -227,7 +227,7 @@ } if up.Dev.PersistentVolumeEnabled() { - if err := volumes.CreateForDev(ctx, up.Dev, up.Client, up.Options.DevPath); err != nil { + if err := volumes.CreateForDev(ctx, up.Dev, up.Client, up.Options.ManifestPath); err != nil { return err } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/cmd/up/exec.go new/okteto-2.4.2/cmd/up/exec.go --- old/okteto-2.4.1/cmd/up/exec.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/cmd/up/exec.go 2022-07-06 18:00:19.000000000 +0200 @@ -103,7 +103,7 @@ return oktetoErrors.UserError{ E: fmt.Errorf("User %d doesn't have write permissions for synchronization paths", userID), Hint: fmt.Sprintf(`Set 'securityContext.runAsUser: %d' in your okteto manifest. - After that, run '%s' to reset your development container and run 'okteto up' again`, userID, utils.GetDownCommand(up.Options.DevPath)), + After that, run '%s' to reset your development container and run 'okteto up' again`, userID, utils.GetDownCommand(up.Options.ManifestPathFlag)), } } } @@ -113,12 +113,12 @@ E: fmt.Errorf(msg), Hint: fmt.Sprintf(`Check your development container logs for errors: 'kubectl logs %s', Check that your container can write to the destination path of your secrets. - Run '%s' to reset your development container and try again`, up.Pod.Name, utils.GetDownCommand(up.Options.DevPath)), + Run '%s' to reset your development container and try again`, up.Pod.Name, utils.GetDownCommand(up.Options.ManifestPathFlag)), } } return oktetoErrors.UserError{ E: fmt.Errorf(msg), Hint: fmt.Sprintf(`Check your development container logs for errors: 'kubectl logs %s'. - Run '%s' to reset your development container and try again`, up.Pod.Name, utils.GetDownCommand(up.Options.DevPath)), + Run '%s' to reset your development container and try again`, up.Pod.Name, utils.GetDownCommand(up.Options.ManifestPathFlag)), } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/cmd/up/syncthing.go new/okteto-2.4.2/cmd/up/syncthing.go --- old/okteto-2.4.1/cmd/up/syncthing.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/cmd/up/syncthing.go 2022-07-06 18:00:19.000000000 +0200 @@ -182,7 +182,7 @@ E: err, Hint: fmt.Sprintf(`Help us improve okteto by filing an issue in https://github.com/okteto/okteto/issues/new. Please include the file generated by 'okteto doctor' if possible. - Then, try to run '%s' + 'okteto up' again`, utils.GetDownCommand(up.Options.DevPath)), + Then, try to run '%s' + 'okteto up' again`, utils.GetDownCommand(up.Options.ManifestPathFlag)), } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/cmd/up/up.go new/okteto-2.4.2/cmd/up/up.go --- old/okteto-2.4.1/cmd/up/up.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/cmd/up/up.go 2022-07-06 18:00:19.000000000 +0200 @@ -41,6 +41,7 @@ oktetoLog "github.com/okteto/okteto/pkg/log" "github.com/okteto/okteto/pkg/model" "github.com/okteto/okteto/pkg/okteto" + oktetoPath "github.com/okteto/okteto/pkg/path" "github.com/okteto/okteto/pkg/registry" "github.com/okteto/okteto/pkg/ssh" "github.com/okteto/okteto/pkg/syncthing" @@ -54,16 +55,21 @@ // UpOptions represents the options available on up command type UpOptions struct { - DevPath string - Namespace string - K8sContext string - DevName string - Devs []string - Envs []string - Remote int - Deploy bool - ForcePull bool - Reset bool + // ManifestPathFlag is the option -f as introduced by the user when executing this command. + // This is stored at the configmap as filename to redeploy from the ui. + ManifestPathFlag string + // ManifestPath is the patah to the manifest used though the command execution. + // This might change its value during execution + ManifestPath string + Namespace string + K8sContext string + DevName string + Devs []string + Envs []string + Remote int + Deploy bool + ForcePull bool + Reset bool } // Up starts a development container @@ -98,14 +104,27 @@ ctx := context.Background() - if upOptions.DevPath != "" { - workdir := model.GetWorkdirFromManifestPath(upOptions.DevPath) - if err := os.Chdir(workdir); err != nil { + if upOptions.ManifestPath != "" { + // if path is absolute, its transformed to rel from root + initialCWD, err := os.Getwd() + if err != nil { + return fmt.Errorf("failed to get the current working directory: %w", err) + } + manifestPathFlag, err := oktetoPath.GetRelativePathFromCWD(initialCWD, upOptions.ManifestPath) + if err != nil { + return err + } + // as the installer uses root for executing the pipeline, we save the rel path from root as ManifestPathFlag option + upOptions.ManifestPathFlag = manifestPathFlag + + // when the manifest path is set by the cmd flag, we are moving cwd so the cmd is executed from that dir + uptManifestPath, err := model.UpdateCWDtoManifestPath(upOptions.ManifestPath) + if err != nil { return err } - upOptions.DevPath = model.GetManifestPathFromWorkdir(upOptions.DevPath, workdir) + upOptions.ManifestPath = uptManifestPath } - manifestOpts := contextCMD.ManifestOptions{Filename: upOptions.DevPath, Namespace: upOptions.Namespace, K8sContext: upOptions.K8sContext} + manifestOpts := contextCMD.ManifestOptions{Filename: upOptions.ManifestPath, Namespace: upOptions.Namespace, K8sContext: upOptions.K8sContext} oktetoManifest, err := contextCMD.LoadManifestWithContext(ctx, manifestOpts) if err != nil { if err.Error() == fmt.Errorf(oktetoErrors.ErrNotLogged, okteto.CloudURL).Error() { @@ -116,15 +135,15 @@ return err } - if upOptions.DevPath == "" { - upOptions.DevPath = utils.DefaultManifest + if upOptions.ManifestPath == "" { + upOptions.ManifestPath = utils.DefaultManifest } - if !utils.AskIfOktetoInit(upOptions.DevPath) { + if !utils.AskIfOktetoInit(upOptions.ManifestPath) { return err } - oktetoManifest, err = LoadManifestWithInit(ctx, upOptions.K8sContext, upOptions.Namespace, upOptions.DevPath) + oktetoManifest, err = LoadManifestWithInit(ctx, upOptions.K8sContext, upOptions.Namespace, upOptions.ManifestPath) if err != nil { return err } @@ -148,11 +167,11 @@ mc := &manifest.ManifestCommand{ K8sClientProvider: okteto.NewK8sClientProvider(), } - if upOptions.DevPath == "" { - upOptions.DevPath = utils.DefaultManifest + if upOptions.ManifestPath == "" { + upOptions.ManifestPath = utils.DefaultManifest } oktetoManifest, err = mc.RunInitV2(ctx, &manifest.InitOpts{ - DevPath: upOptions.DevPath, + DevPath: upOptions.ManifestPath, Namespace: upOptions.Namespace, Context: upOptions.K8sContext, ShowCTA: false, @@ -306,7 +325,7 @@ }, } - cmd.Flags().StringVarP(&upOptions.DevPath, "file", "f", "", "path to the manifest file") + cmd.Flags().StringVarP(&upOptions.ManifestPath, "file", "f", "", "path to the manifest file") cmd.Flags().StringVarP(&upOptions.Namespace, "namespace", "n", "", "namespace where the up command is executed") cmd.Flags().StringVarP(&upOptions.K8sContext, "context", "c", "", "context where the up command is executed") cmd.Flags().StringArrayVarP(&upOptions.Envs, "env", "e", []string{}, "envs to add to the development container") @@ -463,10 +482,11 @@ } return c.RunDeploy(ctx, &deploy.Options{ - Name: up.Manifest.Name, - ManifestPath: up.Manifest.Filename, - Timeout: 5 * time.Minute, - Build: false, + Name: up.Manifest.Name, + ManifestPathFlag: up.Options.ManifestPathFlag, + ManifestPath: up.Options.ManifestPath, + Timeout: 5 * time.Minute, + Build: false, }) } @@ -708,7 +728,7 @@ E: err, Hint: fmt.Sprintf(`Okteto volume is full. Increase your persistent volume size, run '%s' and try 'okteto up' again. - More information about configuring your persistent volume at https://okteto.com/docs/reference/manifest/#persistentvolume-object-optional`, utils.GetDownCommand(up.Options.DevPath)), + More information about configuring your persistent volume at https://okteto.com/docs/reference/manifest/#persistentvolume-object-optional`, utils.GetDownCommand(up.Options.ManifestPathFlag)), } } return oktetoErrors.UserError{ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/pkg/cmd/pipeline/translate.go new/okteto-2.4.2/pkg/cmd/pipeline/translate.go --- old/okteto-2.4.1/pkg/cmd/pipeline/translate.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/pkg/cmd/pipeline/translate.go 2022-07-06 18:00:19.000000000 +0200 @@ -179,17 +179,13 @@ statusField: data.Status, repoField: data.Repository, branchField: data.Branch, - filenameField: data.Filename, + filenameField: "", yamlField: base64.StdEncoding.EncodeToString(data.Manifest), iconField: data.Icon, }, } if data.Repository != "" { - cmap.Data[repoField] = data.Repository - } - - if data.Branch != "" { - cmap.Data[branchField] = data.Branch + cmap.Data[filenameField] = data.Filename } output := oktetoLog.GetOutputBuffer() @@ -209,11 +205,14 @@ cmap.ObjectMeta.Labels[model.GitDeployLabel] = "true" cmap.Data[nameField] = data.Name cmap.Data[statusField] = data.Status - cmap.Data[filenameField] = data.Filename cmap.Data[yamlField] = base64.StdEncoding.EncodeToString(data.Manifest) cmap.Data[iconField] = data.Icon cmap.Data[actionNameField] = actionName if data.Repository != "" { + // the filename at the cfgmap is used by the installer to re-deploy the app from the ui + // this parameter is just saved if a repository is being detected + // when repository is empty - the filename should not be saved and redeploys should be done from cli + cmap.Data[filenameField] = data.Filename cmap.Data[repoField] = data.Repository } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/pkg/model/file.go new/okteto-2.4.2/pkg/model/file.go --- old/okteto-2.4.1/pkg/model/file.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/pkg/model/file.go 2022-07-06 18:00:19.000000000 +0200 @@ -13,7 +13,10 @@ package model -import "path/filepath" +import ( + "os" + "path/filepath" +) // GetWorkdirFromManifestPath sets the path func GetWorkdirFromManifestPath(manifestPath string) string { @@ -32,3 +35,12 @@ } return mPath } + +func UpdateCWDtoManifestPath(manifestPath string) (string, error) { + workdir := GetWorkdirFromManifestPath(manifestPath) + if err := os.Chdir(workdir); err != nil { + return "", err + } + updatedManifestPath := GetManifestPathFromWorkdir(manifestPath, workdir) + return updatedManifestPath, nil +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/pkg/model/file_test.go new/okteto-2.4.2/pkg/model/file_test.go --- old/okteto-2.4.1/pkg/model/file_test.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/pkg/model/file_test.go 2022-07-06 18:00:19.000000000 +0200 @@ -14,6 +14,7 @@ package model import ( + "os" "path/filepath" "strings" "testing" @@ -73,3 +74,119 @@ }) } } + +func Test_GetManifestPathFromWorkdir(t *testing.T) { + var tests = []struct { + name string + path string + workdir string + expectedPath string + }{ + { + name: "inside .okteto folder", + path: filepath.Join(".okteto", "okteto.yml"), + workdir: ".", + expectedPath: filepath.Join(".okteto", "okteto.yml"), + }, + { + name: "one path ahead", + path: filepath.Join("test", "okteto.yml"), + workdir: "test", + expectedPath: "okteto.yml", + }, + { + name: "same path", + path: "okteto.yml", + workdir: ".", + expectedPath: "okteto.yml", + }, + { + name: "full path", + path: filepath.Join("/usr", "okteto.yml"), + workdir: "/usr", + expectedPath: "okteto.yml", + }, + { + name: "full path on .okteto", + path: filepath.Join("/usr", ".okteto", "okteto.yml"), + workdir: "/usr", + expectedPath: filepath.Join(".okteto", "okteto.yml"), + }, + { + name: "relative path with more than two paths ahead", + path: filepath.Join("~", "app", ".okteto", "okteto.yml"), + workdir: "~/app", + expectedPath: filepath.Join(".okteto", "okteto.yml"), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + res := GetManifestPathFromWorkdir(tt.path, tt.workdir) + assert.Equal(t, tt.expectedPath, res) + }) + } +} + +func Test_UpdateCWDtoManifestPath(t *testing.T) { + root := t.TempDir() + var tests = []struct { + name string + path string + expectedPath string + expectedErr bool + }{ + { + name: "inside .okteto folder", + path: filepath.Join(root, ".okteto", "okteto.yml"), + expectedPath: filepath.Join(".okteto", "okteto.yml"), + }, + { + name: "one path ahead", + path: filepath.Join(root, "test", "okteto.yml"), + expectedPath: "okteto.yml", + }, + { + name: "same path", + path: filepath.Join(root, "okteto.yml"), + expectedPath: "okteto.yml", + }, + { + name: "full path on .okteto", + path: filepath.Join(root, "usr", ".okteto", "okteto.yml"), + expectedPath: filepath.Join(".okteto", "okteto.yml"), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + + initialCWD, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + + if err := os.Chdir(root); err != nil { + t.Fatal(err) + } + + if err := os.MkdirAll(tt.path, 0700); err != nil { + t.Fatal(err) + } + + res, err := UpdateCWDtoManifestPath(tt.path) + if tt.expectedErr && err == nil { + t.Fatal("expected err") + } + if !tt.expectedErr && err != nil { + t.Fatalf("not expected error, got %v", err) + } + + assert.Equal(t, tt.expectedPath, res) + + if err := os.Chdir(initialCWD); err != nil { + t.Fatal(err) + } + }) + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/pkg/model/manifest.go new/okteto-2.4.2/pkg/model/manifest.go --- old/okteto-2.4.1/pkg/model/manifest.go 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/pkg/model/manifest.go 2022-07-06 18:00:19.000000000 +0200 @@ -149,7 +149,6 @@ Dependencies ManifestDependencies `json:"dependencies,omitempty" yaml:"dependencies,omitempty"` Type Archetype `json:"-" yaml:"-"` - Filename string `yaml:"-"` Manifest []byte `json:"-" yaml:"-"` IsV2 bool `json:"-" yaml:"-"` } @@ -287,19 +286,7 @@ manifestPath = filepath.Join(cwd, manifestPath) } if manifestPath != "" && FileExistsAndNotDir(manifestPath) { - manifest, err := getManifestFromFile(cwd, manifestPath) - if err != nil { - return nil, err - } - path := "" - if filepath.IsAbs(manifestPath) { - path, err = filepath.Rel(cwd, manifestPath) - if err != nil { - oktetoLog.Debugf("could not detect relative path to %s: %s", manifestPath, err) - } - } - manifest.Filename = path - return manifest, nil + return getManifestFromFile(cwd, manifestPath) } return nil, oktetoErrors.ErrManifestNotFound diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/pkg/path/path.go new/okteto-2.4.2/pkg/path/path.go --- old/okteto-2.4.1/pkg/path/path.go 1970-01-01 01:00:00.000000000 +0100 +++ new/okteto-2.4.2/pkg/path/path.go 2022-07-06 18:00:19.000000000 +0200 @@ -0,0 +1,16 @@ +package path + +import "path/filepath" + +// GetRelativePathFromCWD returns the relative path from the cwd +func GetRelativePathFromCWD(cwd, path string) (string, error) { + if path == "" || !filepath.IsAbs(path) { + return path, nil + } + + relativePath, err := filepath.Rel(cwd, path) + if err != nil { + return "", err + } + return relativePath, nil +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/pkg/path/path_test.go new/okteto-2.4.2/pkg/path/path_test.go --- old/okteto-2.4.1/pkg/path/path_test.go 1970-01-01 01:00:00.000000000 +0100 +++ new/okteto-2.4.2/pkg/path/path_test.go 2022-07-06 18:00:19.000000000 +0200 @@ -0,0 +1,60 @@ +package path + +import ( + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_GetRelativePathFromCWD(t *testing.T) { + root := t.TempDir() + var tests = []struct { + name string + path string + cwd string + expectedPath string + expectedErr bool + }{ + { + name: "inside .okteto folder", + path: filepath.Join(root, ".okteto", "okteto.yml"), + cwd: root, + expectedPath: filepath.Join(".okteto", "okteto.yml"), + }, + { + name: "one path ahead - cwd is folder", + path: filepath.Join(root, "test", "okteto.yml"), + cwd: filepath.Join(root, "test"), + expectedPath: "okteto.yml", + }, + { + name: "one path ahead - cwd is root", + path: filepath.Join(root, "test", "okteto.yml"), + cwd: root, + expectedPath: filepath.Join("test", "okteto.yml"), + }, + { + name: "one path ahead not abs - cwd is root", + path: filepath.Join("test", "okteto.yml"), + cwd: root, + expectedPath: filepath.Join("test", "okteto.yml"), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + + res, err := GetRelativePathFromCWD(tt.cwd, tt.path) + if tt.expectedErr && err == nil { + t.Fatal("expected err") + } + if !tt.expectedErr && err != nil { + t.Fatalf("not expected error, got %v", err) + } + + assert.Equal(t, tt.expectedPath, res) + + }) + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/okteto-2.4.1/scripts/ci/release-github-actions.sh new/okteto-2.4.2/scripts/ci/release-github-actions.sh --- old/okteto-2.4.1/scripts/ci/release-github-actions.sh 2022-06-30 14:46:31.000000000 +0200 +++ new/okteto-2.4.2/scripts/ci/release-github-actions.sh 2022-07-06 18:00:19.000000000 +0200 @@ -97,8 +97,9 @@ exit 0 fi - sed -i '' -E 's_FROM\ okteto\/okteto\:latest_FROM\ okteto\/okteto\:'"$RELEASE_TAG"'_' Dockerfile - sed -i '' -E 's_FROM\ okteto\/okteto\:[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*_FROM\ okteto\/okteto\:'"$RELEASE_TAG"'_' Dockerfile + # NOTE: these sed commands will not work in OS X and will require `brew install gnu-sed` and updating the PATH + sed -i -E 's_FROM\ okteto\/okteto\:latest_FROM\ okteto\/okteto\:'"$RELEASE_TAG"'_' Dockerfile + sed -i -E 's_FROM\ okteto\/okteto\:[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*_FROM\ okteto\/okteto\:'"$RELEASE_TAG"'_' Dockerfile git add Dockerfile git commit -m "release ${RELEASE_TAG}" @@ -126,7 +127,7 @@ -token "$GITHUB_TOKEN" \ -recreate \ -replace \ - -commitish "$(git rev-parse main)" \ + -commitish "$(git rev-parse "${RELEASE_TAG}")" \ latest fi ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/okteto/vendor.tar.gz /work/SRC/openSUSE:Factory/.okteto.new.1523/vendor.tar.gz differ: char 5, line 1