Explorar el Código

hotfix default cluster issue

Alexander Belanger hace 3 años
padre
commit
c843c87023
Se han modificado 1 ficheros con 17 adiciones y 0 borrados
  1. 17 0
      cmd/app/main.go

+ 17 - 0
cmd/app/main.go

@@ -93,6 +93,23 @@ func initData(conf *config.Config) error {
 			return err
 		}
 
+		// determine if there are any clusters in the project already
+		clusters, err := conf.Repo.Cluster().ListClustersByProjectID(1)
+
+		if err != nil {
+			return err
+		}
+
+		// if there are already clusters in the project, determine if any of the clusters are using an
+		// in-cluster auth mechanism
+		if len(clusters) > 0 {
+			for _, cluster := range clusters {
+				if cluster.AuthMechanism == models.InCluster {
+					return nil
+				}
+			}
+		}
+
 		_, err = conf.Repo.Cluster().ReadCluster(1, 1)
 
 		if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {