utils

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TlsCertPath                  = "/var/run/secrets/certs/tls.crt"
	TlsKeyPath                   = "/var/run/secrets/certs/tls.key"
	TlsCaFile                    = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
	TokenFile                    = "/var/run/secrets/kubernetes.io/serviceaccount/token"
	Dns1123LabelFmt       string = "^[a-z0-9][-a-z0-9]*$"
	DNS1123LabelMaxLength int    = 63
)
View Source
const (
	KubiResourcePrefix = "kubi"

	KubiClusterRoleBindingReaderName = "kubi-reader"
	KubiDefaultNetworkPolicyName     = "kubi-default"

	UnauthenticatedGroup = "system:unauthenticated"
	AdminGroup           = "system:masters"

	KubiStageScratch = "scratch"
	KubiStageStaging = "staging"
	KubiStageStable  = "stable"

	KubiEnvironmentProduction  = "production"
	KubiEnvironmentIntegration = "integration"
	KubiEnvironmentDevelopment = "development"

	KubiTenantUndeterminable = "undeterminable"
)

Variables

View Source
var BlacklistedNamespaces = []string{
	"kube-system",
	"kube-public",
	"ingress-nginx",
	"default",
	KubiResourcePrefix,
}
View Source
var Config *types.Config
View Source
var Histogram = promauto.NewHistogramVec(prometheus.HistogramOpts{
	Name:    "kubi_http_requests",
	Help:    "Time per requests",
	Buckets: []float64{1, 2, 5, 6, 10},

}, []string{"path"}) // this will be partitioned by the HTTP code.
View Source
var Log = zerolog.New(output).With().Timestamp().Logger()
View Source
var TokenCounter = promauto.NewCounterVec(prometheus.CounterOpts{
	Name: "kubi_valid_token_total",
	Help: "Total number of tokens issued",
}, []string{"status"})

Functions

func All

func All(vs []string, f func(string) bool) bool

All returns `true` if every strings in the slice satisfy the predicate `f`.

func Any

func Any(vs []string, f func(string) bool) bool

Any returns `true` if one of the strings in the slice satisfies the predicate `f`.

func AppendIfMissing

func AppendIfMissing(slice []string, i string) []string

func Check

func Check(e error)

Print error and exit if error occurred

func Checkf

func Checkf(e error, msg string)

func Filter

func Filter(vs []string, f func(string) bool) []string

Filter returns a new slice containing all strings in the slice that satisfy the predicate `f`.

func Include

func Include(vs []string, t string) bool

Include returns `true` if the target string t is in the slice.

func Index

func Index(vs []string, t string) int

Index returns the first index of the target string `t`, or -1 if no match is found.

func IsEmpty

func IsEmpty(value string) bool

func MakeConfig

func MakeConfig() (*types.Config, error)

Build the configuration from environment variable and validate that is consistent. If false, the program exit with validation message. The validation is not error safe but it limit misconfiguration ( lack of parameter ).

func Map

func Map(vs []string, f func(string) string) []string

Map returns a new slice containing the results of applying the function `f` to each string in the original slice.

func Middleware

func Middleware(next http.HandlerFunc) http.HandlerFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

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