ospreytest

package
v2.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCustomNamespaceToContexts

func AddCustomNamespaceToContexts(namespaceSuffix, kubeconfig string, targetedOspreys []*TestOsprey) error

AddCustomNamespaceToContexts adds a namespace to each context in the kubeconfig file the name of the namespace will be

func Client

func Client(args ...string) clitest.TestCommand

Client returns a TestCommand for the osprey binary with the provided args arguments.

func Login

func Login(args ...string) clitest.LoginCommand

Login returns a LoginCommand for the osprey binary with the provided args arguments.

func OspreyTargetOutput

func OspreyTargetOutput(environment string) string

OspreyTargetOutput returns the name and aliases output format for the environment.

func OspreyconfigAliasName

func OspreyconfigAliasName(environment string) string

OspreyconfigAliasName returns the ospreyconfig target's alias for the environment.

func OspreyconfigTargetName

func OspreyconfigTargetName(environment string) string

OspreyconfigTargetName returns the ospreyconfig target's name for the environment.

func SaveConfig added in v2.12.0

func SaveConfig(config interface{}, path string) error

SaveConfig writes the osprey config to the specified path.

func Stop

func Stop(server *TestOsprey) error

Stop stops the TestOsprey server. Returns an error if any happened.

func WithoutToken

func WithoutToken(authInfo *clientgo.AuthInfo) *clientgo.AuthInfo

WithoutToken creates a DeepCopy() of authInfo without an id-token.

Types

type TestConfig

type TestConfig struct {
	*client.Config
	LegacyConfig     *client.ConfigV1
	ConfigFile       string
	LegacyConfigFile string
}

TestConfig represents an Osprey client configuration file used for testing.

func BuildCADataConfig

func BuildCADataConfig(testDir, providerName string, servers []*TestOsprey,
	caData bool, caPath, clientID, apiServerURL string, useGKEClientConfig bool) (*TestConfig, error)

BuildCADataConfig creates an ospreyconfig file with as many targets as servers are provided. It uses testDir as the home for the .kube and .osprey folders. It also base64 encodes the CA data instead of using the file path.

func BuildConfig

func BuildConfig(testDir, providerName, defaultGroup string, targetGroups map[string][]string,
	servers []*TestOsprey, clientID, apiServerURL string, useGKEClientConfig bool) (*TestConfig, error)

BuildConfig creates an ospreyconfig file using the groups provided for the targets. It uses testDir as the home for the .kube and .osprey folders.

func BuildFullConfig

func BuildFullConfig(testDir, providerName, defaultGroup string,
	targetGroups map[string][]string, servers []*TestOsprey,
	caData bool, caPath, clientID, apiServerURL string, useGKEClientConfig bool) (*TestConfig, error)

BuildFullConfig creates an ospreyconfig file with as many targets as servers are provided. The targets will contain the groups that have been specified. It uses testDir as the home for the .kube and .osprey folders. If caData is true, it base64 encodes the CA data instead of using the file path.

type TestOsprey

type TestOsprey struct {
	clitest.AsyncTestCommand
	Port         int32
	Environment  string
	APIServerURL string
	APIServerCA  string
	Secret       string
	URL          string
	IssuerURL    string
	IssuerPath   string
	IssuerCA     string
	KeyFile      string
	CertFile     string
	TestDir      string
}

TestOsprey represents an Osprey server instance used for testing.

func GetOspreysByGroup

func GetOspreysByGroup(group, defaultGroup string, environmentGroups map[string][]string, ospreys []*TestOsprey) []*TestOsprey

GetOspreysByGroup returns the ospreys matching by group or default group given the environmentGroups definition.

func Start

func Start(testDir string, useTLS bool, port int32, dex *dextest.TestDex) *TestOsprey

Start creates one Osprey test server for the dex Server. Its directory will be testDir/dex.Environment

func StartOspreys

func StartOspreys(testDir string, dexes []*dextest.TestDex, portsFrom int32) ([]*TestOsprey, error)

StartOspreys creates one Osprey test server per TestDex provided, using ports starting from portsFrom. The Osprey directory will be testDir/dex.Environment.

func (*TestOsprey) CallHealthcheck

func (o *TestOsprey) CallHealthcheck() (*http.Response, error)

CallHealthcheck returns the current status of osprey's healthcheck as an http response and error

func (*TestOsprey) CustomAliasNamespace

func (o *TestOsprey) CustomAliasNamespace(suffix string) string

CustomAliasNamespace returns the name for a namespace appending the suffix to the osprey's alias name.

func (*TestOsprey) CustomTargetNamespace

func (o *TestOsprey) CustomTargetNamespace(suffix string) string

CustomTargetNamespace returns the name for a namespace appending the suffix to the osprey's target name.

func (*TestOsprey) OspreyconfigAliasName

func (o *TestOsprey) OspreyconfigAliasName() string

OspreyconfigAliasName returns the ospreyconfig target's alias for the TestOsprey instance.

func (*TestOsprey) OspreyconfigTargetName

func (o *TestOsprey) OspreyconfigTargetName() string

OspreyconfigTargetName returns the ospreyconfig target's name for the TestOsprey instance.

func (*TestOsprey) ToGroupClaims

func (o *TestOsprey) ToGroupClaims(authInfo *clientgo.AuthInfo) ([]string, error)

ToGroupClaims returns the groups contained in the groups claim of the id-token for the authInfo. If no tokens exists it returns an empty slice.

func (*TestOsprey) ToKubeconfigCluster

func (o *TestOsprey) ToKubeconfigCluster(locationOfOrigin string) *clientgo.Cluster

ToKubeconfigCluster returns a *Cluster representation of the TestOsprey instance.

func (*TestOsprey) ToKubeconfigContext

func (o *TestOsprey) ToKubeconfigContext(locationOfOrigin string) *clientgo.Context

ToKubeconfigContext returns a *Context representation of the TestOsprey instance.

func (*TestOsprey) ToKubeconfigUserWithoutToken

func (o *TestOsprey) ToKubeconfigUserWithoutToken(locationOfOrigin string) *clientgo.AuthInfo

ToKubeconfigUserWithoutToken returns an *AuthInfo representation, with an empty id-token, of the TestOsprey instance.

Jump to

Keyboard shortcuts

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