Make export work offline

pull/160/head
stefanprodan 4 years ago
parent 925c1d3d8e
commit 17df7a46e2

@ -113,14 +113,6 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("path must begin with ./") return fmt.Errorf("path must begin with ./")
} }
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
kubeClient, err := utils.kubeClient(kubeconfig)
if err != nil {
return err
}
if !export { if !export {
logger.Generatef("generating kustomization") logger.Generatef("generating kustomization")
} }
@ -190,6 +182,14 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
return exportKs(kustomization) return exportKs(kustomization)
} }
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
kubeClient, err := utils.kubeClient(kubeconfig)
if err != nil {
return err
}
logger.Actionf("applying kustomization") logger.Actionf("applying kustomization")
if err := upsertKustomization(ctx, kubeClient, kustomization); err != nil { if err := upsertKustomization(ctx, kubeClient, kustomization); err != nil {
return err return err

@ -129,14 +129,6 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("git URL parse failed: %w", err) return fmt.Errorf("git URL parse failed: %w", err)
} }
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
kubeClient, err := utils.kubeClient(kubeconfig)
if err != nil {
return err
}
gitRepository := sourcev1.GitRepository{ gitRepository := sourcev1.GitRepository{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
@ -163,6 +155,14 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
return exportGit(gitRepository) return exportGit(gitRepository)
} }
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
kubeClient, err := utils.kubeClient(kubeconfig)
if err != nil {
return err
}
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" {

@ -101,14 +101,6 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("url parse failed: %w", err) return fmt.Errorf("url parse failed: %w", err)
} }
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
kubeClient, err := utils.kubeClient(kubeconfig)
if err != nil {
return err
}
helmRepository := sourcev1.HelmRepository{ helmRepository := sourcev1.HelmRepository{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: name, Name: name,
@ -126,6 +118,14 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
return exportHelmRepository(helmRepository) return exportHelmRepository(helmRepository)
} }
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
kubeClient, err := utils.kubeClient(kubeconfig)
if err != nil {
return err
}
logger.Generatef("generating source") logger.Generatef("generating source")
secret := corev1.Secret{ secret := corev1.Secret{

Loading…
Cancel
Save