github.com/swisscom/cloudfoundry-cli@v7.1.0+incompatible/actor/v2action/feature_flag.go (about)

     1  package v2action
     2  
     3  import "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2"
     4  
     5  type FeatureFlagState string
     6  
     7  const (
     8  	FeatureFlagEnabled  FeatureFlagState = "enabled"
     9  	FeatureFlagDisabled FeatureFlagState = "disabled"
    10  )
    11  
    12  type FeatureFlag ccv2.FeatureFlag
    13  
    14  func (f FeatureFlag) State() FeatureFlagState {
    15  	if f.Enabled {
    16  		return FeatureFlagEnabled
    17  	}
    18  	return FeatureFlagDisabled
    19  }
    20  
    21  func (actor Actor) GetFeatureFlags() ([]FeatureFlag, Warnings, error) {
    22  	featureFlags, warnings, err := actor.CloudControllerClient.GetConfigFeatureFlags()
    23  	if err != nil {
    24  		return nil, Warnings(warnings), err
    25  	}
    26  
    27  	var convertedFeatureFlags []FeatureFlag
    28  	for _, flag := range featureFlags {
    29  		convertedFeatureFlags = append(convertedFeatureFlags, FeatureFlag(flag))
    30  	}
    31  
    32  	return convertedFeatureFlags, Warnings(warnings), nil
    33  }