Skip to content

Commit e1a570b

Browse files
committed
Expose some internal types/funcs in envtest
This exposes a few pieces of the new APIs in internal/testing as public in envtest. These types are effectively part of public APIs (they're referenced by public methods or fields of APIServer, ControlPlane, etc), so we should let users name them.
1 parent c0ca959 commit e1a570b

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

pkg/envtest/server.go

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,48 @@ const (
5959
defaultKubebuilderControlPlaneStopTimeout = 20 * time.Second
6060
)
6161

62-
// ControlPlane is the re-exported ControlPlane type from the internal testing package
63-
type ControlPlane = controlplane.ControlPlane
62+
// internal types we expose as part of our public API
63+
type (
64+
// ControlPlane is the re-exported ControlPlane type from the internal testing package
65+
ControlPlane = controlplane.ControlPlane
6466

65-
// APIServer is the re-exported APIServer type from the internal testing package
66-
type APIServer = controlplane.APIServer
67+
// APIServer is the re-exported APIServer from the internal testing package
68+
APIServer = controlplane.APIServer
6769

68-
// Etcd is the re-exported Etcd type from the internal testing package
69-
type Etcd = controlplane.Etcd
70+
// Etcd is the re-exported Etcd from the internal testing package
71+
Etcd = controlplane.Etcd
7072

71-
// User represents a Kubernetes user to provision for auth purposes.
72-
type User = controlplane.User
73+
// User represents a Kubernetes user to provision for auth purposes.
74+
User = controlplane.User
7375

74-
// AuthenticatedUser represets a Kubernetes user that's been provisioned.
75-
type AuthenticatedUser = controlplane.AuthenticatedUser
76+
// AuthenticatedUser represets a Kubernetes user that's been provisioned.
77+
AuthenticatedUser = controlplane.AuthenticatedUser
78+
79+
// ListenAddr indicates the address and port that the API server should listen on.
80+
ListenAddr = process.ListenAddr
81+
82+
// SecureServing contains details describing how the API server should serve
83+
// its secure endpoint.
84+
SecureServing = controlplane.SecureServing
85+
86+
// Authn is an authentication method that can be used with the control plane to
87+
// provision users.
88+
Authn = controlplane.Authn
89+
90+
// Arguments allows configuring a process's flags.
91+
Arguments = process.Arguments
92+
93+
// Arg is a single flag with one or more values.
94+
Arg = process.Arg
95+
)
96+
97+
var (
98+
// EmptyArguments constructs a new set of flags with nothing set.
99+
//
100+
// This is mostly useful for testing helper methods -- you'll want to call
101+
// Configure on the APIServer (or etcd) to configure their arguments.
102+
EmptyArguments = process.EmptyArguments
103+
)
76104

77105
// Environment creates a Kubernetes test environment that will start / stop the Kubernetes control plane and
78106
// install extension APIs

pkg/internal/testing/controlplane/apiserver.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
"sigs.k8s.io/controller-runtime/pkg/internal/testing/process"
1616
)
1717

18-
// TODO: listenaddr needs to be exposes publically so we can set insecureserving
19-
2018
const (
2119
// saKeyFile is the name of the service account signing private key file
2220
saKeyFile = "sa-signer.key"

0 commit comments

Comments
 (0)