Skip to content

Commit

Permalink
Revert "Eliminate use of vfsgen (istio#180)" (istio#191)
Browse files Browse the repository at this point in the history
This reverts commit 81504f6.
  • Loading branch information
ostromart authored and istio-testing committed Aug 14, 2019
1 parent 81504f6 commit f3f867d
Show file tree
Hide file tree
Showing 7 changed files with 2,348 additions and 32,411 deletions.
7 changes: 4 additions & 3 deletions Makefile.core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ fmt:
@goimports -w -local "istio.io" $(shell find . -type f -name '*.go' ! -name '*.gen.go' ! -name '*.pb.go' )

# make target dependencies
gen: data/
go generate ./...
vfsgen: data/
go run ./cmd/vfsgen/vfsgen.go

########################
# protoc_gen_gogo*
Expand Down Expand Up @@ -119,7 +119,8 @@ gen_patch_iscp:
gen_patch_values:
diff -u pkg/apis/istio/v1alpha2/values/values_types.pb.go.orig pkg/apis/istio/v1alpha2/values/values_types.pb.go > pkg/apis/istio/v1alpha2/values/fix_values_structs.patch || true

mesh:

mesh: vfsgen
go build -o ${GOBIN}/mesh ./cmd/mesh.go

include Makefile.common.mk
2 changes: 1 addition & 1 deletion cmd/mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// 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.

//go:generate vfsgen -i ../data -v Assets -p vfsgen -o ../pkg/vfsgen/vfsgen.gen.go
package main

import (
Expand Down
39 changes: 39 additions & 0 deletions cmd/vfsgen/vfsgen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2019 Istio Authors
//
// 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.

// +build ignore

package main

import (
"log"
"net/http"
"os"
"path/filepath"

"github.com/shurcooL/vfsgen"
)

func main() {
var cwd, _ = os.Getwd()
templates := http.Dir(filepath.Join(cwd, "data"))
if err := vfsgen.Generate(templates, vfsgen.Options{
Filename: "pkg/vfsgen/vfsgen_data.go",
PackageName: "vfsgen",
// BuildTags: "deploy_build",
VariableName: "Assets",
}); err != nil {
log.Fatalln("vfsgen failed to generate code: ", err)
}
}
15 changes: 8 additions & 7 deletions pkg/helm/vfs_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ import (
"k8s.io/helm/pkg/proto/hapi/chart"

"istio.io/operator/pkg/util"
"istio.io/operator/pkg/vfs"
"istio.io/operator/pkg/vfsgen"

"istio.io/pkg/log"
)

const (
// DefaultProfileFilename is the name of the default profile yaml file.
DefaultProfileFilename = "default.yaml"

chartsRoot = "charts"
profilesRoot = "profiles"
chartsRoot = "/charts"
profilesRoot = "/profiles"
)

var (
Expand All @@ -41,7 +42,7 @@ var (
)

func init() {
profilePaths, err := vfs.ReadDir(profilesRoot)
profilePaths, err := vfsgen.ReadDir(profilesRoot)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -94,7 +95,7 @@ func (h *VFSRenderer) RenderManifest(values string) (string, error) {
func LoadValuesVFS(profileName string) (string, error) {
path := filepath.Join(profilesRoot, BuiltinProfileToFilename(profileName))
log.Infof("Loading values from compiled in VFS at path %s", path)
b, err := vfs.ReadFile(path)
b, err := vfsgen.ReadFile(path)
return string(b), err
}

Expand All @@ -108,13 +109,13 @@ func isBuiltinProfileName(name string) bool {
// loadChart implements the TemplateRenderer interface.
func (h *VFSRenderer) loadChart() error {
prefix := filepath.Join(chartsRoot, h.helmChartDirPath)
fnames, err := vfs.GetFilesRecursive(prefix)
fnames, err := vfsgen.GetFilesRecursive(prefix)
if err != nil {
return err
}
var bfs []*chartutil.BufferedFile
for _, fname := range fnames {
b, err := vfs.ReadFile(fname)
b, err := vfsgen.ReadFile(fname)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit f3f867d

Please sign in to comment.