Skip to content

Commit b9f9e3f

Browse files
author
Adrian Cole
committed
Changes from statik to go:embed for examples serving
This removes go.mod from the examples due to golang/go#41191 (comment) Signed-off-by: Adrian Cole <[email protected]>
1 parent aef7e79 commit b9f9e3f

File tree

19 files changed

+98
-144
lines changed

19 files changed

+98
-144
lines changed

.circleci/config.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ version: 2.1
1717
executors:
1818
builder:
1919
docker:
20-
- image: circleci/golang:1.15.6
20+
- image: circleci/golang:1.16.2
2121
- image: registry:2
2222

2323
jobs:
@@ -32,7 +32,6 @@ jobs:
3232
GOMAXPROCS: "3"
3333
steps:
3434
- checkout
35-
- run: make init
3635
- run: ./ci/install-lint
3736
- run: ./ci/lint
3837

@@ -41,7 +40,6 @@ jobs:
4140
resource_class: medium+
4241
steps:
4342
- checkout
44-
- run: make init
4543
- run: ./ci/install-envoy
4644
- run: ./ci/test
4745
- run:

.github/workflows/commit.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ jobs:
2121
- name: "Install Go"
2222
uses: actions/setup-go@v2
2323
with:
24-
go-version: '1.13.3'
25-
26-
- name: "Init on first use"
27-
run: make init
24+
go-version: '1.16.2'
2825

2926
- name: "Build `getenvoy` and `e2e` binaries"
3027
run: make bin

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: "Set up Go"
2222
uses: actions/setup-go@v2
2323
with:
24-
go-version: '1.13.3'
24+
go-version: '1.16.2'
2525

2626
- name: "Login into DockerHub"
2727
uses: azure/docker-login@v1
@@ -75,7 +75,7 @@ jobs:
7575
- name: "Install Go"
7676
uses: actions/setup-go@v2
7777
with:
78-
go-version: '1.13.3'
78+
go-version: '1.16.2'
7979

8080
- name: "Build `e2e` binaries"
8181
run: make build/bin/linux/amd64/e2e build/bin/darwin/amd64/e2e

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ vendor
22
dist
33
/getenvoy
44
/build/
5-
6-
# code generated by `github.com/rakyll/statik`
7-
statik.go
5+
.idea

.golangci.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,6 @@ issues:
182182
- gosec
183183
- maligned
184184

185-
# Exclude lll issues for long lines with go:generate
186-
- linters:
187-
- lll
188-
source: "^//go:generate "
189-
190185
# Independently from option `exclude` we use default exclude patterns,
191186
# it can be disabled by this option. To list all
192187
# excluded by default patterns execute `golangci-lint run --help`.

.goreleaser.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
project_name: getenvoy
1616
env:
1717
- GO111MODULE=on
18-
before:
19-
hooks:
20-
- make init
2118
builds:
2219
- binary: getenvoy
2320
ldflags: "-s -w -X github.com/tetratelabs/getenvoy/pkg/version.version={{.Version}}"

Makefile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ GETENVOY_OUT_PATH = $(BIN_DIR)/$(1)/$(2)/getenvoy
5757

5858
define GEN_GETENVOY_BUILD_TARGET
5959
.PHONY: $(call GETENVOY_OUT_PATH,$(1),$(2))
60-
$(call GETENVOY_OUT_PATH,$(1),$(2)): generate
60+
$(call GETENVOY_OUT_PATH,$(1),$(2)):
6161
CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build $(GO_LD_FLAGS) -o $(call GETENVOY_OUT_PATH,$(1),$(2)) ./cmd/getenvoy/main.go
6262
endef
6363
$(foreach os,$(GOOSES),$(foreach arch,$(GOARCHS),$(eval $(call GEN_GETENVOY_BUILD_TARGET,$(os),$(arch)))))
@@ -71,17 +71,10 @@ $(call E2E_OUT_PATH,$(1),$(2)):
7171
endef
7272
$(foreach os,$(GOOSES),$(foreach arch,$(GOARCHS),$(eval $(call GEN_E2E_BUILD_TARGET,$(os),$(arch)))))
7373

74-
.PHONY: init
75-
init: generate
76-
7774
.PHONY: deps
7875
deps:
7976
go mod download
8077

81-
.PHONY: generate
82-
generate: deps
83-
go generate ./pkg/...
84-
8578
.PHONY: build
8679
build: $(call GETENVOY_OUT_PATH,$(GOOS),$(GOARCH))
8780

@@ -94,12 +87,12 @@ release.dryrun:
9487
goreleaser release --skip-publish --snapshot --rm-dist
9588

9689
.PHONY: test
97-
test: generate
90+
test:
9891
docker-compose up -d
9992
go test $(GO_TEST_OPTS) $(GO_TEST_EXTRA_OPTS) $(TEST_PKG_LIST)
10093

10194
.PHONY: test.ci
102-
test.ci: generate
95+
test.ci:
10396
go test $(GO_TEST_OPTS) $(GO_TEST_EXTRA_OPTS) $(TEST_PKG_LIST)
10497

10598
.PHONY: e2e
@@ -123,7 +116,7 @@ endef
123116
$(foreach os,$(GOOSES),$(foreach arch,$(GOARCHS),$(eval $(call GEN_BIN_GOOS_GOARCH_TARGET,$(os),$(arch)))))
124117

125118
.PHONY: coverage
126-
coverage: generate
119+
coverage:
127120
mkdir -p "$(shell dirname "$(COVERAGE_PROFILE)")"
128121
go test $(GO_COVERAGE_OPTS) $(GO_COVERAGE_EXTRA_OPTS) -coverprofile="$(COVERAGE_PROFILE)" $(COVERAGE_PKG_LIST)
129122
go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT)"

data/example/init/templates.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2021 Tetrate
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package init
16+
// ^^ last path in the directory relative from the project root data/example/init
17+
18+
import (
19+
"embed"
20+
"io/fs"
21+
)
22+
23+
// templatesFs includes only the relative path of "templates".
24+
//
25+
// Assets must be in this directory because go:embed doesn't support navigation outside (ex. ../)
26+
// See https://pkg.go.dev/embed#hdr-Directives
27+
//go:embed templates/*
28+
var templatesFs embed.FS
29+
30+
// GetTemplates returns the templates directory as a filesystem
31+
func GetTemplates() fs.FS {
32+
fs, err := fs.Sub(templatesFs, "templates")
33+
if err != nil {
34+
panic(err) // unexpected or a typo
35+
}
36+
return fs
37+
}

data/extension/init/templates.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2021 Tetrate
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package init
16+
// ^^ last path in the directory relative from the project root data/extension/init
17+
18+
import (
19+
"embed"
20+
"io/fs"
21+
)
22+
23+
// templatesFs includes only the relative path of "templates".
24+
//
25+
// Assets must be in this directory because go:embed doesn't support navigation outside (ex. ../)
26+
// See https://pkg.go.dev/embed#hdr-Directives
27+
//go:embed templates/*
28+
var templatesFs embed.FS
29+
30+
// GetTemplates returns the templates directory as a filesystem
31+
func GetTemplates() fs.FS {
32+
fs, err := fs.Sub(templatesFs, "templates")
33+
if err != nil {
34+
panic(err) // unexpected or a typo
35+
}
36+
return fs
37+
}

data/extension/init/templates/tinygo/envoy.access_loggers/default/go.mod

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

data/extension/init/templates/tinygo/envoy.access_loggers/default/go.sum

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

data/extension/init/templates/tinygo/envoy.filters.http/default/go.mod

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

data/extension/init/templates/tinygo/envoy.filters.http/default/go.sum

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

data/extension/init/templates/tinygo/envoy.filters.network/default/go.mod

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

data/extension/init/templates/tinygo/envoy.filters.network/default/go.sum

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

go.mod

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/tetratelabs/getenvoy
22

3-
go 1.13
3+
// This project uses go:embed, so requires minimally go 1.16
4+
go 1.16
45

56
require (
67
bitbucket.org/creachadair/shell v0.0.6
@@ -16,7 +17,7 @@ require (
1617
github.com/go-ole/go-ole v1.2.4 // indirect
1718
github.com/golang/protobuf v1.3.5
1819
github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect
19-
github.com/manifoldco/promptui v0.0.0-00010101000000-000000000000
20+
github.com/manifoldco/promptui v0.8.0
2021
github.com/mattn/go-isatty v0.0.12
2122
github.com/mattn/go-shellwords v1.0.10
2223
github.com/mholt/archiver v3.1.1+incompatible
@@ -27,7 +28,6 @@ require (
2728
github.com/opencontainers/selinux v1.8.0 // indirect
2829
github.com/otiai10/copy v1.2.0
2930
github.com/pkg/errors v0.9.1
30-
github.com/rakyll/statik v0.0.0-00010101000000-000000000000
3131
github.com/schollz/progressbar/v2 v2.13.2
3232
github.com/shirou/gopsutil v0.0.0-20190731134726-d80c43f9c984
3333
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749
@@ -47,7 +47,3 @@ replace github.com/Azure/go-autorest/autorest => github.com/Azure/go-autorest/au
4747
replace github.com/docker/docker => github.com/docker/docker v17.12.1-ce+incompatible
4848

4949
replace github.com/hashicorp/consul => github.com/hashicorp/consul v1.3.1
50-
51-
replace github.com/manifoldco/promptui => github.com/yskopets/promptui v0.7.1-0.20200429230902-361491009c11
52-
53-
replace github.com/rakyll/statik => github.com/yskopets/statik v0.1.8-0.20200501213002-c2d8dcc79889

0 commit comments

Comments
 (0)