From 820f4575f17851eabc1512c269eba8453e66338c Mon Sep 17 00:00:00 2001 From: ELADAV Date: Tue, 19 Nov 2024 15:19:30 +0200 Subject: [PATCH 1/5] added first commit for path fix --- pkg/executor/push.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/executor/push.go b/pkg/executor/push.go index 2580e314c4..cbe5139e9b 100644 --- a/pkg/executor/push.go +++ b/pkg/executor/push.go @@ -196,7 +196,17 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error { } if opts.OCILayoutPath != "" { - path, err := layout.Write(opts.OCILayoutPath, empty.Index) + resolvedPath := opts.OCILayoutPath + if !filepath.IsAbs(resolvedPath) { + // If the path is relative, make it absolute + cwd, err := os.Getwd() + if err != nil { + return errors.Wrap(err, "getting current working directory") + } + resolvedPath = filepath.Join(cwd, resolvedPath) + } + + path, err := layout.Write(resolvedPath, empty.Index) if err != nil { return errors.Wrap(err, "writing empty layout") } @@ -204,7 +214,8 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error { return errors.Wrap(err, "appending image") } } - + + if opts.NoPush && len(opts.Destinations) == 0 { if opts.TarPath != "" { setDummyDestinations(opts) From cca4b5f927ed005dc6f3a654507cc64c1c118271 Mon Sep 17 00:00:00 2001 From: ELADAV Date: Wed, 20 Nov 2024 13:56:01 +0200 Subject: [PATCH 2/5] added oci-layout-path opt to relativePath check --- cmd/executor/cmd/root.go | 1 + pkg/executor/push.go | 12 +----------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/cmd/executor/cmd/root.go b/cmd/executor/cmd/root.go index 7f0339c5df..5f25093ddb 100644 --- a/cmd/executor/cmd/root.go +++ b/cmd/executor/cmd/root.go @@ -454,6 +454,7 @@ func resolveRelativePaths() error { &opts.DigestFile, &opts.ImageNameDigestFile, &opts.ImageNameTagDigestFile, + &opts.OCILayoutPath, } for _, p := range optsPaths { diff --git a/pkg/executor/push.go b/pkg/executor/push.go index cbe5139e9b..15909b49b1 100644 --- a/pkg/executor/push.go +++ b/pkg/executor/push.go @@ -196,17 +196,7 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error { } if opts.OCILayoutPath != "" { - resolvedPath := opts.OCILayoutPath - if !filepath.IsAbs(resolvedPath) { - // If the path is relative, make it absolute - cwd, err := os.Getwd() - if err != nil { - return errors.Wrap(err, "getting current working directory") - } - resolvedPath = filepath.Join(cwd, resolvedPath) - } - - path, err := layout.Write(resolvedPath, empty.Index) + path, err := layout.Write(opts.OCILayoutPath, empty.Index) if err != nil { return errors.Wrap(err, "writing empty layout") } From efa7da69bd260cb6e4eda888837b6536edcb3583 Mon Sep 17 00:00:00 2001 From: Elad Avikzer Date: Wed, 20 Nov 2024 13:56:01 +0200 Subject: [PATCH 3/5] added oci-layout-path opt to relativePath check --- cmd/executor/cmd/root.go | 1 + pkg/executor/push.go | 12 +----------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/cmd/executor/cmd/root.go b/cmd/executor/cmd/root.go index 7f0339c5df..5f25093ddb 100644 --- a/cmd/executor/cmd/root.go +++ b/cmd/executor/cmd/root.go @@ -454,6 +454,7 @@ func resolveRelativePaths() error { &opts.DigestFile, &opts.ImageNameDigestFile, &opts.ImageNameTagDigestFile, + &opts.OCILayoutPath, } for _, p := range optsPaths { diff --git a/pkg/executor/push.go b/pkg/executor/push.go index cbe5139e9b..15909b49b1 100644 --- a/pkg/executor/push.go +++ b/pkg/executor/push.go @@ -196,17 +196,7 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error { } if opts.OCILayoutPath != "" { - resolvedPath := opts.OCILayoutPath - if !filepath.IsAbs(resolvedPath) { - // If the path is relative, make it absolute - cwd, err := os.Getwd() - if err != nil { - return errors.Wrap(err, "getting current working directory") - } - resolvedPath = filepath.Join(cwd, resolvedPath) - } - - path, err := layout.Write(resolvedPath, empty.Index) + path, err := layout.Write(opts.OCILayoutPath, empty.Index) if err != nil { return errors.Wrap(err, "writing empty layout") } From bf31db1e48eb6ce91b0ee71e9aa9ef5459752833 Mon Sep 17 00:00:00 2001 From: Elad Date: Thu, 21 Nov 2024 11:08:24 +0200 Subject: [PATCH 4/5] removed blank lines --- pkg/executor/push.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/executor/push.go b/pkg/executor/push.go index 15909b49b1..d3e527f653 100644 --- a/pkg/executor/push.go +++ b/pkg/executor/push.go @@ -205,7 +205,6 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error { } } - if opts.NoPush && len(opts.Destinations) == 0 { if opts.TarPath != "" { setDummyDestinations(opts) From 516cff1d958e3ac0c0b73c8b76eb6cacb5634541 Mon Sep 17 00:00:00 2001 From: Elad Avikzer Date: Thu, 21 Nov 2024 11:08:24 +0200 Subject: [PATCH 5/5] removed blank lines --- pkg/executor/push.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/executor/push.go b/pkg/executor/push.go index 15909b49b1..d3e527f653 100644 --- a/pkg/executor/push.go +++ b/pkg/executor/push.go @@ -205,7 +205,6 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error { } } - if opts.NoPush && len(opts.Destinations) == 0 { if opts.TarPath != "" { setDummyDestinations(opts)