Add export for public git repos
This commit is contained in:
@@ -121,6 +121,32 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
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
|
withAuth := false
|
||||||
// TODO(hidde): move all auth prep to separate func?
|
// TODO(hidde): move all auth prep to separate func?
|
||||||
if u.Scheme == "ssh" {
|
if u.Scheme == "ssh" {
|
||||||
@@ -187,34 +213,12 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
logGenerate("generating source")
|
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 {
|
if withAuth {
|
||||||
gitRepository.Spec.SecretRef = &corev1.LocalObjectReference{
|
gitRepository.Spec.SecretRef = &corev1.LocalObjectReference{
|
||||||
Name: name,
|
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")
|
logAction("applying source")
|
||||||
if err := upsertGitRepository(ctx, kubeClient, gitRepository); err != nil {
|
if err := upsertGitRepository(ctx, kubeClient, gitRepository); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user