Skip to content

Commit 05fa1c6

Browse files
remove go-bindata
1 parent 26ff3df commit 05fa1c6

File tree

9 files changed

+84
-601
lines changed

9 files changed

+84
-601
lines changed

Makefile

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

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

7574
# Define Docker related variables. Releases should modify and double check these vars.
7675
REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
@@ -176,9 +175,6 @@ $(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod # Build golangci-lint from tools folder.
176175
$(CONVERSION_GEN): $(TOOLS_DIR)/go.mod
177176
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-gen k8s.io/code-generator/cmd/conversion-gen
178177

179-
$(GOBINDATA): $(TOOLS_DIR)/go.mod # Build go-bindata from tools folder.
180-
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/go-bindata github.com/go-bindata/go-bindata/go-bindata
181-
182178
$(RELEASE_NOTES): $(TOOLS_DIR)/go.mod
183179
cd $(TOOLS_DIR) && go build -tags=tools -o $(RELEASE_NOTES_BIN) ./release
184180

@@ -230,7 +226,7 @@ ALL_GENERATE_MODULES = core cabpk kcp
230226

231227
.PHONY: generate
232228
generate: ## Generate code
233-
$(MAKE) generate-manifests generate-go generate-bindata
229+
$(MAKE) generate-manifests generate-go
234230
$(MAKE) -C test/infrastructure/docker generate
235231

236232
.PHONY: generate-go
@@ -299,7 +295,7 @@ generate-go-conversions-kcp: $(CONVERSION_GEN)
299295
generate-manifests: $(addprefix generate-manifests-,$(ALL_GENERATE_MODULES)) ## Generate manifests e.g. CRD, RBAC etc.
300296

301297
.PHONY: generate-manifests-core
302-
generate-manifests-core: $(CONTROLLER_GEN)
298+
generate-manifests-core: $(CONTROLLER_GEN) $(KUSTOMIZE)
303299
$(CONTROLLER_GEN) \
304300
paths=./api/... \
305301
paths=./controllers/... \
@@ -316,6 +312,7 @@ generate-manifests-core: $(CONTROLLER_GEN)
316312
paths=./cmd/clusterctl/api/... \
317313
crd:crdVersions=v1 \
318314
output:crd:dir=./cmd/clusterctl/config/crd/bases
315+
$(KUSTOMIZE) build $(CLUSTERCTL_MANIFEST_DIR)/crd > $(CLUSTERCTL_MANIFEST_DIR)/manifest/clusterctl-api.yaml
319316

320317
.PHONY: generate-manifests-cabpk
321318
generate-manifests-cabpk: $(CONTROLLER_GEN)
@@ -341,26 +338,6 @@ generate-manifests-kcp: $(CONTROLLER_GEN)
341338
output:webhook:dir=./controlplane/kubeadm/config/webhook \
342339
webhook
343340

344-
## --------------------------------------
345-
## Bindata generation
346-
## TODO(community): Figure out a way to remove this target in favor of go embed.
347-
## --------------------------------------
348-
349-
.PHONY: generate-bindata
350-
generate-bindata: $(KUSTOMIZE) $(GOBINDATA) clean-bindata ## Generate code for embedding the clusterctl api manifest
351-
# We're running go generate here, because the only target actually generates bindata in test/framework/kubernetesversions
352-
# This directive should be removed in favor of go embed.
353-
go generate ./...
354-
# Package manifest YAML into a single file.
355-
mkdir -p $(GOBINDATA_CLUSTERCTL_DIR)/manifest/
356-
$(KUSTOMIZE) build $(GOBINDATA_CLUSTERCTL_DIR)/crd > $(GOBINDATA_CLUSTERCTL_DIR)/manifest/clusterctl-api.yaml
357-
# Generate go-bindata, add boilerplate, then cleanup.
358-
$(GOBINDATA) -mode=420 -modtime=1 -pkg=config -o=$(GOBINDATA_CLUSTERCTL_DIR)/zz_generated.bindata.go $(GOBINDATA_CLUSTERCTL_DIR)/manifest/
359-
cat ./hack/boilerplate/boilerplate.generatego.txt $(GOBINDATA_CLUSTERCTL_DIR)/zz_generated.bindata.go > $(GOBINDATA_CLUSTERCTL_DIR)/manifest/manifests.go
360-
cp $(GOBINDATA_CLUSTERCTL_DIR)/manifest/manifests.go $(GOBINDATA_CLUSTERCTL_DIR)/zz_generated.bindata.go
361-
# Cleanup the manifest folder.
362-
$(MAKE) clean-bindata
363-
364341
## --------------------------------------
365342
## Modules
366343
## --------------------------------------
@@ -603,10 +580,6 @@ clean-release-git: ## Restores the git files usually modified during a release
603580
clean-book: ## Remove all generated GitBook files
604581
rm -rf ./docs/book/_book
605582

606-
.PHONY: clean-bindata
607-
clean-bindata: ## Remove bindata generated folder
608-
rm -rf $(GOBINDATA_CLUSTERCTL_DIR)/manifest
609-
610583
.PHONY: clean-manifests ## Reset manifests in config directories back to master
611584
clean-manifests:
612585
@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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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
39+
of an object. Servers should convert recognized schemas to the latest
40+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
41+
type: string
42+
kind:
43+
description: 'Kind is a string value representing the REST resource this
44+
object represents. Servers may infer this from the endpoint the client
45+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
46+
type: string
47+
metadata:
48+
type: object
49+
providerName:
50+
description: ProviderName indicates the name of the provider.
51+
type: string
52+
type:
53+
description: Type indicates the type of the provider. See ProviderType
54+
for a list of supported values
55+
type: string
56+
version:
57+
description: Version indicates the component version.
58+
type: string
59+
watchedNamespace:
60+
description: WatchedNamespace indicates the namespace where the provider
61+
controller is is watching. if empty the provider controller is watching
62+
for objects in all namespaces.
63+
type: string
64+
type: object
65+
served: true
66+
storage: true
67+
subresources: {}
68+
status:
69+
acceptedNames:
70+
kind: ""
71+
plural: ""
72+
conditions: []
73+
storedVersions: []

0 commit comments

Comments
 (0)