Skip to content

Commit 5201978

Browse files
authored
Merge pull request #1146 from tkan145/replace-go-bindata-with-embed
Replace go-bindata with embed
2 parents c8a8c01 + c3e50ef commit 5201978

File tree

4 files changed

+6
-410
lines changed

4 files changed

+6
-410
lines changed

Makefile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,6 @@ $(OPERATOR_SDK):
193193
.PHONY: operator-sdk
194194
operator-sdk: $(OPERATOR_SDK)
195195

196-
GO_BINDATA=$(PROJECT_PATH)/bin/go-bindata
197-
GO_BINDATA_VERSION = v3.1.3
198-
$(GO_BINDATA):
199-
$(call go-install-tool,$(GO_BINDATA),github.com/go-bindata/go-bindata/v3/...,$(GO_BINDATA_VERSION))
200-
201-
.PHONY: go-bindata
202-
go-bindata: $(GO_BINDATA)
203-
204196
# Install CRDs into a cluster
205197
install: manifests $(KUSTOMIZE)
206198
$(KUSTOMIZE) build config/crd | $(KUBECTL) create -f - || $(KUSTOMIZE) build config/crd | $(KUBECTL) replace -f -
@@ -239,10 +231,8 @@ lint: $(GOLANGCI-LINT) ## Run lint tests
239231
$(GOLANGCI-LINT) run
240232

241233
# Generate code
242-
generate: $(CONTROLLER_GEN) $(GO_BINDATA)
234+
generate: $(CONTROLLER_GEN)
243235
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
244-
@echo Generate Go embedded assets files by processing source
245-
export PATH=$(PROJECT_PATH)/bin:$$PATH; $(GO) generate github.com/3scale/3scale-operator/pkg/assets
246236

247237
# Build the docker image
248238
.PHONY: docker-build

doc/dependency_decisions.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,6 @@
189189
:why:
190190
:versions: []
191191
:when: 2019-11-26 10:15:34.001520959 Z
192-
- - :license
193-
- github.com/go-bindata/go-bindata
194-
- CC0 1.0 Universal
195-
- :who:
196-
:why: https://github.com/go-bindata/go-bindata/blob/master/LICENSE
197-
:versions: []
198-
:when: 2020-06-15 09:58:31.161619176 Z
199192
- - :license
200193
- github.com/RHsyseng/operator-utils
201194
- Apache 2.0

pkg/assets/assets.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ package assets
22

33
import (
44
"bytes"
5+
"embed"
56
"text/template"
67
)
78

8-
// Important: Run "make" to regenerate code after modifying/adding/removing any asset
9-
// adding -nometadata to not preserve size, mode, and modtime info. It should not be necessary as the content will be embedded in custom resources.
10-
//go:generate go-bindata --prefix assets -pkg $GOPACKAGE -nometadata -o bindata.go assets/...
9+
//go:embed assets/*
10+
var embeddedFiles embed.FS
1111

1212
// SafeStringAsset Returns asset data as string
1313
// panic if not found or any err is detected
1414
func SafeStringAsset(name string) string {
15-
data, err := Asset(name)
15+
data, err := embeddedFiles.ReadFile("assets/" + name)
1616
if err != nil {
1717
panic(err)
1818
}
1919

2020
return string(data)
2121
}
2222

23-
// TemplateAsset Executes one tamplate by applying it to a daata structure.
23+
// TemplateAsset Executes one template by applying it to a data structure.
2424
// panic if not found or any err is detected
2525
func TemplateAsset(name string, data interface{}) string {
2626
tObj, err := template.New(name).Parse(SafeStringAsset(name))

0 commit comments

Comments
 (0)