common

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package common holds code needed by multiple commands.

Index

Constants

View Source
const (
	// ACLReplicationTokenName is the name used for the ACL replication policy and
	// Kubernetes secret. It is consumed in both the server-acl-init and
	// create-federation-secret commands and so lives in this common package.
	ACLReplicationTokenName = "acl-replication"

	// ACLTokenSecretKey is the key that we store the ACL tokens in when we
	// create Kubernetes secrets.
	ACLTokenSecretKey = "token"
)

Variables

This section is empty.

Functions

func ConsulLogin added in v0.26.0

func ConsulLogin(client *api.Client, bearerTokenFile, authMethodName, tokenSinkFile, namespace string, meta map[string]string) error

ConsulLogin issues an ACL().Login to Consul and writes out the token to tokenSinkFile. The logic of this is taken from the `consul login` command.

func GenerateServerCerts

func GenerateServerCerts(t *testing.T) (string, string, string)

GenerateServerCerts generates Consul CA and a server certificate and saves them to temp files. It returns file names in this order: CA certificate, server certificate, and server key.

func Logger added in v0.21.0

func Logger(level string) (hclog.Logger, error)

Logger returns an hclog instance or an error if level is invalid.

func ValidateUnprivilegedPort added in v0.25.0

func ValidateUnprivilegedPort(flagName, flagValue string) error

ValidateUnprivilegedPort converts flags representing ports into integer and validates that it's in the unprivileged port range.

func WriteFileWithPerms added in v0.26.0

func WriteFileWithPerms(outputFile, payload string, mode os.FileMode) error

WriteFileWithPerms will write payload as the contents of the outputFile and set permissions after writing the contents. This function is necessary since using ioutil.WriteFile() alone will create the new file with the requested permissions prior to actually writing the file, so you can't set read-only permissions.

func WriteTempFile added in v0.26.0

func WriteTempFile(t *testing.T, contents string) string

WriteTempFile writes contents to a temporary file and returns the file name. It will remove the file once the test completes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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