Skip to content

Commit

Permalink
Merge pull request #160 from fluxcd/export-fix
Browse files Browse the repository at this point in the history
Make export work offline
  • Loading branch information
stefanprodan authored Aug 18, 2020
2 parents 925c1d3 + 17df7a4 commit 3fbc396
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
16 changes: 8 additions & 8 deletions cmd/tk/create_kustomization.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
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 {
logger.Generatef("generating kustomization")
}
Expand Down Expand Up @@ -190,6 +182,14 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
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")
if err := upsertKustomization(ctx, kubeClient, kustomization); err != nil {
return err
Expand Down
16 changes: 8 additions & 8 deletions cmd/tk/create_source_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,6 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
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{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -163,6 +155,14 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
return exportGit(gitRepository)
}

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

kubeClient, err := utils.kubeClient(kubeconfig)
if err != nil {
return err
}

withAuth := false
// TODO(hidde): move all auth prep to separate func?
if u.Scheme == "ssh" {
Expand Down
16 changes: 8 additions & 8 deletions cmd/tk/create_source_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
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{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -126,6 +118,14 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
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")

secret := corev1.Secret{
Expand Down

0 comments on commit 3fbc396

Please sign in to comment.