config

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvIdentityCertFile       = "IDENTITY_CERT_FILE"
	EnvIdentityPrivateKeyFile = "IDENTITY_PRIVATE_KEY_FILE"

	EnvPrometheusServiceURL   = "PROMETHEUS_SERVICE_URL"
	EnvInCluster              = "IN_CLUSTER"
	EnvIstioIdentityDomain    = "ISTIO_IDENTITY_DOMAIN"
	EnvIstioSidecarAnnotation = "ISTIO_SIDECAR_ANNOTATION"
	EnvIstioUrlServiceVersion = "ISTIO_URL_SERVICE_VERSION"

	EnvServerAddress                    = "SERVER_ADDRESS"
	EnvServerPort                       = "SERVER_PORT"
	EnvServerCredentialsUsername        = "SERVER_CREDENTIALS_USERNAME"
	EnvServerCredentialsPassword        = "SERVER_CREDENTIALS_PASSWORD"
	EnvServerStaticContentRootDirectory = "SERVER_STATIC_CONTENT_ROOT_DIRECTORY"
	EnvServerCORSAllowAll               = "SERVER_CORS_ALLOW_ALL"

	EnvGrafanaDisplayLink      = "GRAFANA_DISPLAY_LINK"
	EnvGrafanaURL              = "GRAFANA_URL"
	EnvGrafanaServiceNamespace = "GRAFANA_SERVICE_NAMESPACE"
	EnvGrafanaService          = "GRAFANA_SERVICE"
	EnvGrafanaDashboard        = "GRAFANA_DASHBOARD"
	EnvGrafanaVarServiceSource = "GRAFANA_VAR_SERVICE_SOURCE"
	EnvGrafanaVarServiceDest   = "GRAFANA_VAR_SERVICE_DEST"

	EnvJaegerURL              = "JAEGER_URL"
	EnvJaegerServiceNamespace = "JAEGER_SERVICE_NAMESPACE"
	EnvJaegerService          = "JAEGER_SERVICE"

	EnvServiceFilterLabelName = "SERVICE_FILTER_LABEL_NAME"
	EnvVersionFilterLabelName = "VERSION_FILTER_LABEL_NAME"

	EnvTokenSecret       = "TOKEN_SECRET"
	EnvTokenExpirationAt = "TOKEN_EXPIRATION_AT"

	IstioVersionSupported = ">= 0.8"
)

Environment vars can define some default values. NOTE: If you add a new variable, don't forget to update README.adoc

Variables

This section is empty.

Functions

func AuthenticationHandler

func AuthenticationHandler(next http.Handler) http.Handler

func Marshal

func Marshal(conf *Config) (yamlString string, err error)

Marshal converts the Config object and returns its YAML string.

func SaveToFile

func SaveToFile(filename string, conf *Config) (err error)

SaveToFile converts the Config object and stores its YAML string into the given file, overwriting any data that is in the file.

func Set

func Set(conf *Config)

Set the global Config

func ValidateToken

func ValidateToken(tokenString string) error

Types

type Config

type Config struct {
	Identity               security.Identity `yaml:",omitempty"`
	Server                 Server            `yaml:",omitempty"`
	InCluster              bool              `yaml:"in_cluster,omitempty"`
	ServiceFilterLabelName string            `yaml:"service_filter_label_name,omitempty"`
	VersionFilterLabelName string            `yaml:"version_filter_label_name,omitempty"`
	ExternalServices       ExternalServices  `yaml:"external_services,omitempty"`
	Token                  Token             `yaml:"token,omitempty"`
}

Config defines full YAML configuration.

func Get

func Get() (conf *Config)

Get the global Config

func LoadFromFile

func LoadFromFile(filename string) (conf *Config, err error)

LoadFromFile reads the YAML from the given file, parses the content, and returns its Config object representation.

func NewConfig

func NewConfig() (c *Config)

NewConfig creates a default Config struct

func Unmarshal

func Unmarshal(yamlString string) (conf *Config, err error)

Unmarshal parses the given YAML string and returns its Config object representation.

func (Config) String

func (conf Config) String() (str string)

String marshals the given Config into a YAML string

type ExternalServices

type ExternalServices struct {
	Istio                IstioConfig   `yaml:"istio,omitempty"`
	PrometheusServiceURL string        `yaml:"prometheus_service_url,omitempty"`
	Grafana              GrafanaConfig `yaml:"grafana,omitempty"`
	Jaeger               JaegerConfig  `yaml:"jaeger,omitempty"`
}

type GrafanaConfig

type GrafanaConfig struct {
	DisplayLink      bool   `yaml:"display_link"`
	URL              string `yaml:"url"`
	ServiceNamespace string `yaml:"service_namespace"`
	Service          string `yaml:"service"`
	Dashboard        string `yaml:"dashboard"`
	VarServiceSource string `yaml:"var_service_source"`
	VarServiceDest   string `yaml:"var_service_dest"`
}

GrafanaConfig describes configuration used for Grafana links

type IstioConfig

type IstioConfig struct {
	UrlServiceVersion      string `yaml:"url_service_version"`
	IstioIdentityDomain    string `yaml:"istio_identity_domain,omitempty"`
	IstioSidecarAnnotation string `yaml:"istio_sidecar_annotation,omitempty"`
}

IstioConfig describes configuration used for istio links

type JaegerConfig

type JaegerConfig struct {
	URL              string `yaml:"url"`
	ServiceNamespace string `yaml:"service_namespace"`
	Service          string `yaml:"service"`
}

JaegerConfig describes configuration used for jaeger links

type Server

type Server struct {
	Address                    string               `yaml:",omitempty"`
	Port                       int                  `yaml:",omitempty"`
	Credentials                security.Credentials `yaml:",omitempty"`
	StaticContentRootDirectory string               `yaml:"static_content_root_directory,omitempty"`
	CORSAllowAll               bool                 `yaml:"cors_allow_all,omitempty"`
}

Server configuration

type Token

type Token struct {
	Secret       []byte `yaml:"secret,omitempty"`
	ExpirationAt int64  `yaml:"expiration,omitempty"`
}

type TokenClaim

type TokenClaim struct {
	User string `json:"username"`
	jwt.StandardClaims
}

Structured version of Claims Section, as referenced at https://tools.ietf.org/html/rfc7519#section-4.1 See examples for how to use this with your own claim types

type TokenGenerated

type TokenGenerated struct {
	// The authentication token
	// A string with the authentication token for the user
	//
	// example: zI1NiIsIsR5cCI6IkpXVCJ9.ezJ1c2VybmFtZSI6ImFkbWluIiwiZXhwIjoxNTI5NTIzNjU0fQ.PPZvRGnR6VA4v7FmgSfQcGQr-VD
	// required: true
	Token string `json:"token"`
	// The expired time for the token
	// A string with the Datetime when the token will be expired
	//
	// example: 2018-06-20 19:40:54.116369887 +0000 UTC m=+43224.838320603
	// required: true
	ExpiredAt string `json:"expired_at"`
}

TokenGenerated tokenGenerated

This is used for returning the token

swagger:model TokenGenerated

func GenerateToken

func GenerateToken(username string) (TokenGenerated, error)

Generate the token with a Expiraton of <ExpiresAt> seconds

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL