Skip to content

Commit

Permalink
Add flag by cluster to disable validation
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed May 15, 2024
1 parent 3064e3e commit 624caf0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
13 changes: 7 additions & 6 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ type RpaasConfig struct {
}

type ClusterConfig struct {
Name string `json:"name"`
Default bool `json:"default"`
Address string `json:"address"`
Token string `json:"token"`
TokenFile string `json:"tokenFile"`
CA string `json:"ca"`
Name string `json:"name"`
Default bool `json:"default"`
DisableValidation bool `json:"disableValidation"`
Address string `json:"address"`
Token string `json:"token"`
TokenFile string `json:"tokenFile"`
CA string `json:"ca"`

AuthProvider *clientcmdapi.AuthProviderConfig `json:"authProvider"`
ExecProvider *clientcmdapi.ExecConfig `json:"execProvider"`
Expand Down
15 changes: 14 additions & 1 deletion pkg/web/target/multi-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ func (m *multiClusterFactory) Manager(ctx context.Context, headers http.Header)
return nil, err
}

clusterValidationDisabled := m.validationDisabled(clusterName)

k8sClient, err := sigsk8sclient.New(kubernetesRestConfig, sigsk8sclient.Options{Scheme: extensionsruntime.NewScheme()})
if err != nil {
return nil, err
Expand All @@ -103,7 +105,7 @@ func (m *multiClusterFactory) Manager(ctx context.Context, headers http.Header)
return nil, err
}

if !disableValidation {
if !disableValidation && !clusterValidationDisabled {
manager = validation.New(manager, k8sClient)
}

Expand All @@ -114,6 +116,17 @@ func (m *multiClusterFactory) Manager(ctx context.Context, headers http.Header)
return manager, nil
}

func (m *multiClusterFactory) validationDisabled(name string) bool {

for _, cluster := range m.clusters {
if cluster.Name == name {
return cluster.DisableValidation
}
}

return false
}

func (m *multiClusterFactory) getKubeConfig(name, address string) (*rest.Config, error) {
selectedCluster := config.ClusterConfig{}

Expand Down

0 comments on commit 624caf0

Please sign in to comment.