@@ -79,17 +79,17 @@ func startFrontProxy(
7979 Path : "/services/" ,
8080 // TODO: support multiple virtual workspace backend servers
8181 Backend : fmt .Sprintf ("https://localhost:%s" , vwPort ),
82- BackendServerCA : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
83- ProxyClientCert : filepath .Join (workDirPath , ".kcp-front-proxy/ requestheader.crt" ),
84- ProxyClientKey : filepath .Join (workDirPath , ".kcp-front-proxy/ requestheader.key" ),
82+ BackendServerCA : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
83+ ProxyClientCert : filepath .Join (workDirPath , ".kcp-front-proxy" , " requestheader.crt" ),
84+ ProxyClientKey : filepath .Join (workDirPath , ".kcp-front-proxy" , " requestheader.key" ),
8585 },
8686 {
8787 Path : "/clusters/" ,
8888 // TODO: support multiple shard backend servers
8989 Backend : "https://localhost:6444" ,
90- BackendServerCA : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
91- ProxyClientCert : filepath .Join (workDirPath , ".kcp-front-proxy/ requestheader.crt" ),
92- ProxyClientKey : filepath .Join (workDirPath , ".kcp-front-proxy/ requestheader.key" ),
90+ BackendServerCA : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
91+ ProxyClientCert : filepath .Join (workDirPath , ".kcp-front-proxy" , " requestheader.crt" ),
92+ ProxyClientKey : filepath .Join (workDirPath , ".kcp-front-proxy" , " requestheader.key" ),
9393 },
9494 }
9595
@@ -98,13 +98,13 @@ func startFrontProxy(
9898 return fmt .Errorf ("error marshaling mappings yaml: %w" , err )
9999 }
100100
101- if err := os .WriteFile (filepath .Join (workDirPath , ".kcp-front-proxy/ mapping.yaml" ), mappingsYAML , 0644 ); err != nil {
101+ if err := os .WriteFile (filepath .Join (workDirPath , ".kcp-front-proxy" , " mapping.yaml" ), mappingsYAML , 0644 ); err != nil {
102102 return fmt .Errorf ("failed to create front-proxy mapping.yaml: %w" , err )
103103 }
104104
105105 // write root shard kubeconfig
106106 configLoader := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (
107- & clientcmd.ClientConfigLoadingRules {ExplicitPath : filepath .Join (workDirPath , ".kcp-0/ admin.kubeconfig" )},
107+ & clientcmd.ClientConfigLoadingRules {ExplicitPath : filepath .Join (workDirPath , ".kcp-0" , " admin.kubeconfig" )},
108108 & clientcmd.ConfigOverrides {CurrentContext : "shard-base" },
109109 )
110110 raw , err := configLoader .RawConfig ()
@@ -115,31 +115,31 @@ func startFrontProxy(
115115 if err := clientcmdapi .MinifyConfig (& raw ); err != nil {
116116 return err
117117 }
118- if err := clientcmd .WriteToFile (raw , filepath .Join (workDirPath , ".kcp/ root.kubeconfig" )); err != nil {
118+ if err := clientcmd .WriteToFile (raw , filepath .Join (workDirPath , ".kcp" , " root.kubeconfig" )); err != nil {
119119 return err
120120 }
121121
122122 // create serving cert
123- hostnames := sets .New [ string ] ("localhost" , hostIP )
123+ hostnames := sets .New ("localhost" , hostIP )
124124 logger .Info ("creating kcp-front-proxy serving cert with hostnames" , "hostnames" , hostnames )
125125 cert , err := servingCA .MakeServerCert (hostnames , 365 )
126126 if err != nil {
127127 return fmt .Errorf ("failed to create server cert: %w" , err )
128128 }
129- if err := cert .WriteCertConfigFile (filepath .Join (workDirPath , ".kcp-front-proxy/ apiserver.crt" ), filepath .Join (workDirPath , ".kcp-front-proxy/ apiserver.key" )); err != nil {
129+ if err := cert .WriteCertConfigFile (filepath .Join (workDirPath , ".kcp-front-proxy" , " apiserver.crt" ), filepath .Join (workDirPath , ".kcp-front-proxy" , " apiserver.key" )); err != nil {
130130 return fmt .Errorf ("failed to write server cert: %w" , err )
131131 }
132132
133133 // run front-proxy command
134134 commandLine := append (kcptestingserver .Command ("kcp-front-proxy" , "front-proxy" ),
135135 "--bind-address=" + hostIP ,
136- fmt .Sprintf ("--mapping-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy/ mapping.yaml" )),
136+ fmt .Sprintf ("--mapping-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy" , " mapping.yaml" )),
137137 fmt .Sprintf ("--root-directory=%s" , filepath .Join (workDirPath , ".kcp-front-proxy" )),
138- fmt .Sprintf ("--root-kubeconfig=%s" , filepath .Join (workDirPath , ".kcp/ root.kubeconfig" )),
139- fmt .Sprintf ("--shards-kubeconfig=%s" , filepath .Join (workDirPath , ".kcp-front-proxy/ shards.kubeconfig" )),
140- fmt .Sprintf ("--client-ca-file=%s" , filepath .Join (workDirPath , ".kcp/ client-ca.crt" )),
141- fmt .Sprintf ("--tls-cert-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy/ apiserver.crt" )),
142- fmt .Sprintf ("--tls-private-key-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy/ apiserver.key" )),
138+ fmt .Sprintf ("--root-kubeconfig=%s" , filepath .Join (workDirPath , ".kcp" , " root.kubeconfig" )),
139+ fmt .Sprintf ("--shards-kubeconfig=%s" , filepath .Join (workDirPath , ".kcp-front-proxy" , " shards.kubeconfig" )),
140+ fmt .Sprintf ("--client-ca-file=%s" , filepath .Join (workDirPath , ".kcp" , " client-ca.crt" )),
141+ fmt .Sprintf ("--tls-cert-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy" , " apiserver.crt" )),
142+ fmt .Sprintf ("--tls-private-key-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy" , " apiserver.key" )),
143143 "--secure-port=6443" ,
144144 "--v=4" ,
145145 )
@@ -148,7 +148,7 @@ func startFrontProxy(
148148
149149 cmd := exec .CommandContext (ctx , commandLine [0 ], commandLine [1 :]... ) //nolint:gosec
150150
151- logFilePath := filepath .Join (workDirPath , ".kcp-front-proxy/ proxy.log" )
151+ logFilePath := filepath .Join (workDirPath , ".kcp-front-proxy" , " proxy.log" )
152152 if logDirPath != "" {
153153 logFilePath = filepath .Join (logDirPath , "kcp-front-proxy.log" )
154154 }
@@ -204,7 +204,7 @@ func startFrontProxy(
204204 }
205205
206206 // intentionally load again every iteration because it can change
207- configLoader := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (& clientcmd.ClientConfigLoadingRules {ExplicitPath : filepath .Join (workDirPath , ".kcp/ admin.kubeconfig" )},
207+ configLoader := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (& clientcmd.ClientConfigLoadingRules {ExplicitPath : filepath .Join (workDirPath , ".kcp" , " admin.kubeconfig" )},
208208 & clientcmd.ConfigOverrides {CurrentContext : "base" },
209209 )
210210 config , err := configLoader .ClientConfig ()
@@ -249,7 +249,7 @@ func scrapeMetrics(ctx context.Context, cfg *rest.Config, workDir string) error
249249 if ! set || promUrl == "" {
250250 return nil
251251 }
252- return kcptestingserver .ScrapeMetrics (ctx , cfg , promUrl , workDir , "kcp-front-proxy" , filepath .Join (workDir , ".kcp-front-proxy/ apiserver.crt" ), map [string ]string {
252+ return kcptestingserver .ScrapeMetrics (ctx , cfg , promUrl , workDir , "kcp-front-proxy" , filepath .Join (workDir , ".kcp-front-proxy" , " apiserver.crt" ), map [string ]string {
253253 "server" : "kcp-front-proxy" ,
254254 })
255255}
@@ -260,18 +260,18 @@ func writeAdminKubeConfig(hostIP string, workDirPath string) error {
260260 var kubeConfig clientcmdapi.Config
261261 kubeConfig .AuthInfos = map [string ]* clientcmdapi.AuthInfo {
262262 "kcp-admin" : {
263- ClientKey : filepath .Join (workDirPath , ".kcp/ kcp-admin.key" ),
264- ClientCertificate : filepath .Join (workDirPath , ".kcp/ kcp-admin.crt" ),
263+ ClientKey : filepath .Join (workDirPath , ".kcp" , " kcp-admin.key" ),
264+ ClientCertificate : filepath .Join (workDirPath , ".kcp" , " kcp-admin.crt" ),
265265 },
266266 }
267267 kubeConfig .Clusters = map [string ]* clientcmdapi.Cluster {
268268 "root" : {
269269 Server : baseHost + "/clusters/root" ,
270- CertificateAuthority : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
270+ CertificateAuthority : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
271271 },
272272 "base" : {
273273 Server : baseHost ,
274- CertificateAuthority : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
274+ CertificateAuthority : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
275275 },
276276 }
277277 kubeConfig .Contexts = map [string ]* clientcmdapi.Context {
@@ -284,20 +284,20 @@ func writeAdminKubeConfig(hostIP string, workDirPath string) error {
284284 return err
285285 }
286286
287- return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp/ admin.kubeconfig" ))
287+ return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp" , " admin.kubeconfig" ))
288288}
289289
290290func writeShardKubeConfig (workDirPath string ) error {
291291 var kubeConfig clientcmdapi.Config
292292 kubeConfig .AuthInfos = map [string ]* clientcmdapi.AuthInfo {
293293 "shard-admin" : {
294- ClientKey : filepath .Join (workDirPath , ".kcp-front-proxy/ shard-admin.key" ),
295- ClientCertificate : filepath .Join (workDirPath , ".kcp-front-proxy/ shard-admin.crt" ),
294+ ClientKey : filepath .Join (workDirPath , ".kcp-front-proxy" , " shard-admin.key" ),
295+ ClientCertificate : filepath .Join (workDirPath , ".kcp-front-proxy" , " shard-admin.crt" ),
296296 },
297297 }
298298 kubeConfig .Clusters = map [string ]* clientcmdapi.Cluster {
299299 "base" : {
300- CertificateAuthority : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
300+ CertificateAuthority : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
301301 },
302302 }
303303 kubeConfig .Contexts = map [string ]* clientcmdapi.Context {
@@ -309,7 +309,7 @@ func writeShardKubeConfig(workDirPath string) error {
309309 return err
310310 }
311311
312- return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp-front-proxy/ shards.kubeconfig" ))
312+ return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp-front-proxy" , " shards.kubeconfig" ))
313313}
314314
315315func writeLogicalClusterAdminKubeConfig (hostIP , workDirPath string ) error {
@@ -321,14 +321,14 @@ func writeLogicalClusterAdminKubeConfig(hostIP, workDirPath string) error {
321321 var kubeConfig clientcmdapi.Config
322322 kubeConfig .AuthInfos = map [string ]* clientcmdapi.AuthInfo {
323323 "logical-cluster-admin" : {
324- ClientKey : filepath .Join (workDirPath , ".kcp/ logical-cluster-admin.key" ),
325- ClientCertificate : filepath .Join (workDirPath , ".kcp/ logical-cluster-admin.crt" ),
324+ ClientKey : filepath .Join (workDirPath , ".kcp" , " logical-cluster-admin.key" ),
325+ ClientCertificate : filepath .Join (workDirPath , ".kcp" , " logical-cluster-admin.crt" ),
326326 },
327327 }
328328 kubeConfig .Clusters = map [string ]* clientcmdapi.Cluster {
329329 "base" : {
330330 Server : baseHost ,
331- CertificateAuthority : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
331+ CertificateAuthority : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
332332 },
333333 }
334334 kubeConfig .Contexts = map [string ]* clientcmdapi.Context {
@@ -340,7 +340,7 @@ func writeLogicalClusterAdminKubeConfig(hostIP, workDirPath string) error {
340340 return err
341341 }
342342
343- return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp/ logical-cluster-admin.kubeconfig" ))
343+ return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp" , " logical-cluster-admin.kubeconfig" ))
344344}
345345
346346func writeExternalLogicalClusterAdminKubeConfig (hostIP , workDirPath string ) error {
@@ -350,14 +350,14 @@ func writeExternalLogicalClusterAdminKubeConfig(hostIP, workDirPath string) erro
350350 var kubeConfig clientcmdapi.Config
351351 kubeConfig .AuthInfos = map [string ]* clientcmdapi.AuthInfo {
352352 "external-logical-cluster-admin" : {
353- ClientKey : filepath .Join (workDirPath , ".kcp/ external-logical-cluster-admin.key" ),
354- ClientCertificate : filepath .Join (workDirPath , ".kcp/ external-logical-cluster-admin.crt" ),
353+ ClientKey : filepath .Join (workDirPath , ".kcp" , " external-logical-cluster-admin.key" ),
354+ ClientCertificate : filepath .Join (workDirPath , ".kcp" , " external-logical-cluster-admin.crt" ),
355355 },
356356 }
357357 kubeConfig .Clusters = map [string ]* clientcmdapi.Cluster {
358358 "base" : {
359359 Server : baseHost ,
360- CertificateAuthority : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
360+ CertificateAuthority : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
361361 },
362362 }
363363 kubeConfig .Contexts = map [string ]* clientcmdapi.Context {
@@ -369,5 +369,5 @@ func writeExternalLogicalClusterAdminKubeConfig(hostIP, workDirPath string) erro
369369 return err
370370 }
371371
372- return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp/ external-logical-cluster-admin.kubeconfig" ))
372+ return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp" , " external-logical-cluster-admin.kubeconfig" ))
373373}
0 commit comments