Skip to content

Commit 9c0f035

Browse files
committed
envtest: reject existing kcp configs that contain /clusters/ substring
On-behalf-of: SAP <[email protected]> Signed-off-by: Marvin Beckers <[email protected]>
1 parent 6b9707d commit 9c0f035

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

envtest/server.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,22 @@ type Environment struct {
124124

125125
// UseExistingCluster indicates that this environments should use an
126126
// existing kubeconfig, instead of trying to stand up a new kcp.
127+
// It defaults to the USE_EXISTING_KCP environment variable if unspecified.
127128
UseExistingKcp *bool
128129

129130
// KcpStartTimeout is the maximum duration each kcp component
130131
// may take to start. It defaults to the TEST_KCP_START_TIMEOUT
131-
// environment variable or 20 seconds if unspecified
132+
// environment variable or 20 seconds if unspecified.
132133
KcpStartTimeout time.Duration
133134

134135
// KcpStopTimeout is the maximum duration each kcp component
135136
// may take to stop. It defaults to the TEST_KCP_STOP_TIMEOUT
136-
// environment variable or 20 seconds if unspecified
137+
// environment variable or 20 seconds if unspecified.
137138
KcpStopTimeout time.Duration
138139

139140
// AttachKcpOutput indicates if kcp output will be attached to os.Stdout and os.Stderr.
140141
// Enable this to get more visibility of the testing kcp.
141-
// It respect TEST_ATTACH_KCP_OUTPUT environment variable.
142+
// It respects the the TEST_ATTACH_KCP_OUTPUT environment variable.
142143
AttachKcpOutput bool
143144
}
144145

@@ -167,6 +168,10 @@ func (te *Environment) Start() (*rest.Config, error) {
167168
if err != nil {
168169
return nil, fmt.Errorf("unable to get configuration for existing cluster: %w", err)
169170
}
171+
172+
if strings.Contains(te.Config.Host, "/clusters/") {
173+
return nil, fmt.Errorf("'%s' contains /clusters/ but should point to base context", te.Config.Host)
174+
}
170175
}
171176
} else {
172177
shard := te.Kcp.GetRootShard()

0 commit comments

Comments
 (0)