...

Source file src/edge-infra.dev/pkg/sds/emergencyaccess/authservice/config.go

Documentation: edge-infra.dev/pkg/sds/emergencyaccess/authservice

     1  package authservice
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  )
     7  
     8  const (
     9  	defaultRulesEngineHost = "rulesengine"
    10  	defaultUserServiceHost = "userservice"
    11  	confUserServiceHost    = "ea-user-service-host"
    12  	confRulesEngineHost    = "ea-rules-engine-host"
    13  	confEdgeAPI            = "edge-api"
    14  )
    15  
    16  // Config is a struct that stores the cli or env flags at runtime.
    17  type Config struct {
    18  	UserServiceHost string
    19  	RulesEngineHost string
    20  	EdgeAPI         string
    21  }
    22  
    23  // Bind flags updates the flags at runtime when ffparse is called (usually in main)
    24  func (config *Config) BindFlags(flags *flag.FlagSet) {
    25  	flags.StringVar(
    26  		&config.UserServiceHost,
    27  		confUserServiceHost,
    28  		defaultUserServiceHost,
    29  		"IP address at which user service endpoints are hosted",
    30  	)
    31  
    32  	flags.StringVar(
    33  		&config.RulesEngineHost,
    34  		confRulesEngineHost,
    35  		defaultRulesEngineHost,
    36  		"IP address at which rules engine endpoints are hosted",
    37  	)
    38  
    39  	flags.StringVar(
    40  		&config.EdgeAPI,
    41  		confEdgeAPI,
    42  		config.EdgeAPI,
    43  		"URL of the Edge API to be used to authenticate users.",
    44  	)
    45  }
    46  
    47  func (config *Config) Validate() error {
    48  	if config.EdgeAPI == "" {
    49  		return fmt.Errorf("edge api url required")
    50  	}
    51  
    52  	return nil
    53  }
    54  

View as plain text