Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make export work offline #160

Merged
merged 1 commit into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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