github.com/thanhphan1147/cloudfoundry-cli@v7.1.0+incompatible/command/flag/health_check_type_with_deprecated_value.go (about)

     1  package flag
     2  
     3  import (
     4  	"strings"
     5  
     6  	flags "github.com/jessevdk/go-flags"
     7  )
     8  
     9  type HealthCheckTypeWithDeprecatedValue struct {
    10  	Type string
    11  }
    12  
    13  func (HealthCheckTypeWithDeprecatedValue) Complete(prefix string) []flags.Completion {
    14  	return completions([]string{"http", "port", "process"}, prefix, false)
    15  }
    16  
    17  func (h *HealthCheckTypeWithDeprecatedValue) UnmarshalFlag(val string) error {
    18  	valLower := strings.ToLower(val)
    19  	switch valLower {
    20  	case "port", "process", "http", "none":
    21  		h.Type = valLower
    22  	default:
    23  		return &flags.Error{
    24  			Type:    flags.ErrRequired,
    25  			Message: `HEALTH_CHECK_TYPE must be "port", "process", or "http"`,
    26  		}
    27  	}
    28  	return nil
    29  }