1
0
mirror of synced 2026-02-06 19:05:55 +00:00

Add export for public git repos

This commit is contained in:
stefanprodan
2020-06-09 16:22:35 +03:00
parent c047a4476e
commit 0cd820e923

View File

@@ -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