From ac7ccf7b94f9cf094abae60ad5428b67037161d0 Mon Sep 17 00:00:00 2001 From: Phil Nichol <35630607+philnichol@users.noreply.github.com> Date: Fri, 1 Oct 2021 10:45:30 +0100 Subject: [PATCH] added tag,semver,commit to manifestgen Signed-off-by: Phil Nichol <35630607+philnichol@users.noreply.github.com> --- pkg/manifestgen/sync/options.go | 3 +++ pkg/manifestgen/sync/sync.go | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pkg/manifestgen/sync/options.go b/pkg/manifestgen/sync/options.go index 71da1e47..7085d56e 100644 --- a/pkg/manifestgen/sync/options.go +++ b/pkg/manifestgen/sync/options.go @@ -26,6 +26,9 @@ type Options struct { Name string Namespace string Branch string + Tag string + SemVer string + Commit string Secret string TargetPath string ManifestFile string diff --git a/pkg/manifestgen/sync/sync.go b/pkg/manifestgen/sync/sync.go index b2557208..665cae16 100644 --- a/pkg/manifestgen/sync/sync.go +++ b/pkg/manifestgen/sync/sync.go @@ -35,6 +35,20 @@ import ( func Generate(options Options) (*manifestgen.Manifest, error) { gvk := sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind) + gitRef := &sourcev1.GitRepositoryRef{} + if options.Branch != "" { + gitRef.Branch = options.Branch + } + if options.Tag != "" { + gitRef.Tag = options.Tag + } + if options.SemVer != "" { + gitRef.SemVer = options.SemVer + } + if options.Commit != "" { + gitRef.Commit = options.Commit + } + gitRepository := sourcev1.GitRepository{ TypeMeta: metav1.TypeMeta{ Kind: gvk.Kind, @@ -49,9 +63,7 @@ func Generate(options Options) (*manifestgen.Manifest, error) { Interval: metav1.Duration{ Duration: options.Interval, }, - Reference: &sourcev1.GitRepositoryRef{ - Branch: options.Branch, - }, + Reference: gitRef, SecretRef: &meta.LocalObjectReference{ Name: options.Secret, }, -- GitLab