Documentation
¶
Index ¶
- Variables
- func AdmitWorkspaceAccess(ctx context.Context, t *testing.T, ...)
- func ConfigWithToken(token string, cfg *rest.Config) *rest.Config
- func ExportVirtualWorkspaceURLs(export *apisv1alpha1.APIExport) []string
- func KcpCliPluginCommand() []string
- func Kubectl(t *testing.T, kubeconfigPath string, args ...string) []byte
- func KubectlApply(t *testing.T, kubeconfigPath string, input []byte) []byte
- func NewOrganizationFixture(t *testing.T, server frameworkserver.RunningServer, ...) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
- func NewPrivilegedOrganizationFixture[O WorkspaceOption](t *testing.T, server frameworkserver.RunningServer, options ...O) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
- func NewWorkspaceFixture(t *testing.T, server frameworkserver.RunningServer, parent logicalcluster.Path, ...) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
- func PrivateKcpServer(t *testing.T, options ...frameworkserver.Option) frameworkserver.RunningServer
- func RunKcpCliPlugin(t *testing.T, kubeconfigPath string, subcommand []string) []byte
- func SharedKcpServer(t *testing.T) frameworkserver.RunningServer
- func StaticTokenUserConfig(username string, cfg *rest.Config) *rest.Config
- func Suite(t *testing.T, suite string)
- func TestServerArgs() []string
- func TestServerArgsWithTokenAuthFile(tokenAuthFile string) []string
- func TestServerWithAuditPolicyFile(auditPolicyFile string) []string
- func UniqueGroup(suffix string) string
- func VirtualWorkspaceURL(ctx context.Context, kcpClusterClient kcpclientset.ClusterInterface, ...) (string, bool, error)
- func VirtualWorkspaceURLOrDie(t *testing.T, kcpClusterClient kcpclientset.ClusterInterface, ...) string
- func WorkspaceShard(ctx context.Context, kcpClient kcpclientset.ClusterInterface, ...) (*corev1alpha1.Shard, error)
- func WorkspaceShardOrDie(t *testing.T, kcpClient kcpclientset.ClusterInterface, ...) *corev1alpha1.Shard
- func WriteEmbedFile(t *testing.T, source string) string
- func WriteTokenAuthFile(t *testing.T) string
- type ArtifactFunc
- type PrivilegedWorkspaceOption
- type UnprivilegedWorkspaceOption
- func TODO_WithoutMultiShardSupport() UnprivilegedWorkspaceOption
- func WithLocation(w tenancyv1alpha1.WorkspaceLocation) UnprivilegedWorkspaceOption
- func WithName(s string, formatArgs ...interface{}) UnprivilegedWorkspaceOption
- func WithNameSuffix(suffix string) UnprivilegedWorkspaceOption
- func WithRootShard() UnprivilegedWorkspaceOption
- func WithShard(name string) UnprivilegedWorkspaceOption
- func WithType(path logicalcluster.Path, name tenancyv1alpha1.WorkspaceTypeName) UnprivilegedWorkspaceOption
- type WorkspaceOption
Constants ¶
This section is empty.
Variables ¶
var TestConfig *testConfig
Functions ¶
func AdmitWorkspaceAccess ¶ added in v0.6.0
func AdmitWorkspaceAccess(ctx context.Context, t *testing.T, kubeClusterClient kcpkubernetesclientset.ClusterInterface, clusterName logicalcluster.Path, users []string, groups []string, admin bool)
AdmitWorkspaceAccess create RBAC rules that allow the given users and/or groups to access the given workspace, optionally as admin.
func ConfigWithToken ¶ added in v0.6.0
func ExportVirtualWorkspaceURLs ¶ added in v0.11.0
func ExportVirtualWorkspaceURLs(export *apisv1alpha1.APIExport) []string
func KcpCliPluginCommand ¶ added in v0.6.0
func KcpCliPluginCommand() []string
KcpCliPluginCommand returns the cli args to run the workspace plugin directly or via go run (depending on whether NO_GORUN is set).
func Kubectl ¶ added in v0.6.0
Kubectl runs kubectl with the given arguments and returns the combined stderr and stdout.
func KubectlApply ¶ added in v0.6.0
KubectlApply runs kubectl apply -f with the supplied input piped to stdin and returns the combined stderr and stdout output.
func NewOrganizationFixture ¶ added in v0.6.0
func NewOrganizationFixture(t *testing.T, server frameworkserver.RunningServer, options ...UnprivilegedWorkspaceOption) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
func NewPrivilegedOrganizationFixture ¶ added in v0.11.0
func NewPrivilegedOrganizationFixture[O WorkspaceOption](t *testing.T, server frameworkserver.RunningServer, options ...O) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
func NewWorkspaceFixture ¶ added in v0.6.0
func NewWorkspaceFixture(t *testing.T, server frameworkserver.RunningServer, parent logicalcluster.Path, options ...UnprivilegedWorkspaceOption) (logicalcluster.Path, *tenancyv1alpha1.Workspace)
func PrivateKcpServer ¶ added in v0.6.0
func PrivateKcpServer(t *testing.T, options ...frameworkserver.Option) frameworkserver.RunningServer
PrivateKcpServer returns a new kcp server fixture managing a new server process that is not intended to be shared between tests.
func RunKcpCliPlugin ¶ added in v0.6.0
RunKcpCliPlugin runs the kcp workspace plugin with the provided subcommand and returns the combined stderr and stdout output.
func SharedKcpServer ¶ added in v0.6.0
func SharedKcpServer(t *testing.T) frameworkserver.RunningServer
SharedKcpServer returns a kcp server fixture intended to be shared between tests. A persistent server will be configured if `--kcp-kubeconfig` or `--use-default-kcp-server` is supplied to the test runner. Otherwise a test-managed server will be started. Only tests that are known to be hermetic are compatible with shared fixture.
func StaticTokenUserConfig ¶ added in v0.11.0
StaticTokenUserConfig returns a user config based on static user tokens defined in "test/e2e/framework/auth-tokens.csv". The token being used is "[username]-token".
func Suite ¶ added in v0.10.0
Suite should be called at the very beginning of a test case, to ensure that a test is only run when the suite containing it is selected by the user running tests.
func TestServerArgs ¶ added in v0.6.0
func TestServerArgs() []string
TestServerArgs returns the set of kcp args used to start a test server using the token auth file from the working tree.
func TestServerArgsWithTokenAuthFile ¶ added in v0.6.0
TestServerArgsWithTokenAuthFile returns the set of kcp args used to start a test server with the given token auth file.
func TestServerWithAuditPolicyFile ¶ added in v0.9.0
TestServerWithAuditPolicyFile returns the set of kcp args used to start a test server with the given audit policy file.
func UniqueGroup ¶ added in v0.7.0
UniqueGroup returns a unique API group with the given suffix by prefixing some random 8 character base36 string. suffix must start with a dot if the random string should be dot-separated.
func VirtualWorkspaceURL ¶ added in v0.11.0
func VirtualWorkspaceURL(ctx context.Context, kcpClusterClient kcpclientset.ClusterInterface, ws *tenancyv1alpha1.Workspace, urls []string) (string, bool, error)
func VirtualWorkspaceURLOrDie ¶ added in v0.11.0
func VirtualWorkspaceURLOrDie(t *testing.T, kcpClusterClient kcpclientset.ClusterInterface, ws *tenancyv1alpha1.Workspace, urls []string) string
func WorkspaceShard ¶ added in v0.11.0
func WorkspaceShard(ctx context.Context, kcpClient kcpclientset.ClusterInterface, ws *tenancyv1alpha1.Workspace) (*corev1alpha1.Shard, error)
func WorkspaceShardOrDie ¶ added in v0.11.0
func WorkspaceShardOrDie(t *testing.T, kcpClient kcpclientset.ClusterInterface, ws *tenancyv1alpha1.Workspace) *corev1alpha1.Shard
func WriteTokenAuthFile ¶ added in v0.6.0
WriteTokenAuthFile writes the embedded token file to the current test's data dir.
Persistent servers can target the file in the source tree with `--token-auth-file` and test-managed servers can target a file written to a temp path. This avoids requiring a test to know the location of the token file.
TODO(marun) Is there a way to avoid embedding by determining the path to the file during test execution?
Types ¶
type ArtifactFunc ¶ added in v0.6.0
type PrivilegedWorkspaceOption ¶ added in v0.11.0
type PrivilegedWorkspaceOption func(ws *tenancyv1alpha1.Workspace)
func WithRequiredGroups ¶ added in v0.11.0
func WithRequiredGroups(groups ...string) PrivilegedWorkspaceOption
WithRequiredGroups is a privileged action, so we return a privileged option type, and only the helpers that use the system:master config can consume this. However, workspace initialization requires a valid user annotation on the workspace object to impersonate during initialization, and system:master bypasses setting that, so we end up needing to hard-code something conceivable.
type UnprivilegedWorkspaceOption ¶ added in v0.11.0
type UnprivilegedWorkspaceOption func(ws *tenancyv1alpha1.Workspace)
func TODO_WithoutMultiShardSupport ¶ added in v0.11.0
func TODO_WithoutMultiShardSupport() UnprivilegedWorkspaceOption
func WithLocation ¶ added in v0.11.0
func WithLocation(w tenancyv1alpha1.WorkspaceLocation) UnprivilegedWorkspaceOption
func WithName ¶ added in v0.6.0
func WithName(s string, formatArgs ...interface{}) UnprivilegedWorkspaceOption
func WithNameSuffix ¶ added in v0.11.0
func WithNameSuffix(suffix string) UnprivilegedWorkspaceOption
func WithRootShard ¶ added in v0.11.0
func WithRootShard() UnprivilegedWorkspaceOption
func WithShard ¶ added in v0.11.0
func WithShard(name string) UnprivilegedWorkspaceOption
func WithType ¶ added in v0.6.0
func WithType(path logicalcluster.Path, name tenancyv1alpha1.WorkspaceTypeName) UnprivilegedWorkspaceOption
type WorkspaceOption ¶ added in v0.11.0
type WorkspaceOption interface {
PrivilegedWorkspaceOption | UnprivilegedWorkspaceOption
}