Stefan McShane 3 лет назад
Родитель
Сommit
6151704778

+ 3 - 0
api/server/shared/config/config.go

@@ -104,6 +104,9 @@ type Config struct {
 
 	// NATS contains the required config for connecting to a NATS cluster for streaming
 	NATS nats.NATS
+
+	// DisableCAPIProvisioner disables checks for ClusterControlPlaneClient and NATS, if set to true
+	DisableCAPIProvisioner bool
 }
 
 type ConfigLoader interface {

+ 3 - 0
api/server/shared/config/env/envconfs.go

@@ -125,6 +125,9 @@ type ServerConf struct {
 
 	// NATSUrl is the URL of the NATS cluster
 	NATSUrl string `env:"NATS_URL"`
+
+	// DisableCAPIProvisioner disables checks for ClusterControlPlaneClient and NATS, if set to true
+	DisableCAPIProvisioner bool `env:"DISABLE_TEMPORARY_KUBECONFIG"`
 }
 
 // DBConf is the database configuration: if generated from environment variables,

+ 15 - 12
api/server/shared/config/loader/loader.go

@@ -232,20 +232,23 @@ func (e *EnvConfigLoader) LoadConfig() (res *config.Config, err error) {
 		res.PowerDNSClient = powerdns.NewClient(sc.PowerDNSAPIServerURL, sc.PowerDNSAPIKey, sc.AppRootDomain)
 	}
 
-	if sc.ClusterControlPlaneAddress == "" {
-		return res, errors.New("must provide CLUSTER_CONTROL_PLANE_ADDRESS")
-	}
-	client := porterv1connect.NewClusterControlPlaneServiceClient(http.DefaultClient, sc.ClusterControlPlaneAddress)
-	res.ClusterControlPlaneClient = client
+	res.DisableCAPIProvisioner = sc.DisableCAPIProvisioner
+	if sc.DisableCAPIProvisioner {
+		if sc.ClusterControlPlaneAddress == "" {
+			return res, errors.New("must provide CLUSTER_CONTROL_PLANE_ADDRESS")
+		}
+		client := porterv1connect.NewClusterControlPlaneServiceClient(http.DefaultClient, sc.ClusterControlPlaneAddress)
+		res.ClusterControlPlaneClient = client
 
-	if sc.NATSUrl == "" {
-		return res, errors.New("must provide NATS_URL")
-	}
-	pnats, err := nats.NewConnection(ctx, nats.Config{URL: sc.NATSUrl})
-	if err != nil {
-		return res, fmt.Errorf("error setting up connection to NATS cluster")
+		if sc.NATSUrl == "" {
+			return res, errors.New("must provide NATS_URL")
+		}
+		pnats, err := nats.NewConnection(ctx, nats.Config{URL: sc.NATSUrl})
+		if err != nil {
+			return res, fmt.Errorf("error setting up connection to NATS cluster")
+		}
+		res.NATS = pnats
 	}
-	res.NATS = pnats
 
 	return res, nil
 }