github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/actor/v7pushaction/handle_health_check_endpoint_override.go (about)

     1  package v7pushaction
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"
     5  	"code.cloudfoundry.org/cli/command/translatableerror"
     6  	"code.cloudfoundry.org/cli/util/manifestparser"
     7  )
     8  
     9  func HandleHealthCheckEndpointOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) {
    10  	if overrides.HealthCheckEndpoint != "" {
    11  
    12  		if manifest.ContainsMultipleApps() {
    13  			return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{}
    14  		}
    15  
    16  		var healthCheckType constant.HealthCheckType
    17  
    18  		webProcess := manifest.GetFirstAppWebProcess()
    19  		if webProcess != nil {
    20  			webProcess.HealthCheckEndpoint = overrides.HealthCheckEndpoint
    21  			healthCheckType = webProcess.HealthCheckType
    22  		} else {
    23  			app := manifest.GetFirstApp()
    24  			app.HealthCheckEndpoint = overrides.HealthCheckEndpoint
    25  			healthCheckType = app.HealthCheckType
    26  		}
    27  
    28  		if healthCheckType != "" && healthCheckType != constant.HTTP {
    29  			return manifest, translatableerror.ArgumentManifestMismatchError{
    30  				Arg:              "--endpoint",
    31  				ManifestProperty: "health-check-type",
    32  				ManifestValue:    string(healthCheckType),
    33  			}
    34  		}
    35  	}
    36  
    37  	return manifest, nil
    38  }