Skip to content

Commit ce4e4f5

Browse files
committed
some more deprecations
1 parent 56dcc14 commit ce4e4f5

File tree

6 files changed

+35
-29
lines changed

6 files changed

+35
-29
lines changed

tools/setup-envtest/README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
This is a small tool that manages binaries for envtest. It can be used to
44
download new binaries, list currently installed and available ones, and
5-
clean up versions. Binaries can be downloaded either via HTTP via an index
6-
or from GCS.
5+
clean up versions.
76

87
To use it, just go-install it on 1.19+ (it's a separate, self-contained
98
module):
@@ -50,7 +49,8 @@ setup-envtest use --index https://custom.com/envtest-releases.yaml
5049
# To download from the kubebuilder-tools GCS bucket: (default behavior before v0.18)
5150
# Note: This is a Google-owned bucket and it might be shutdown at any time
5251
# see: https://github.com/kubernetes/k8s.io/issues/2647#event-12439345373
53-
setup-envtest use --use-gcs
52+
# Note: This flag will also be removed soon.
53+
setup-envtest use --use-deprecated-gcs
5454
```
5555

5656
## Where does it put all those binaries?
@@ -119,7 +119,8 @@ Then, you have a few options for managing your binaries:
119119
https://raw.githubusercontent.com/kubernetes-sigs/controller-tools/master/envtest-releases.yaml
120120

121121
- If you want to talk to some internal source in a GCS "style", you can use the
122-
`--remote-bucket` and `--remote-server` options together with `--use-gcs`. The former sets which
122+
`--remote-bucket` and `--remote-server` options together with `--use-deprecated-gcs`.
123+
Note: This is deprecated and will be removed soon. The former sets which
123124
GCS bucket to download from, and the latter sets the host to talk to as
124125
if it were a GCS endpoint. Theoretically, you could use the latter
125126
version to run an internal "mirror" -- the tool expects

tools/setup-envtest/env/env.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
// envtest binaries.
2727
//
2828
// In general, the methods will use the Exit{,Cause} functions from this package
29-
// to indicate errors. Catch them with a `defer HandleExitWithCode()`.
29+
// to indicate errors. Catch them with a `defer HandleExitWithCode()`.
3030
type Env struct {
3131
// the following *must* be set on input
3232

@@ -35,18 +35,18 @@ type Env struct {
3535

3636
// VerifySum indicates whether we should run checksums.
3737
VerifySum bool
38-
// NoDownload forces us to not contact GCS or download the index via HTTP,
38+
// NoDownload forces us to not contact remote services,
3939
// looking only at local files instead.
4040
NoDownload bool
4141
// ForceDownload forces us to ignore local files and always
42-
// contact GCS or download the index via HTTP & re-download.
42+
// contact remote services & re-download.
4343
ForceDownload bool
4444

45-
// UseGCS signals if the GCS client is used.
46-
UseGCS bool
45+
// UseDeprecatedGCS signals if the GCS client is used.
46+
// Note: This will be removed together with remote.GCSClient.
47+
UseDeprecatedGCS bool
4748

48-
// Client is our remote client for contacting GCS or
49-
// to download the index via HTTP.
49+
// Client is our remote client for contacting remote services.
5050
Client remote.Client
5151

5252
// Log allows us to log.
@@ -291,7 +291,7 @@ func (e *Env) Fetch(ctx context.Context) {
291291
}
292292
})
293293

294-
archiveOut, err := e.FS.TempFile("", "*-"+e.Platform.ArchiveName(e.UseGCS, *e.Version.AsConcrete()))
294+
archiveOut, err := e.FS.TempFile("", "*-"+e.Platform.ArchiveName(e.UseDeprecatedGCS, *e.Version.AsConcrete()))
295295
if err != nil {
296296
ExitCause(2, err, "unable to open file to write downloaded archive to")
297297
}

tools/setup-envtest/main.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ var (
5050
binDir = flag.String("bin-dir", "",
5151
"directory to store binary assets (default: $OS_SPECIFIC_DATA_DIR/envtest-binaries)")
5252

53-
useGCS = flag.Bool("use-gcs", false, "use GCS to fetch envtest binaries")
53+
useDeprecatedGCS = flag.Bool("use-deprecated-gcs", false, "use GCS to fetch envtest binaries. Note: This is deprecated and will be removed soon. For more details see: https://github.com/kubernetes-sigs/controller-runtime/pull/2811")
5454

55-
// These flags are only used with --use-gcs.
56-
remoteBucket = flag.String("remote-bucket", "kubebuilder-tools", "remote GCS bucket to download from (only used with --use-gcs)")
55+
// These flags are only used with --use-deprecated-gcs.
56+
remoteBucket = flag.String("remote-bucket", "kubebuilder-tools", "remote GCS bucket to download from (only used with --use-deprecated-gcs)")
5757
remoteServer = flag.String("remote-server", "storage.googleapis.com",
5858
"remote server to query from. You can override this if you want to run "+
59-
"an internal storage server instead, or for testing. (only used with --use-gcs)")
59+
"an internal storage server instead, or for testing. (only used with --use-deprecated-gcs)")
6060

61-
// This flag is only used if --use-gcs is not set or false (default).
62-
index = flag.String("index", remote.DefaultIndexURL, "index to discover envtest binaries (only used if --use-gcs is not set, or set to false)")
61+
// This flag is only used if --use-deprecated-gcs is not set or false (default).
62+
index = flag.String("index", remote.DefaultIndexURL, "index to discover envtest binaries (only used if --use-deprecated-gcs is not set, or set to false)")
6363
)
6464

6565
// TODO(directxman12): handle interrupts?
@@ -89,28 +89,28 @@ func setupEnv(globalLog logr.Logger, version string) *envp.Env {
8989
log.V(1).Info("using binaries directory", "dir", *binDir)
9090

9191
var client remote.Client
92-
if useGCS != nil && *useGCS {
93-
client = &remote.GCSClient{
92+
if useDeprecatedGCS != nil && *useDeprecatedGCS {
93+
client = &remote.GCSClient{ //nolint:staticcheck // deprecation accepted for now
9494
Log: globalLog.WithName("storage-client"),
9595
Bucket: *remoteBucket,
9696
Server: *remoteServer,
9797
}
98-
log.V(1).Info("using GCS", "bucket", *remoteBucket, "server", *remoteServer)
98+
log.V(1).Info("using deprecated GCS client", "bucket", *remoteBucket, "server", *remoteServer)
9999
} else {
100100
client = &remote.HTTPClient{
101101
Log: globalLog.WithName("storage-client"),
102102
IndexURL: *index,
103103
}
104-
log.V(1).Info("using HTTP", "index", *index)
104+
log.V(1).Info("using HTTP client", "index", *index)
105105
}
106106

107107
env := &envp.Env{
108-
Log: globalLog,
109-
UseGCS: useGCS != nil && *useGCS,
110-
Client: client,
111-
VerifySum: *verify,
112-
ForceDownload: *force,
113-
NoDownload: *installedOnly,
108+
Log: globalLog,
109+
UseDeprecatedGCS: useDeprecatedGCS != nil && *useDeprecatedGCS,
110+
Client: client,
111+
VerifySum: *verify,
112+
ForceDownload: *force,
113+
NoDownload: *installedOnly,
114114
Platform: versions.PlatformItem{
115115
Platform: versions.Platform{
116116
OS: *targetOS,

tools/setup-envtest/remote/gcs_client.go

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ var _ Client = &GCSClient{}
3333

3434
// GCSClient is a basic client for fetching versions of the envtest binary archives
3535
// from GCS.
36+
//
37+
// Deprecated: This client is deprecated and will be removed soon.
38+
// The kubebuilder GCS bucket that we use with this client might be shutdown at any time,
39+
// see: https://github.com/kubernetes/k8s.io/issues/2647.
3640
type GCSClient struct {
3741
// Bucket is the bucket to fetch from.
3842
Bucket string

tools/setup-envtest/versions/platform.go

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func (p Platform) BaseName(ver Concrete) string {
3737
}
3838

3939
// ArchiveName returns the full archive name for this version and platform.
40+
// useGCS is deprecated and will be removed when the remote.GCSClient is removed.
4041
func (p Platform) ArchiveName(useGCS bool, ver Concrete) string {
4142
if useGCS {
4243
return "kubebuilder-tools-" + p.BaseName(ver) + ".tar.gz"

tools/setup-envtest/workflows/workflows_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func WorkflowTest(testMode string) {
7979
var client remote.Client
8080
switch testMode {
8181
case gcsMode:
82-
client = &remote.GCSClient{
82+
client = &remote.GCSClient{ //nolint:staticcheck // deprecation accepted for now
8383
Log: testLog.WithName("gcs-client"),
8484
Bucket: "kubebuilder-tools-test", // test custom bucket functionality too
8585
Server: server.Addr(),

0 commit comments

Comments
 (0)