diff --git a/cmd/tk/create_source_git.go b/cmd/tk/create_source_git.go index bbad2099..43cdf3c9 100644 --- a/cmd/tk/create_source_git.go +++ b/cmd/tk/create_source_git.go @@ -121,6 +121,32 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error { return err } + gitRepository := sourcev1.GitRepository{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Spec: sourcev1.GitRepositorySpec{ + URL: sourceGitURL, + Interval: metav1.Duration{ + Duration: interval, + }, + Reference: &sourcev1.GitRepositoryRef{}, + }, + } + + if sourceGitSemver != "" { + gitRepository.Spec.Reference.SemVer = sourceGitSemver + } else if sourceGitTag != "" { + gitRepository.Spec.Reference.Tag = sourceGitTag + } else { + gitRepository.Spec.Reference.Branch = sourceGitBranch + } + + if export { + return exportGit(gitRepository) + } + withAuth := false // TODO(hidde): move all auth prep to separate func? if u.Scheme == "ssh" { @@ -187,34 +213,12 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error { logGenerate("generating source") - gitRepository := sourcev1.GitRepository{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - Namespace: namespace, - }, - Spec: sourcev1.GitRepositorySpec{ - URL: sourceGitURL, - Interval: metav1.Duration{ - Duration: interval, - }, - Reference: &sourcev1.GitRepositoryRef{}, - }, - } - if withAuth { gitRepository.Spec.SecretRef = &corev1.LocalObjectReference{ Name: name, } } - if sourceGitSemver != "" { - gitRepository.Spec.Reference.SemVer = sourceGitSemver - } else if sourceGitTag != "" { - gitRepository.Spec.Reference.Tag = sourceGitTag - } else { - gitRepository.Spec.Reference.Branch = sourceGitBranch - } - logAction("applying source") if err := upsertGitRepository(ctx, kubeClient, gitRepository); err != nil { return err