Skip to content

Commit

Permalink
Replace vfsgen with embed.FS (istio#29963)
Browse files Browse the repository at this point in the history
* Replace vfsgen with embed.FS

* fix lint
  • Loading branch information
howardjohn authored Feb 24, 2021
1 parent f349613 commit bc5a0d2
Show file tree
Hide file tree
Showing 19 changed files with 257 additions and 859 deletions.
12 changes: 5 additions & 7 deletions Makefile.core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -342,22 +342,20 @@ go-gen:
@mkdir -p /tmp/bin
@PATH="${PATH}":/tmp/bin go generate ./...

gen-charts:
@operator/scripts/create_assets_gen.sh

refresh-goldens:
@REFRESH_GOLDEN=true go test ${GOBUILDFLAGS} ./operator/...
@REFRESH_GOLDEN=true go test ${GOBUILDFLAGS} ./pkg/kube/inject/...
@REFRESH_GOLDEN=true go test ${GOBUILDFLAGS} ./pilot/pkg/security/authz/builder/...

update-golden: refresh-goldens

gen: mod-download-go go-gen mirror-licenses format update-crds operator-proto sync-configs-from-istiod gen-kustomize update-golden ## Update all generated code.
# Keep dummy target since some build pipelines depend on this
gen-charts:
@echo "This target is no longer required and will be removed in the future"

check-no-modify:
@bin/check_no_modify.sh
gen: mod-download-go go-gen mirror-licenses format update-crds operator-proto sync-configs-from-istiod gen-kustomize update-golden ## Update all generated code.

gen-check: check-no-modify gen check-clean-repo
gen-check: gen check-clean-repo

# Copy the injection template file and configmap from istiod chart to istiod-remote chart
sync-configs-from-istiod:
Expand Down
24 changes: 0 additions & 24 deletions bin/check_no_modify.sh

This file was deleted.

1 change: 0 additions & 1 deletion bin/nomodify.md5

This file was deleted.

27 changes: 0 additions & 27 deletions bin/update_no_modify.sh

This file was deleted.

5 changes: 1 addition & 4 deletions istioctl/cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,7 @@ func tagWebhookConfigFromCanonicalWebhook(wh admit_v1.MutatingWebhookConfigurati

// tagWebhookYAML generates YAML for the tag webhook MutatingWebhookConfiguration.
func tagWebhookYAML(config *tagWebhookConfig, chartPath string) (string, error) {
r, err := helm.NewHelmRenderer(chartPath, pilotDiscoveryChart, "Pilot", istioNamespace)
if err != nil {
return "", fmt.Errorf("failed creating Helm renderer: %v", err)
}
r := helm.NewHelmRenderer(chartPath, pilotDiscoveryChart, "Pilot", istioNamespace)

if err := r.Run(); err != nil {
return "", fmt.Errorf("failed running Helm renderer: %v", err)
Expand Down
5 changes: 1 addition & 4 deletions istioctl/pkg/multicluster/remote_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,7 @@ func getOrCreateServiceAccount(client kube.ExtendedClient, opt RemoteSecretOptio

func createServiceAccount(client kube.ExtendedClient, opt RemoteSecretOptions) error {
// Create a renderer for the base installation.
r, err := helm.NewHelmRenderer(opt.ManifestsPath, "base", "Base", opt.Namespace)
if err != nil {
return fmt.Errorf("failed creating Helm renderer: %v", err)
}
r := helm.NewHelmRenderer(opt.ManifestsPath, "base", "Base", opt.Namespace)

if err := r.Run(); err != nil {
return fmt.Errorf("failed running Helm renderer: %v", err)
Expand Down
43 changes: 43 additions & 0 deletions manifests/manifest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 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.

package manifests

import (
"embed"
"io/fs"
"os"
)

// FS embeds the manifests
//go:embed charts/* profiles/*
//go:embed charts/gateways/istio-egress/templates/_affinity.tpl
//go:embed charts/gateways/istio-egress/templates/_helpers.tpl
//go:embed charts/gateways/istio-ingress/templates/_affinity.tpl
var FS embed.FS

var (
_ fs.FS = FS
_ fs.ReadFileFS = FS
_ fs.ReadDirFS = FS
)

// BuiltinOrDir returns a FS for the provided directory. If no directory is passed, the compiled in
// FS will be used
func BuiltinOrDir(dir string) fs.FS {
if dir == "" {
return FS
}
return os.DirFS(dir)
}
15 changes: 3 additions & 12 deletions operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,7 @@ for details.

The quick start describes how to install and use the operator `mesh` CLI command and/or controller.

### Building

If you're trying to do a local build that bypasses the build container, you'll need to
to execute the following step one time.

```bash
GO111MODULE=on go get github.com/jteeuwen/go-bindata/go-bindata@6025e8de665b
```

#### CLI
### CLI

To build the operator CLI, simply:

Expand All @@ -73,7 +64,7 @@ make build

Ensure the created binary is in your PATH to run the examples below.

#### Controller (in cluster)
### Controller (in cluster)

Building a custom controller requires a Dockerhub (or similar) account. To build using the container based build:

Expand All @@ -95,7 +86,7 @@ kubectl apply -f operator/samples/default-install.yaml
This installs the controller into the cluster in the istio-operator namespace. The controller in turns installs
the Istio control plane into the istio-system namespace by default.

#### Controller (running locally)
### Controller (running locally)

1. Set env $WATCH_NAMESPACE (default value is "istio-system") and $LEADER_ELECTION_NAMESPACE (default value is "istio-operator")

Expand Down
5 changes: 1 addition & 4 deletions operator/cmd/mesh/operator-common.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ func isControllerInstalled(cs kubernetes.Interface, operatorNamespace string, re
// renderOperatorManifest renders a manifest to install the operator with the given input arguments.
func renderOperatorManifest(_ *rootArgs, ocArgs *operatorCommonArgs) (string, string, error) {
installPackagePath := ocArgs.manifestsPath
r, err := helm.NewHelmRenderer(installPackagePath, "istio-operator", string(name.IstioOperatorComponentName), ocArgs.operatorNamespace)
if err != nil {
return "", "", err
}
r := helm.NewHelmRenderer(installPackagePath, "istio-operator", string(name.IstioOperatorComponentName), ocArgs.operatorNamespace)

if err := r.Run(); err != nil {
return "", "", err
Expand Down
7 changes: 2 additions & 5 deletions operator/pkg/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,7 @@ func (c *EgressComponent) Enabled() bool {

// runComponent performs startup tasks for the component defined by the given CommonComponentFields.
func runComponent(c *CommonComponentFields) error {
r, err := createHelmRenderer(c)
if err != nil {
return err
}
r := createHelmRenderer(c)
if err := r.Run(); err != nil {
return err
}
Expand Down Expand Up @@ -472,7 +469,7 @@ func renderManifest(c IstioComponent, cf *CommonComponentFields) (string, error)

// createHelmRenderer creates a helm renderer for the component defined by c and returns a ptr to it.
// If a helm subdir is not found in ComponentMap translations, it is assumed to be "addon/<component name>.
func createHelmRenderer(c *CommonComponentFields) (helm.TemplateRenderer, error) {
func createHelmRenderer(c *CommonComponentFields) helm.TemplateRenderer {
iop := c.InstallSpec
cns := string(c.ComponentName)
helmSubdir := c.Translator.ComponentMap(cns).HelmSubdir
Expand Down
95 changes: 0 additions & 95 deletions operator/pkg/helm/fs_renderer.go

This file was deleted.

Loading

0 comments on commit bc5a0d2

Please sign in to comment.