Skip to content

Commit

Permalink
provide the ability to disable features
Browse files Browse the repository at this point in the history
part of: kiali#4737
  • Loading branch information
jmazzitelli committed Mar 23, 2022
1 parent 06558ed commit 5661caf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ type CertificatesInformationIndicators struct {
// KialiFeatureFlags available from the CR
type KialiFeatureFlags struct {
CertificatesInformationIndicators CertificatesInformationIndicators `yaml:"certificates_information_indicators,omitempty" json:"certificatesInformationIndicators"`
DisabledFeatures []string `yaml:"disabled_features,omitempty" json:"disabledFeatures,omitempty"`
IstioInjectionAction bool `yaml:"istio_injection_action,omitempty" json:"istioInjectionAction"`
IstioUpgradeAction bool `yaml:"istio_upgrade_action,omitempty" json:"istioUpgradeAction"`
UIDefaults UIDefaults `yaml:"ui_defaults,omitempty" json:"uiDefaults,omitempty"`
Expand Down Expand Up @@ -617,6 +618,7 @@ func NewConfig() (c *Config) {
Enabled: true,
Secrets: []string{"cacerts", "istio-ca-secret"},
},
DisabledFeatures: []string{},
IstioInjectionAction: true,
IstioUpgradeAction: false,
UIDefaults: UIDefaults{
Expand Down Expand Up @@ -931,3 +933,14 @@ func IsIstioNamespace(namespace string) bool {
func IsRootNamespace(namespace string) bool {
return namespace == configuration.ExternalServices.Istio.RootNamespace
}

// IsFeatureDisabled will return true if the named feature is to be disabled.
func IsFeatureDisabled(featureName string) bool {
cfg := Get()
for _, f := range cfg.KialiFeatureFlags.DisabledFeatures {
if f == featureName {
return true
}
}
return false
}
5 changes: 5 additions & 0 deletions handlers/workloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/gorilla/mux"

"github.com/kiali/kiali/business"
"github.com/kiali/kiali/config"
"github.com/kiali/kiali/models"
)

Expand Down Expand Up @@ -205,6 +206,10 @@ func PodDetails(w http.ResponseWriter, r *http.Request) {

// PodLogs is the API handler to fetch logs for a single pod container
func PodLogs(w http.ResponseWriter, r *http.Request) {
if config.IsFeatureDisabled("log-view") {
RespondWithError(w, http.StatusForbidden, "Pod Logs access is disabled")
return
}
vars := mux.Vars(r)
queryParams := r.URL.Query()

Expand Down

0 comments on commit 5661caf

Please sign in to comment.