env

package
v0.6.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FailHeader = "x-istio-backend-fail"
	FailBody   = "Bad request from backend."
)

If HTTP header has non empty FailHeader, HTTP server will fail the request with 400 with FailBody in the response body.

Variables

View Source
var (
	// TARGET_OUT environment variable
	// nolint: revive, stylecheck
	TARGET_OUT Variable = "TARGET_OUT"

	// LOCAL_OUT environment variable
	// nolint: revive, stylecheck
	LOCAL_OUT Variable = "LOCAL_OUT"

	// REPO_ROOT environment variable
	// nolint: revive, stylecheck
	REPO_ROOT Variable = "REPO_ROOT"

	// HUB is the Docker hub to be used for images.
	// nolint: revive, stylecheck
	HUB Variable = "HUB"

	// TAG is the Docker tag to be used for images.
	// nolint: revive, stylecheck
	TAG Variable = "TAG"

	// PULL_POLICY is the image pull policy to use when rendering templates.
	// nolint: revive, stylecheck
	PULL_POLICY Variable = "PULL_POLICY"

	// KUBECONFIG is the list of Kubernetes configuration files. If configuration files are specified on
	// the command-line, that takes precedence.
	// nolint: revive, stylecheck
	KUBECONFIG Variable = "KUBECONFIG"

	// IstioSrc is the location of istio source ($TOP/src/istio.io/istio
	IstioSrc = REPO_ROOT.ValueOrDefaultFunc(getDefaultIstioSrc)

	// IstioOut is the location of the output directory ($TOP/out)
	IstioOut = verifyFile(TARGET_OUT, TARGET_OUT.ValueOrDefaultFunc(getDefaultIstioOut))

	// LocalOut is the location of the output directory for the OS we are running in,
	// not necessarily the OS we are building for
	LocalOut = verifyFile(LOCAL_OUT, LOCAL_OUT.ValueOrDefaultFunc(getDefaultIstioOut))

	// OtelCollectorInstallFilePath is the OpenTelemetry installation file.
	OtelCollectorInstallFilePath = path.Join(IstioSrc, getInstallationFile("opentelemetry/opentelemetry-collector.yaml"))

	// StackdriverInstallFilePath is the stackdriver installation file.
	StackdriverInstallFilePath = path.Join(IstioSrc, getInstallationFile("stackdriver/stackdriver.yaml"))

	// GCEMetadataServerInstallFilePath is the GCE Metadata Server installation file.
	GCEMetadataServerInstallFilePath = path.Join(IstioSrc, getInstallationFile("gcemetadata/gce_metadata_server.yaml"))

	// ContainerRegistryServerInstallFilePath is the fake container registry installation file.
	ContainerRegistryServerInstallFilePath = path.Join(IstioSrc, getInstallationFile("containerregistry/container_registry_server.yaml"))
)
View Source
var (

	// Root folder of this project
	// This relies on the fact this file is 3 levels up from the root; if this changes, adjust the path below
	Root = filepath.Join(filepath.Dir(b), "../../..")
)

Functions

func CheckFileExists

func CheckFileExists(path string) error

func HTTPGet

func HTTPGet(url string) (code int, respBody string, err error)

HTTPGet send GET

func IsPortUsed

func IsPortUsed(port uint16) bool

IsPortUsed checks if a port is used

func ReadProxySHA

func ReadProxySHA() (string, error)

func WaitForHTTPServer

func WaitForHTTPServer(url string) error

WaitForHTTPServer waits for a HTTP server

func WaitForPort

func WaitForPort(port uint16)

WaitForPort waits for a TCP port

Types

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

HTTPServer stores data for a HTTP server.

func NewHTTPServer

func NewHTTPServer(port uint16) (*HTTPServer, error)

NewHTTPServer creates a new HTTP server.

func (*HTTPServer) LastRequestHeaders

func (s *HTTPServer) LastRequestHeaders() http.Header

LastRequestHeaders returns the headers from the last request and clears the value

func (*HTTPServer) Start

func (s *HTTPServer) Start() <-chan error

Start starts the server

func (*HTTPServer) Stop

func (s *HTTPServer) Stop()

Stop shutdown the server

type Variable

type Variable string

Variable is a wrapper for an environment variable.

func (Variable) Name

func (e Variable) Name() string

Name of the environment variable.

func (Variable) Value

func (e Variable) Value() string

Value of the environment variable.

func (Variable) ValueOrDefault

func (e Variable) ValueOrDefault(defaultValue string) string

ValueOrDefault returns the value of the environment variable if it is non-empty. Otherwise returns the value provided.

func (Variable) ValueOrDefaultFunc

func (e Variable) ValueOrDefaultFunc(defaultValueFunc func() string) string

ValueOrDefaultFunc returns the value of the environment variable if it is non-empty. Otherwise returns the value function provided.

Jump to

Keyboard shortcuts

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