Parcourir la source

Add Feature Flag to Reprovision (#3368)

sdess09 il y a 2 ans
Parent
commit
d46ae39a53

+ 1 - 0
api/server/handlers/project/create.go

@@ -45,6 +45,7 @@ func (p *ProjectCreateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
 		SimplifiedViewEnabled:  true,
 		HelmValuesEnabled:      false,
 		MultiCluster:           false,
+		EnableReprovision:      false,
 	}
 
 	var err error

+ 1 - 0
api/server/handlers/project/create_test.go

@@ -46,6 +46,7 @@ func TestCreateProjectSuccessful(t *testing.T) {
 		SimplifiedViewEnabled:  true,
 		HelmValuesEnabled:      false,
 		MultiCluster:           false,
+		EnableReprovision:      false,
 	}
 
 	gotProject := &types.CreateProjectResponse{}

+ 2 - 0
api/types/project.go

@@ -14,6 +14,7 @@ type Project struct {
 	AzureEnabled           bool    `json:"azure_enabled"`
 	HelmValuesEnabled      bool    `json:"helm_values_enabled"`
 	MultiCluster           bool    `json:"multi_cluster"`
+	EnableReprovision      bool    `json:"enable_reprovision"`
 	ValidateApplyV2        bool    `json:"validate_apply_v2"`
 }
 
@@ -27,6 +28,7 @@ type FeatureFlags struct {
 	AzureEnabled               bool   `json:"azure_enabled,omitempty"`
 	HelmValuesEnabled          bool   `json:"helm_values_enabled,omitempty"`
 	MultiCluster               bool   `json:"multi_cluster,omitempty"`
+	EnableReprovision          bool   `json:"enable_reprovision,omitempty"`
 	ValidateApplyV2            bool   `json:"validate_apply_v2"`
 }
 

+ 1 - 1
dashboard/src/components/ProvisionerSettings.tsx

@@ -880,7 +880,7 @@ const ProvisionerSettings: React.FC<Props> = (props) => {
       <Button
         // disabled={isDisabled()}
         disabled={
-          user?.email === "admin@porter.run" || currentProject?.id === 7760 || currentProject?.id === 7257 || currentProject?.id === 7645
+          user?.email === "admin@porter.run" || currentProject?.enable_reprovision
             ? false
             : currentCluster
               ? true

+ 1 - 0
dashboard/src/shared/types.tsx

@@ -273,6 +273,7 @@ export interface ProjectType {
   azure_enabled: boolean;
   helm_values_enabled: boolean;
   multi_cluster: boolean;
+  enable_reprovision: boolean;
   roles: {
     id: number;
     kind: string;

+ 2 - 0
internal/models/project.go

@@ -69,6 +69,7 @@ type Project struct {
 	HelmValuesEnabled      bool
 	MultiCluster           bool `gorm:"default:false"`
 	ValidateApplyV2        bool `gorm:"default:false"`
+	EnableReprovision      bool `gorm:"default:false"`
 }
 
 // ToProjectType generates an external types.Project to be shared over REST
@@ -93,6 +94,7 @@ func (p *Project) ToProjectType() *types.Project {
 		AzureEnabled:           p.AzureEnabled,
 		HelmValuesEnabled:      p.HelmValuesEnabled,
 		MultiCluster:           p.MultiCluster,
+		EnableReprovision:      p.EnableReprovision,
 		ValidateApplyV2:        p.ValidateApplyV2,
 	}
 }