Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱Remove go-bindata #4378

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/golangci-lint)
CONVERSION_GEN := $(abspath $(TOOLS_BIN_DIR)/conversion-gen)
ENVSUBST := $(abspath $(TOOLS_BIN_DIR)/envsubst)

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

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

$(GOBINDATA): $(TOOLS_DIR)/go.mod # Build go-bindata from tools folder.
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/go-bindata github.com/go-bindata/go-bindata/go-bindata

$(RELEASE_NOTES): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && go build -tags=tools -o $(RELEASE_NOTES_BIN) ./release

Expand Down Expand Up @@ -230,7 +226,7 @@ ALL_GENERATE_MODULES = core cabpk kcp

.PHONY: generate
generate: ## Generate code
$(MAKE) generate-manifests generate-go generate-bindata
$(MAKE) generate-manifests generate-go
$(MAKE) -C test/infrastructure/docker generate

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

.PHONY: generate-manifests-core
generate-manifests-core: $(CONTROLLER_GEN)
generate-manifests-core: $(CONTROLLER_GEN) $(KUSTOMIZE)
$(CONTROLLER_GEN) \
paths=./api/... \
paths=./controllers/... \
Expand All @@ -316,6 +312,7 @@ generate-manifests-core: $(CONTROLLER_GEN)
paths=./cmd/clusterctl/api/... \
crd:crdVersions=v1 \
output:crd:dir=./cmd/clusterctl/config/crd/bases
$(KUSTOMIZE) build $(CLUSTERCTL_MANIFEST_DIR)/crd > $(CLUSTERCTL_MANIFEST_DIR)/manifest/clusterctl-api.yaml

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

## --------------------------------------
## Bindata generation
## TODO(community): Figure out a way to remove this target in favor of go embed.
## --------------------------------------

.PHONY: generate-bindata
generate-bindata: $(KUSTOMIZE) $(GOBINDATA) clean-bindata ## Generate code for embedding the clusterctl api manifest
# We're running go generate here, because the only target actually generates bindata in test/framework/kubernetesversions
# This directive should be removed in favor of go embed.
go generate ./...
# Package manifest YAML into a single file.
mkdir -p $(GOBINDATA_CLUSTERCTL_DIR)/manifest/
$(KUSTOMIZE) build $(GOBINDATA_CLUSTERCTL_DIR)/crd > $(GOBINDATA_CLUSTERCTL_DIR)/manifest/clusterctl-api.yaml
# Generate go-bindata, add boilerplate, then cleanup.
$(GOBINDATA) -mode=420 -modtime=1 -pkg=config -o=$(GOBINDATA_CLUSTERCTL_DIR)/zz_generated.bindata.go $(GOBINDATA_CLUSTERCTL_DIR)/manifest/
cat ./hack/boilerplate/boilerplate.generatego.txt $(GOBINDATA_CLUSTERCTL_DIR)/zz_generated.bindata.go > $(GOBINDATA_CLUSTERCTL_DIR)/manifest/manifests.go
cp $(GOBINDATA_CLUSTERCTL_DIR)/manifest/manifests.go $(GOBINDATA_CLUSTERCTL_DIR)/zz_generated.bindata.go
# Cleanup the manifest folder.
$(MAKE) clean-bindata

## --------------------------------------
## Modules
## --------------------------------------
Expand Down Expand Up @@ -603,10 +580,6 @@ clean-release-git: ## Restores the git files usually modified during a release
clean-book: ## Remove all generated GitBook files
rm -rf ./docs/book/_book

.PHONY: clean-bindata
clean-bindata: ## Remove bindata generated folder
rm -rf $(GOBINDATA_CLUSTERCTL_DIR)/manifest

.PHONY: clean-manifests ## Reset manifests in config directories back to master
clean-manifests:
@read -p "WARNING: This will reset all config directories to local master. Press [ENTER] to continue."
Expand Down
10 changes: 1 addition & 9 deletions cmd/clusterctl/client/cluster/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import (
)

const (
embeddedCustomResourceDefinitionPath = "cmd/clusterctl/config/manifest/clusterctl-api.yaml"

waitInventoryCRDInterval = 250 * time.Millisecond
waitInventoryCRDTimeout = 1 * time.Minute
)
Expand Down Expand Up @@ -162,14 +160,8 @@ func (p *inventoryClient) EnsureCustomResourceDefinitions() error {

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

// Get the CRDs manifest from the embedded assets.
yaml, err := config.Asset(embeddedCustomResourceDefinitionPath)
if err != nil {
return err
}

// Transform the yaml in a list of objects.
objs, err := utilyaml.ToUnstructured(yaml)
objs, err := utilyaml.ToUnstructured(config.ClusterctlAPIManifest)
if err != nil {
return errors.Wrap(err, "failed to parse yaml for clusterctl inventory CRDs")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 The Kubernetes Authors.
Copyright 2021 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package config

package kubernetesversions
import _ "embed"

//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"
//go:embed manifest/clusterctl-api.yaml
var ClusterctlAPIManifest []byte
66 changes: 66 additions & 0 deletions cmd/clusterctl/config/manifest/clusterctl-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.5.0
creationTimestamp: null
name: providers.clusterctl.cluster.x-k8s.io
spec:
group: clusterctl.cluster.x-k8s.io
names:
categories:
- cluster-api
kind: Provider
listKind: ProviderList
plural: providers
singular: provider
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .type
name: Type
type: string
- jsonPath: .providerName
name: Provider
type: string
- jsonPath: .version
name: Version
type: string
- jsonPath: .watchedNamespace
name: Watch Namespace
type: string
name: v1alpha3
schema:
openAPIV3Schema:
description: Provider defines an entry in the provider inventory.
properties:
apiVersion:
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'
type: string
kind:
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'
type: string
metadata:
type: object
providerName:
description: ProviderName indicates the name of the provider.
type: string
type:
description: Type indicates the type of the provider. See ProviderType for a list of supported values
type: string
version:
description: Version indicates the component version.
type: string
watchedNamespace:
description: WatchedNamespace indicates the namespace where the provider controller is is watching. if empty the provider controller is watching for objects in all namespaces.
type: string
type: object
served: true
storage: true
subresources: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading