From acc29f4ca7baf78fc7abac6c3a61dce2a97015de Mon Sep 17 00:00:00 2001 From: varshaprasad96 Date: Wed, 30 Jun 2021 10:38:12 -0700 Subject: [PATCH] fix: specify the right path of metadata in bundle.Dockerfile Signed-off-by: varshaprasad96 --- changelog/fragments/generate-bundle-fix.yaml | 17 +++++++++++++++++ internal/util/bundleutil/bundleutil.go | 8 +++++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 changelog/fragments/generate-bundle-fix.yaml diff --git a/changelog/fragments/generate-bundle-fix.yaml b/changelog/fragments/generate-bundle-fix.yaml new file mode 100644 index 0000000000..88320363fc --- /dev/null +++ b/changelog/fragments/generate-bundle-fix.yaml @@ -0,0 +1,17 @@ +# entries is a list of entries to include in +# release notes and/or the migration guide +entries: + - description: > + Fixed the `operator-sdk generate bundle` command to specify the right path of bundle + metadata in bundle.Dcokerfile. + + # kind is one of: + # - addition + # - change + # - deprecation + # - removal + # - bugfix + kind: bugfix + + # Is this a breaking change? + breaking: false diff --git a/internal/util/bundleutil/bundleutil.go b/internal/util/bundleutil/bundleutil.go index eab231cfeb..a604c3c1f9 100644 --- a/internal/util/bundleutil/bundleutil.go +++ b/internal/util/bundleutil/bundleutil.go @@ -88,7 +88,7 @@ func (meta *BundleMetaData) GenerateMetadata() error { // Create annotation values for both bundle.Dockerfile and annotations.yaml, which should // hold the same set of values always. values := annotationsValues{ - BundleDir: filepath.Base(meta.BundleDir), + BundleDir: meta.BundleDir, PackageName: meta.PackageName, Channels: meta.Channels, DefaultChannel: meta.DefaultChannel, @@ -107,11 +107,13 @@ func (meta *BundleMetaData) GenerateMetadata() error { } dockerfilePath := defaultBundleDockerfilePath - // If migrating from packagemanifests to bundle, bundle.Docker file is present - // inside bundleDir, else its in the project directory. + // If migrating from packagemanifests to bundle, bundle.Dockerfile is present + // inside bundleDir, else its in the project directory. Hence dockerfile + // should have the path specified with respect to output directory of resulting bundles. // Remmove this, when pkgman-to-bundle migrate command is removed. if len(meta.PkgmanifestPath) != 0 { dockerfilePath = filepath.Join(filepath.Dir(meta.BundleDir), "bundle.Dockerfile") + values.BundleDir = filepath.Base(meta.BundleDir) } templateMap := map[string]*template.Template{