Skip to content

Commit c7b22a6

Browse files
authored
Merge pull request #4378 from fabriziopandini/remove-gobindata
🌱Remove go-bindata
2 parents 77093e2 + 3d3dd08 commit c7b22a6

File tree

9 files changed

+77
-601
lines changed

9 files changed

+77
-601
lines changed

Makefile

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/golangci-lint)
6969
CONVERSION_GEN := $(abspath $(TOOLS_BIN_DIR)/conversion-gen)
7070
ENVSUBST := $(abspath $(TOOLS_BIN_DIR)/envsubst)
7171

72-
# Bindata.
73-
GOBINDATA := $(abspath $(TOOLS_BIN_DIR)/go-bindata)
74-
GOBINDATA_CLUSTERCTL_DIR := cmd/clusterctl/config
72+
# clusterctl.
73+
CLUSTERCTL_MANIFEST_DIR := cmd/clusterctl/config
7574

7675
# Define Docker related variables. Releases should modify and double check these vars.
7776
REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
@@ -188,9 +187,6 @@ $(GOTESTSUM): $(TOOLS_DIR)/go.mod # Build gotestsum from tools folder.
188187
$(CONVERSION_GEN): $(TOOLS_DIR)/go.mod
189188
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-gen k8s.io/code-generator/cmd/conversion-gen
190189

191-
$(GOBINDATA): $(TOOLS_DIR)/go.mod # Build go-bindata from tools folder.
192-
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/go-bindata github.com/go-bindata/go-bindata/go-bindata
193-
194190
$(RELEASE_NOTES): $(TOOLS_DIR)/go.mod
195191
cd $(TOOLS_DIR) && go build -tags=tools -o $(RELEASE_NOTES_BIN) ./release
196192

@@ -245,7 +241,7 @@ ALL_GENERATE_MODULES = core cabpk kcp
245241

246242
.PHONY: generate
247243
generate: ## Generate code
248-
$(MAKE) generate-manifests generate-go generate-bindata
244+
$(MAKE) generate-manifests generate-go
249245
$(MAKE) -C test/infrastructure/docker generate
250246

251247
.PHONY: generate-go
@@ -314,7 +310,7 @@ generate-go-conversions-kcp: $(CONVERSION_GEN)
314310
generate-manifests: $(addprefix generate-manifests-,$(ALL_GENERATE_MODULES)) ## Generate manifests e.g. CRD, RBAC etc.
315311

316312
.PHONY: generate-manifests-core
317-
generate-manifests-core: $(CONTROLLER_GEN)
313+
generate-manifests-core: $(CONTROLLER_GEN) $(KUSTOMIZE)
318314
$(CONTROLLER_GEN) \
319315
paths=./api/... \
320316
paths=./controllers/... \
@@ -331,6 +327,7 @@ generate-manifests-core: $(CONTROLLER_GEN)
331327
paths=./cmd/clusterctl/api/... \
332328
crd:crdVersions=v1 \
333329
output:crd:dir=./cmd/clusterctl/config/crd/bases
330+
$(KUSTOMIZE) build $(CLUSTERCTL_MANIFEST_DIR)/crd > $(CLUSTERCTL_MANIFEST_DIR)/manifest/clusterctl-api.yaml
334331

335332
.PHONY: generate-manifests-cabpk
336333
generate-manifests-cabpk: $(CONTROLLER_GEN)
@@ -356,26 +353,6 @@ generate-manifests-kcp: $(CONTROLLER_GEN)
356353
output:webhook:dir=./controlplane/kubeadm/config/webhook \
357354
webhook
358355

359-
## --------------------------------------
360-
## Bindata generation
361-
## TODO(community): Figure out a way to remove this target in favor of go embed.
362-
## --------------------------------------
363-
364-
.PHONY: generate-bindata
365-
generate-bindata: $(KUSTOMIZE) $(GOBINDATA) clean-bindata ## Generate code for embedding the clusterctl api manifest
366-
# We're running go generate here, because the only target actually generates bindata in test/framework/kubernetesversions
367-
# This directive should be removed in favor of go embed.
368-
go generate ./...
369-
# Package manifest YAML into a single file.
370-
mkdir -p $(GOBINDATA_CLUSTERCTL_DIR)/manifest/
371-
$(KUSTOMIZE) build $(GOBINDATA_CLUSTERCTL_DIR)/crd > $(GOBINDATA_CLUSTERCTL_DIR)/manifest/clusterctl-api.yaml
372-
# Generate go-bindata, add boilerplate, then cleanup.
373-
$(GOBINDATA) -mode=420 -modtime=1 -pkg=config -o=$(GOBINDATA_CLUSTERCTL_DIR)/zz_generated.bindata.go $(GOBINDATA_CLUSTERCTL_DIR)/manifest/
374-
cat ./hack/boilerplate/boilerplate.generatego.txt $(GOBINDATA_CLUSTERCTL_DIR)/zz_generated.bindata.go > $(GOBINDATA_CLUSTERCTL_DIR)/manifest/manifests.go
375-
cp $(GOBINDATA_CLUSTERCTL_DIR)/manifest/manifests.go $(GOBINDATA_CLUSTERCTL_DIR)/zz_generated.bindata.go
376-
# Cleanup the manifest folder.
377-
$(MAKE) clean-bindata
378-
379356
## --------------------------------------
380357
## Modules
381358
## --------------------------------------
@@ -618,10 +595,6 @@ clean-release-git: ## Restores the git files usually modified during a release
618595
clean-book: ## Remove all generated GitBook files
619596
rm -rf ./docs/book/_book
620597

621-
.PHONY: clean-bindata
622-
clean-bindata: ## Remove bindata generated folder
623-
rm -rf $(GOBINDATA_CLUSTERCTL_DIR)/manifest
624-
625598
.PHONY: clean-manifests ## Reset manifests in config directories back to master
626599
clean-manifests:
627600
@read -p "WARNING: This will reset all config directories to local master. Press [ENTER] to continue."

cmd/clusterctl/client/cluster/inventory.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import (
3434
)
3535

3636
const (
37-
embeddedCustomResourceDefinitionPath = "cmd/clusterctl/config/manifest/clusterctl-api.yaml"
38-
3937
waitInventoryCRDInterval = 250 * time.Millisecond
4038
waitInventoryCRDTimeout = 1 * time.Minute
4139
)
@@ -162,14 +160,8 @@ func (p *inventoryClient) EnsureCustomResourceDefinitions() error {
162160

163161
log.V(1).Info("Installing the clusterctl inventory CRD")
164162

165-
// Get the CRDs manifest from the embedded assets.
166-
yaml, err := config.Asset(embeddedCustomResourceDefinitionPath)
167-
if err != nil {
168-
return err
169-
}
170-
171163
// Transform the yaml in a list of objects.
172-
objs, err := utilyaml.ToUnstructured(yaml)
164+
objs, err := utilyaml.ToUnstructured(config.ClusterctlAPIManifest)
173165
if err != nil {
174166
return errors.Wrap(err, "failed to parse yaml for clusterctl inventory CRDs")
175167
}

test/framework/kubernetesversions/bindata.go renamed to cmd/clusterctl/config/embedded_manifest.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2020 The Kubernetes Authors.
2+
Copyright 2021 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -13,7 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
package config
1617

17-
package kubernetesversions
18+
import _ "embed"
1819

19-
//go:generate sh -c "go-bindata -nometadata -pkg kubernetesversions -o zz_generated.bindata.go.tmp data && cat ../../../hack/boilerplate/boilerplate.generatego.txt zz_generated.bindata.go.tmp > zz_generated.bindata.go && rm zz_generated.bindata.go.tmp"
20+
//go:embed manifest/clusterctl-api.yaml
21+
var ClusterctlAPIManifest []byte
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
annotations:
5+
controller-gen.kubebuilder.io/version: v0.5.0
6+
creationTimestamp: null
7+
name: providers.clusterctl.cluster.x-k8s.io
8+
spec:
9+
group: clusterctl.cluster.x-k8s.io
10+
names:
11+
categories:
12+
- cluster-api
13+
kind: Provider
14+
listKind: ProviderList
15+
plural: providers
16+
singular: provider
17+
scope: Namespaced
18+
versions:
19+
- additionalPrinterColumns:
20+
- jsonPath: .type
21+
name: Type
22+
type: string
23+
- jsonPath: .providerName
24+
name: Provider
25+
type: string
26+
- jsonPath: .version
27+
name: Version
28+
type: string
29+
- jsonPath: .watchedNamespace
30+
name: Watch Namespace
31+
type: string
32+
name: v1alpha3
33+
schema:
34+
openAPIV3Schema:
35+
description: Provider defines an entry in the provider inventory.
36+
properties:
37+
apiVersion:
38+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
39+
type: string
40+
kind:
41+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
42+
type: string
43+
metadata:
44+
type: object
45+
providerName:
46+
description: ProviderName indicates the name of the provider.
47+
type: string
48+
type:
49+
description: Type indicates the type of the provider. See ProviderType for a list of supported values
50+
type: string
51+
version:
52+
description: Version indicates the component version.
53+
type: string
54+
watchedNamespace:
55+
description: WatchedNamespace indicates the namespace where the provider controller is is watching. if empty the provider controller is watching for objects in all namespaces.
56+
type: string
57+
type: object
58+
served: true
59+
storage: true
60+
subresources: {}
61+
status:
62+
acceptedNames:
63+
kind: ""
64+
plural: ""
65+
conditions: []
66+
storedVersions: []

0 commit comments

Comments
 (0)