From d3b548fc51e34524659f0093b175e137565ae60f Mon Sep 17 00:00:00 2001 From: Matthias Diester Date: Wed, 28 Jul 2021 14:26:11 +0200 Subject: [PATCH] Apply suggestions from code review Apply suggestions from code review. Co-authored-by: Sascha Schwarze --- cmd/bundle/main.go | 2 +- pkg/apis/build/v1alpha1/source.go | 2 +- pkg/bundle/bundle.go | 1 + pkg/reconciler/buildrun/resources/sources.go | 2 +- pkg/reconciler/buildrun/resources/sources/bundle.go | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/bundle/main.go b/cmd/bundle/main.go index cf84ed10dd..b51ce94172 100644 --- a/cmd/bundle/main.go +++ b/cmd/bundle/main.go @@ -89,7 +89,7 @@ func resolveAuthBasedOnTarget(ref name.Reference) (authn.Authenticator, error) { } // Look-up the respective registry server inside the credentials - var registryName = ref.Context().RegistryStr() + registryName := ref.Context().RegistryStr() if registryName == name.DefaultRegistry { registryName = authn.DefaultAuthKey } diff --git a/pkg/apis/build/v1alpha1/source.go b/pkg/apis/build/v1alpha1/source.go index 8b61d1c226..af2ac75580 100644 --- a/pkg/apis/build/v1alpha1/source.go +++ b/pkg/apis/build/v1alpha1/source.go @@ -19,7 +19,7 @@ type Source struct { // URL describes the URL of the Git repository. // // +optional - URL string `json:"url"` + URL string `json:"url,omitempty"` // BundleContainer // diff --git a/pkg/bundle/bundle.go b/pkg/bundle/bundle.go index dde31b7bf0..c79e025dbc 100644 --- a/pkg/bundle/bundle.go +++ b/pkg/bundle/bundle.go @@ -247,6 +247,7 @@ func Unpack(in io.Reader, targetPath string) error { } if _, err := io.Copy(file, tr); err != nil { + file.Close() return err } diff --git a/pkg/reconciler/buildrun/resources/sources.go b/pkg/reconciler/buildrun/resources/sources.go index 31b7bf306d..56f2c29d54 100644 --- a/pkg/reconciler/buildrun/resources/sources.go +++ b/pkg/reconciler/buildrun/resources/sources.go @@ -22,7 +22,7 @@ func AmendTaskSpecWithSources( case build.Spec.Source.BundleContainer != nil: sources.AppendBundleStep(cfg, taskSpec, build.Spec.Source, "default") - default: + case build.Spec.Source.URL != "": sources.AppendGitStep(cfg, taskSpec, build.Spec.Source, "default") } diff --git a/pkg/reconciler/buildrun/resources/sources/bundle.go b/pkg/reconciler/buildrun/resources/sources/bundle.go index 6be111bf53..0c72b256a7 100644 --- a/pkg/reconciler/buildrun/resources/sources/bundle.go +++ b/pkg/reconciler/buildrun/resources/sources/bundle.go @@ -27,7 +27,7 @@ func AppendBundleStep( } // add the build-specific details - bundleStep.Container.Name = fmt.Sprintf("bundle-%s", name) + bundleStep.Container.Name = fmt.Sprintf("source-%s", name) bundleStep.Container.Args = []string{ "--image", source.BundleContainer.Image, "--target", fmt.Sprintf("$(params.%s-%s)", prefixParamsResultsVolumes, paramSourceRoot),