mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-17 13:11:48 +00:00
Merge pull request #1881 from philnichol/add-git-ref-options-to-manifestgen
Add tag, semver and commit args to manifestgen
This commit is contained in:
commit
b9ceceada4
2 changed files with 18 additions and 3 deletions
|
|
@ -26,6 +26,9 @@ type Options struct {
|
||||||
Name string
|
Name string
|
||||||
Namespace string
|
Namespace string
|
||||||
Branch string
|
Branch string
|
||||||
|
Tag string
|
||||||
|
SemVer string
|
||||||
|
Commit string
|
||||||
Secret string
|
Secret string
|
||||||
TargetPath string
|
TargetPath string
|
||||||
ManifestFile string
|
ManifestFile string
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,20 @@ import (
|
||||||
|
|
||||||
func Generate(options Options) (*manifestgen.Manifest, error) {
|
func Generate(options Options) (*manifestgen.Manifest, error) {
|
||||||
gvk := sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)
|
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{
|
gitRepository := sourcev1.GitRepository{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
Kind: gvk.Kind,
|
Kind: gvk.Kind,
|
||||||
|
|
@ -49,9 +63,7 @@ func Generate(options Options) (*manifestgen.Manifest, error) {
|
||||||
Interval: metav1.Duration{
|
Interval: metav1.Duration{
|
||||||
Duration: options.Interval,
|
Duration: options.Interval,
|
||||||
},
|
},
|
||||||
Reference: &sourcev1.GitRepositoryRef{
|
Reference: gitRef,
|
||||||
Branch: options.Branch,
|
|
||||||
},
|
|
||||||
SecretRef: &meta.LocalObjectReference{
|
SecretRef: &meta.LocalObjectReference{
|
||||||
Name: options.Secret,
|
Name: options.Secret,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue