Skip to content

Commit

Permalink
Changes from statik to go:embed for examples serving
Browse files Browse the repository at this point in the history
There's currently a glitch because go.mod isn't allowed in the go:embed
path.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
Adrian Cole committed Mar 24, 2021
1 parent aef7e79 commit ed15f0d
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 143 deletions.
2 changes: 0 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
GOMAXPROCS: "3"
steps:
- checkout
- run: make init
- run: ./ci/install-lint
- run: ./ci/lint

Expand All @@ -41,7 +40,6 @@ jobs:
resource_class: medium+
steps:
- checkout
- run: make init
- run: ./ci/install-envoy
- run: ./ci/test
- run:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ jobs:
- name: "Install Go"
uses: actions/setup-go@v2
with:
go-version: '1.13.3'

- name: "Init on first use"
run: make init
go-version: '1.16.2'

- name: "Build `getenvoy` and `e2e` binaries"
run: make bin
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: "Set up Go"
uses: actions/setup-go@v2
with:
go-version: '1.13.3'
go-version: '1.16.2'

- name: "Login into DockerHub"
uses: azure/docker-login@v1
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
- name: "Install Go"
uses: actions/setup-go@v2
with:
go-version: '1.13.3'
go-version: '1.16.2'

- name: "Build `e2e` binaries"
run: make build/bin/linux/amd64/e2e build/bin/darwin/amd64/e2e
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ vendor
dist
/getenvoy
/build/

# code generated by `github.com/rakyll/statik`
statik.go
.idea
3 changes: 0 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
project_name: getenvoy
env:
- GO111MODULE=on
before:
hooks:
- make init
builds:
- binary: getenvoy
ldflags: "-s -w -X github.com/tetratelabs/getenvoy/pkg/version.version={{.Version}}"
Expand Down
15 changes: 4 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ GETENVOY_OUT_PATH = $(BIN_DIR)/$(1)/$(2)/getenvoy

define GEN_GETENVOY_BUILD_TARGET
.PHONY: $(call GETENVOY_OUT_PATH,$(1),$(2))
$(call GETENVOY_OUT_PATH,$(1),$(2)): generate
$(call GETENVOY_OUT_PATH,$(1),$(2)):
CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build $(GO_LD_FLAGS) -o $(call GETENVOY_OUT_PATH,$(1),$(2)) ./cmd/getenvoy/main.go
endef
$(foreach os,$(GOOSES),$(foreach arch,$(GOARCHS),$(eval $(call GEN_GETENVOY_BUILD_TARGET,$(os),$(arch)))))
Expand All @@ -71,17 +71,10 @@ $(call E2E_OUT_PATH,$(1),$(2)):
endef
$(foreach os,$(GOOSES),$(foreach arch,$(GOARCHS),$(eval $(call GEN_E2E_BUILD_TARGET,$(os),$(arch)))))

.PHONY: init
init: generate

.PHONY: deps
deps:
go mod download

.PHONY: generate
generate: deps
go generate ./pkg/...

.PHONY: build
build: $(call GETENVOY_OUT_PATH,$(GOOS),$(GOARCH))

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

.PHONY: test
test: generate
test:
docker-compose up -d
go test $(GO_TEST_OPTS) $(GO_TEST_EXTRA_OPTS) $(TEST_PKG_LIST)

.PHONY: test.ci
test.ci: generate
test.ci:
go test $(GO_TEST_OPTS) $(GO_TEST_EXTRA_OPTS) $(TEST_PKG_LIST)

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

.PHONY: coverage
coverage: generate
coverage:
mkdir -p "$(shell dirname "$(COVERAGE_PROFILE)")"
go test $(GO_COVERAGE_OPTS) $(GO_COVERAGE_EXTRA_OPTS) -coverprofile="$(COVERAGE_PROFILE)" $(COVERAGE_PKG_LIST)
go tool cover -html="$(COVERAGE_PROFILE)" -o "$(COVERAGE_REPORT)"
Expand Down
37 changes: 37 additions & 0 deletions data/extension/init/templates.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2021 Tetrate
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// 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 init
// ^^ last path in the directory relative from the project root data/extension/init

import (
"embed"
"io/fs"
)

// templatesFs includes only the relative path of "templates".
//
// Assets must be in this directory because go:embed doesn't support navigation outside (ex. ../)
// See https://pkg.go.dev/embed#hdr-Directives
//go:embed templates/*
var templatesFs embed.FS

// GetTemplates returns the templates directory as a filesystem
func GetTemplates() fs.FS {
fs, err := fs.Sub(templatesFs, "templates")
if err != nil {
panic(err) // unexpected or a typo
}
return fs
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package init

import (
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm"
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package init

import (
"bufio"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package init

import (
"testing"
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package init

import (
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package init

import (
"testing"
Expand Down
10 changes: 3 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/tetratelabs/getenvoy

go 1.13
// This project uses go:embed, so requires minimally go 1.16
go 1.16

require (
bitbucket.org/creachadair/shell v0.0.6
Expand All @@ -16,7 +17,7 @@ require (
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/golang/protobuf v1.3.5
github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect
github.com/manifoldco/promptui v0.0.0-00010101000000-000000000000
github.com/manifoldco/promptui v0.8.0
github.com/mattn/go-isatty v0.0.12
github.com/mattn/go-shellwords v1.0.10
github.com/mholt/archiver v3.1.1+incompatible
Expand All @@ -27,7 +28,6 @@ require (
github.com/opencontainers/selinux v1.8.0 // indirect
github.com/otiai10/copy v1.2.0
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.0.0-00010101000000-000000000000
github.com/schollz/progressbar/v2 v2.13.2
github.com/shirou/gopsutil v0.0.0-20190731134726-d80c43f9c984
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749
Expand All @@ -47,7 +47,3 @@ replace github.com/Azure/go-autorest/autorest => github.com/Azure/go-autorest/au
replace github.com/docker/docker => github.com/docker/docker v17.12.1-ce+incompatible

replace github.com/hashicorp/consul => github.com/hashicorp/consul v1.3.1

replace github.com/manifoldco/promptui => github.com/yskopets/promptui v0.7.1-0.20200429230902-361491009c11

replace github.com/rakyll/statik => github.com/yskopets/statik v0.1.8-0.20200501213002-c2d8dcc79889
Loading

0 comments on commit ed15f0d

Please sign in to comment.