Skip to content

Commit

Permalink
Add conditions based on the situation.
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdappollonio committed Aug 28, 2024
1 parent 703dc80 commit b52ccde
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions cmd/k3d/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"os"
"strconv"
"strings"
"syscall"
"time"

"github.com/atotto/clipboard"
Expand All @@ -24,23 +25,22 @@ import (
argocdapi "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned"
"github.com/go-git/go-git/v5"
githttps "github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/konstructio/kubefirst-api/pkg/argocd"
"github.com/konstructio/kubefirst-api/pkg/configs"
constants "github.com/konstructio/kubefirst-api/pkg/constants"
"github.com/konstructio/kubefirst-api/pkg/gitClient"
"github.com/konstructio/kubefirst-api/pkg/handlers"
"github.com/konstructio/kubefirst-api/pkg/reports"
"github.com/konstructio/kubefirst-api/pkg/types"
utils "github.com/konstructio/kubefirst-api/pkg/utils"

"github.com/konstructio/kubefirst-api/pkg/argocd"
github "github.com/konstructio/kubefirst-api/pkg/github"
gitlab "github.com/konstructio/kubefirst-api/pkg/gitlab"
"github.com/konstructio/kubefirst-api/pkg/handlers"
"github.com/konstructio/kubefirst-api/pkg/k3d"
"github.com/konstructio/kubefirst-api/pkg/k8s"
"github.com/konstructio/kubefirst-api/pkg/progressPrinter"
"github.com/konstructio/kubefirst-api/pkg/reports"
"github.com/konstructio/kubefirst-api/pkg/services"
internalssh "github.com/konstructio/kubefirst-api/pkg/ssh"
"github.com/konstructio/kubefirst-api/pkg/terraform"
"github.com/konstructio/kubefirst-api/pkg/types"
utils "github.com/konstructio/kubefirst-api/pkg/utils"
"github.com/konstructio/kubefirst-api/pkg/wrappers"
"github.com/konstructio/kubefirst/internal/catalog"
"github.com/konstructio/kubefirst/internal/gitShim"
Expand All @@ -52,6 +52,7 @@ import (
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/spf13/cobra"
"github.com/spf13/viper"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
)
Expand Down Expand Up @@ -1043,11 +1044,18 @@ func runK3d(cmd *cobra.Command, args []string) error {
err = wait.PollImmediate(5*time.Second, 20*time.Second, func() (bool, error) {
_, err := argocdClient.ArgoprojV1alpha1().Applications("argocd").Create(context.Background(), registryApplicationObject, metav1.CreateOptions{})
if err != nil {
return false, nil
if errors.Is(err, syscall.ECONNREFUSED) {
return false, nil // retry if we can't connect to it
}

if apierrors.IsAlreadyExists(err) {
return true, nil // application already exists
}

return false, fmt.Errorf("error creating argocd application : %w", err)
}
return true, nil
})

if err != nil {
return fmt.Errorf("error creating argocd application : %w", err)
}
Expand Down

0 comments on commit b52ccde

Please sign in to comment.