Skip to content

Commit e6c3d13

Browse files
authored
Merge pull request kubernetes-sigs#2915 from sbueringer/pr-setup-envtest-drop-gcs
🌱 setup-envtest: drop support for GCS
2 parents b901db1 + 3a474bf commit e6c3d13

File tree

12 files changed

+346
-822
lines changed

12 files changed

+346
-822
lines changed

tools/setup-envtest/README.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ setup-envtest sideload 1.16.2 < downloaded-envtest.tar.gz
5252
# To download from a custom index use the following:
5353
setup-envtest use --index https://custom.com/envtest-releases.yaml
5454

55-
# To download from the kubebuilder-tools GCS bucket: (default behavior before v0.18)
56-
# Note: This is a Google-owned bucket and it might be shutdown at any time
57-
# see: https://github.com/kubernetes/k8s.io/issues/2647#event-12439345373
58-
# Note: This flag will also be removed soon.
59-
setup-envtest use --use-deprecated-gcs
6055
```
6156

6257
## Where does it put all those binaries?
@@ -107,8 +102,7 @@ Then, you have a few options for managing your binaries:
107102

108103
`--use-env` makes the command unconditionally use the value of
109104
KUBEBUILDER_ASSETS as long as it contains the required binaries, and
110-
`-i` indicates that we only ever want to work with installed binaries
111-
(no reaching out the remote GCS storage).
105+
`-i` indicates that we only ever want to work with installed binaries.
112106

113107
As noted about, you can use `ENVTEST_INSTALLED_ONLY=true` to switch `-i`
114108
on by default, and you can use `ENVTEST_USE_ENV=true` to switch
@@ -123,25 +117,3 @@ Then, you have a few options for managing your binaries:
123117
- If you want to talk to some internal source via HTTP, you can simply set `--index`
124118
The index must contain references to envtest binary archives in the same format as:
125119
https://raw.githubusercontent.com/kubernetes-sigs/controller-tools/master/envtest-releases.yaml
126-
127-
- If you want to talk to some internal source in a GCS "style", you can use the
128-
`--remote-bucket` and `--remote-server` options together with `--use-deprecated-gcs`.
129-
Note: This is deprecated and will be removed soon. The former sets which
130-
GCS bucket to download from, and the latter sets the host to talk to as
131-
if it were a GCS endpoint. Theoretically, you could use the latter
132-
version to run an internal "mirror" -- the tool expects
133-
134-
- `HOST/storage/v1/b/BUCKET/o` to return JSON like
135-
136-
```json
137-
{"items": [
138-
{"name": "kubebuilder-tools-X.Y.Z-os-arch.tar.gz", "md5Hash": "<base-64-encoded-md5-hash>"},
139-
{"name": "kubebuilder-tools-X.Y.Z-os-arch.tar.gz", "md5Hash": "<base-64-encoded-md5-hash>"}
140-
]}
141-
```
142-
143-
- `HOST/storage/v1/b/BUCKET/o/TARBALL_NAME` to return JSON like
144-
`{"name": "kubebuilder-tools-X.Y.Z-os-arch.tar.gz", "md5Hash": "<base-64-encoded-md5-hash>"}`
145-
146-
- `HOST/storage/v1/b/BUCKET/o/TARBALL_NAME?alt=media` to return the
147-
actual file contents

tools/setup-envtest/env/env.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ type Env struct {
4242
// contact remote services & re-download.
4343
ForceDownload bool
4444

45-
// UseDeprecatedGCS signals if the GCS client is used.
46-
// Note: This will be removed together with remote.GCSClient.
47-
UseDeprecatedGCS bool
48-
4945
// Client is our remote client for contacting remote services.
5046
Client remote.Client
5147

@@ -291,7 +287,7 @@ func (e *Env) Fetch(ctx context.Context) {
291287
}
292288
})
293289

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

tools/setup-envtest/main.go

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

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")
54-
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)")
57-
remoteServer = flag.String("remote-server", "storage.googleapis.com",
58-
"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-deprecated-gcs)")
60-
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)")
53+
index = flag.String("index", remote.DefaultIndexURL, "index to discover envtest binaries")
6354
)
6455

6556
// TODO(directxman12): handle interrupts?
@@ -88,29 +79,18 @@ func setupEnv(globalLog logr.Logger, version string) *envp.Env {
8879
}
8980
log.V(1).Info("using binaries directory", "dir", *binDir)
9081

91-
var client remote.Client
92-
if useDeprecatedGCS != nil && *useDeprecatedGCS {
93-
client = &remote.GCSClient{ //nolint:staticcheck // deprecation accepted for now
94-
Log: globalLog.WithName("storage-client"),
95-
Bucket: *remoteBucket,
96-
Server: *remoteServer,
97-
}
98-
log.V(1).Info("using deprecated GCS client", "bucket", *remoteBucket, "server", *remoteServer)
99-
} else {
100-
client = &remote.HTTPClient{
101-
Log: globalLog.WithName("storage-client"),
102-
IndexURL: *index,
103-
}
104-
log.V(1).Info("using HTTP client", "index", *index)
82+
client := &remote.HTTPClient{
83+
Log: globalLog.WithName("storage-client"),
84+
IndexURL: *index,
10585
}
86+
log.V(1).Info("using HTTP client", "index", *index)
10687

10788
env := &envp.Env{
108-
Log: globalLog,
109-
UseDeprecatedGCS: useDeprecatedGCS != nil && *useDeprecatedGCS,
110-
Client: client,
111-
VerifySum: *verify,
112-
ForceDownload: *force,
113-
NoDownload: *installedOnly,
89+
Log: globalLog,
90+
Client: client,
91+
VerifySum: *verify,
92+
ForceDownload: *force,
93+
NoDownload: *installedOnly,
11494
Platform: versions.PlatformItem{
11595
Platform: versions.Platform{
11696
OS: *targetOS,
@@ -189,7 +169,7 @@ Commands:
189169
190170
use:
191171
get information for the requested version, downloading it if necessary and allowed.
192-
Needs a concrete platform (no wildcards), but wilcard versions are supported.
172+
Needs a concrete platform (no wildcards), but wildcard versions are supported.
193173
194174
list:
195175
list installed *and* available versions matching the given version & platform.

tools/setup-envtest/remote/gcs_client.go

Lines changed: 0 additions & 202 deletions
This file was deleted.

tools/setup-envtest/store/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (i Item) String() string {
3838
}
3939

4040
// Filter is a version spec & platform selector (i.e. platform
41-
// potentially with wilcards) to filter store items.
41+
// potentially with wildcards) to filter store items.
4242
type Filter struct {
4343
Version versions.Spec
4444
Platform versions.Platform

tools/setup-envtest/store/store_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,36 +125,6 @@ var _ = Describe("Store", func() {
125125
})
126126
})
127127

128-
Describe("adding items (GCS archives)", func() {
129-
archiveName := "kubebuilder-tools-1.16.3-linux-amd64.tar.gz"
130-
131-
It("should support .tar.gz input", func() {
132-
Expect(st.Add(logCtx(), newItem, makeFakeArchive(archiveName, "kubebuilder/bin/"))).To(Succeed())
133-
Expect(st.Has(newItem)).To(BeTrue(), "should have the item after adding it")
134-
})
135-
136-
It("should extract binaries from the given archive to a directly to the item's directory, regardless of path", func() {
137-
Expect(st.Add(logCtx(), newItem, makeFakeArchive(archiveName, "kubebuilder/bin/"))).To(Succeed())
138-
139-
dirName := newItem.Platform.BaseName(newItem.Version)
140-
Expect(afero.ReadFile(st.Root, filepath.Join("k8s", dirName, "some-file"))).To(HavePrefix(archiveName + "some-file"))
141-
Expect(afero.ReadFile(st.Root, filepath.Join("k8s", dirName, "other-file"))).To(HavePrefix(archiveName + "other-file"))
142-
})
143-
144-
It("should clean up any existing item directory before creating the new one", func() {
145-
item := localVersions[0]
146-
Expect(st.Add(logCtx(), item, makeFakeArchive(archiveName, "kubebuilder/bin/"))).To(Succeed())
147-
Expect(st.Root.Stat(filepath.Join("k8s", item.Platform.BaseName(item.Version)))).NotTo(BeNil(), "new files should exist")
148-
})
149-
It("should clean up if it errors before finishing", func() {
150-
item := localVersions[0]
151-
Expect(st.Add(logCtx(), item, new(bytes.Buffer))).NotTo(Succeed(), "should fail to extract")
152-
_, err := st.Root.Stat(filepath.Join("k8s", item.Platform.BaseName(item.Version)))
153-
Expect(err).To(HaveOccurred(), "the binaries dir for the item should be gone")
154-
155-
})
156-
})
157-
158128
Describe("adding items (controller-tools archives)", func() {
159129
archiveName := "envtest-v1.16.3-linux-amd64.tar.gz"
160130

0 commit comments

Comments
 (0)