mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-25 17:11:48 +00:00
Use install pkg in CLI
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
parent
c4d3fa7a48
commit
5672646278
4 changed files with 73 additions and 304 deletions
|
|
@ -19,6 +19,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
@ -36,6 +37,8 @@ import (
|
||||||
|
|
||||||
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta1"
|
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta1"
|
||||||
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||||
|
|
||||||
|
"github.com/fluxcd/toolkit/pkg/install"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bootstrapCmd = &cobra.Command{
|
var bootstrapCmd = &cobra.Command{
|
||||||
|
|
@ -111,31 +114,36 @@ func generateInstallManifests(targetPath, namespace, tmpDir string, localManifes
|
||||||
if err := os.MkdirAll(manifestsDir, os.ModePerm); err != nil {
|
if err := os.MkdirAll(manifestsDir, os.ModePerm); err != nil {
|
||||||
return "", fmt.Errorf("creating manifests dir failed: %w", err)
|
return "", fmt.Errorf("creating manifests dir failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest := path.Join(manifestsDir, bootstrapInstallManifest)
|
manifest := path.Join(manifestsDir, bootstrapInstallManifest)
|
||||||
|
|
||||||
if localManifests != "" {
|
opts := install.Options{
|
||||||
if err := buildKustomization(localManifests, manifest); err != nil {
|
BaseURL: localManifests,
|
||||||
return "", fmt.Errorf("build kustomization failed: %w", err)
|
Version: bootstrapVersion,
|
||||||
}
|
Namespace: namespace,
|
||||||
|
Components: bootstrapComponents,
|
||||||
return manifest, nil
|
Registry: bootstrapRegistry,
|
||||||
|
ImagePullSecret: bootstrapImagePullSecret,
|
||||||
|
Arch: bootstrapArch,
|
||||||
|
WatchAllNamespaces: bootstrapWatchAllNamespaces,
|
||||||
|
NetworkPolicy: bootstrapNetworkPolicy,
|
||||||
|
LogLevel: bootstrapLogLevel,
|
||||||
|
NotificationController: defaultNotification,
|
||||||
|
ManifestsFile: fmt.Sprintf("%s.yaml", namespace),
|
||||||
|
Timeout: timeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
gotkDir := path.Join(tmpDir, ".gotk")
|
if localManifests == "" {
|
||||||
defer os.RemoveAll(gotkDir)
|
opts.BaseURL = install.MakeDefaultOptions().BaseURL
|
||||||
|
|
||||||
if err := os.MkdirAll(gotkDir, os.ModePerm); err != nil {
|
|
||||||
return "", fmt.Errorf("generating manifests failed: %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := genInstallManifests(bootstrapVersion, namespace, bootstrapComponents,
|
output, err := install.Generate(opts)
|
||||||
bootstrapWatchAllNamespaces, bootstrapNetworkPolicy, bootstrapRegistry, bootstrapImagePullSecret,
|
if err != nil {
|
||||||
bootstrapArch, bootstrapLogLevel, gotkDir); err != nil {
|
return "", fmt.Errorf("generating install manifests failed: %w", err)
|
||||||
return "", fmt.Errorf("generating manifests failed: %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := buildKustomization(gotkDir, manifest); err != nil {
|
if err := ioutil.WriteFile(manifest, output, os.ModePerm); err != nil {
|
||||||
return "", fmt.Errorf("build kustomization failed: %w", err)
|
return "", fmt.Errorf("generating install manifests failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return manifest, nil
|
return manifest, nil
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,13 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"sigs.k8s.io/kustomize/api/filesys"
|
|
||||||
"sigs.k8s.io/kustomize/api/krusty"
|
|
||||||
|
|
||||||
"github.com/fluxcd/pkg/untar"
|
"github.com/fluxcd/toolkit/pkg/install"
|
||||||
)
|
)
|
||||||
|
|
||||||
var installCmd = &cobra.Command{
|
var installCmd = &cobra.Command{
|
||||||
|
|
@ -114,38 +109,50 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
if !installExport {
|
if !installExport {
|
||||||
logger.Generatef("generating manifests")
|
logger.Generatef("generating manifests")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opts := install.Options{
|
||||||
|
BaseURL: installManifestsPath,
|
||||||
|
Version: installVersion,
|
||||||
|
Namespace: namespace,
|
||||||
|
Components: installComponents,
|
||||||
|
Registry: installRegistry,
|
||||||
|
ImagePullSecret: installImagePullSecret,
|
||||||
|
Arch: installArch,
|
||||||
|
WatchAllNamespaces: installWatchAllNamespaces,
|
||||||
|
NetworkPolicy: installNetworkPolicy,
|
||||||
|
LogLevel: installLogLevel,
|
||||||
|
NotificationController: defaultNotification,
|
||||||
|
ManifestsFile: fmt.Sprintf("%s.yaml", namespace),
|
||||||
|
Timeout: timeout,
|
||||||
|
}
|
||||||
|
|
||||||
if installManifestsPath == "" {
|
if installManifestsPath == "" {
|
||||||
err = genInstallManifests(installVersion, namespace, installComponents,
|
opts.BaseURL = install.MakeDefaultOptions().BaseURL
|
||||||
installWatchAllNamespaces, installNetworkPolicy, installRegistry, installImagePullSecret,
|
}
|
||||||
installArch, installLogLevel, tmpDir)
|
|
||||||
if err != nil {
|
output, err := install.Generate(opts)
|
||||||
return fmt.Errorf("install failed: %w", err)
|
if err != nil {
|
||||||
}
|
return fmt.Errorf("install failed: %w", err)
|
||||||
installManifestsPath = tmpDir
|
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest := path.Join(tmpDir, fmt.Sprintf("%s.yaml", namespace))
|
manifest := path.Join(tmpDir, fmt.Sprintf("%s.yaml", namespace))
|
||||||
if err := buildKustomization(installManifestsPath, manifest); err != nil {
|
if err := ioutil.WriteFile(manifest, output, os.ModePerm); err != nil {
|
||||||
return fmt.Errorf("install failed: %w", err)
|
return fmt.Errorf("install failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
command := fmt.Sprintf("cat %s", manifest)
|
yaml := string(output)
|
||||||
if yaml, err := utils.execCommand(ctx, ModeCapture, command); err != nil {
|
if verbose {
|
||||||
return fmt.Errorf("install failed: %w", err)
|
fmt.Print(yaml)
|
||||||
} else {
|
} else if installExport {
|
||||||
if verbose {
|
fmt.Println("---")
|
||||||
fmt.Print(yaml)
|
fmt.Println("# GitOps Toolkit revision", installVersion)
|
||||||
} else if installExport {
|
fmt.Println("# Components:", strings.Join(installComponents, ","))
|
||||||
fmt.Println("---")
|
fmt.Print(yaml)
|
||||||
fmt.Println("# GitOps Toolkit revision", installVersion, time.Now().Format(time.RFC3339))
|
fmt.Println("---")
|
||||||
fmt.Println("# Components:", strings.Join(installComponents, ","))
|
return nil
|
||||||
fmt.Print(yaml)
|
|
||||||
fmt.Println("---")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Successf("manifests build completed")
|
logger.Successf("manifests build completed")
|
||||||
|
|
||||||
logger.Actionf("installing components in %s namespace", namespace)
|
logger.Actionf("installing components in %s namespace", namespace)
|
||||||
applyOutput := ModeStderrOS
|
applyOutput := ModeStderrOS
|
||||||
if verbose {
|
if verbose {
|
||||||
|
|
@ -156,7 +163,8 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
dryRun = "--dry-run=client"
|
dryRun = "--dry-run=client"
|
||||||
applyOutput = ModeOS
|
applyOutput = ModeOS
|
||||||
}
|
}
|
||||||
command = fmt.Sprintf("cat %s | kubectl apply -f- %s", manifest, dryRun)
|
|
||||||
|
command := fmt.Sprintf("kubectl apply -f %s %s", manifest, dryRun)
|
||||||
if _, err := utils.execCommand(ctx, applyOutput, command); err != nil {
|
if _, err := utils.execCommand(ctx, applyOutput, command); err != nil {
|
||||||
return fmt.Errorf("install failed")
|
return fmt.Errorf("install failed")
|
||||||
}
|
}
|
||||||
|
|
@ -182,250 +190,3 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
logger.Successf("install finished")
|
logger.Successf("install finished")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var namespaceTmpl = `---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Namespace
|
|
||||||
metadata:
|
|
||||||
name: {{.Namespace}}
|
|
||||||
`
|
|
||||||
|
|
||||||
var labelsTmpl = `---
|
|
||||||
apiVersion: builtin
|
|
||||||
kind: LabelTransformer
|
|
||||||
metadata:
|
|
||||||
name: labels
|
|
||||||
labels:
|
|
||||||
app.kubernetes.io/instance: {{.Namespace}}
|
|
||||||
app.kubernetes.io/version: "{{.Version}}"
|
|
||||||
fieldSpecs:
|
|
||||||
- path: metadata/labels
|
|
||||||
create: true
|
|
||||||
`
|
|
||||||
|
|
||||||
var kustomizationTmpl = `---
|
|
||||||
{{- $eventsAddr := .EventsAddr }}
|
|
||||||
{{- $watchAllNamespaces := .WatchAllNamespaces }}
|
|
||||||
{{- $registry := .Registry }}
|
|
||||||
{{- $arch := .Arch }}
|
|
||||||
{{- $logLevel := .LogLevel }}
|
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
namespace: {{.Namespace}}
|
|
||||||
|
|
||||||
transformers:
|
|
||||||
- labels.yaml
|
|
||||||
|
|
||||||
resources:
|
|
||||||
- namespace.yaml
|
|
||||||
{{- if .NetworkPolicy }}
|
|
||||||
- policies.yaml
|
|
||||||
{{- end }}
|
|
||||||
- roles
|
|
||||||
{{- range .Components }}
|
|
||||||
- {{.}}.yaml
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
patches:
|
|
||||||
- path: node-selector.yaml
|
|
||||||
target:
|
|
||||||
kind: Deployment
|
|
||||||
|
|
||||||
patchesJson6902:
|
|
||||||
{{- range $i, $component := .Components }}
|
|
||||||
{{- if eq $component "notification-controller" }}
|
|
||||||
- target:
|
|
||||||
group: apps
|
|
||||||
version: v1
|
|
||||||
kind: Deployment
|
|
||||||
name: {{$component}}
|
|
||||||
patch: |-
|
|
||||||
- op: replace
|
|
||||||
path: /spec/template/spec/containers/0/args/0
|
|
||||||
value: --watch-all-namespaces={{$watchAllNamespaces}}
|
|
||||||
- op: replace
|
|
||||||
path: /spec/template/spec/containers/0/args/1
|
|
||||||
value: --log-level={{$logLevel}}
|
|
||||||
{{- else }}
|
|
||||||
- target:
|
|
||||||
group: apps
|
|
||||||
version: v1
|
|
||||||
kind: Deployment
|
|
||||||
name: {{$component}}
|
|
||||||
patch: |-
|
|
||||||
- op: replace
|
|
||||||
path: /spec/template/spec/containers/0/args/0
|
|
||||||
value: --events-addr={{$eventsAddr}}
|
|
||||||
- op: replace
|
|
||||||
path: /spec/template/spec/containers/0/args/1
|
|
||||||
value: --watch-all-namespaces={{$watchAllNamespaces}}
|
|
||||||
- op: replace
|
|
||||||
path: /spec/template/spec/containers/0/args/2
|
|
||||||
value: --log-level={{$logLevel}}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
{{- if $registry }}
|
|
||||||
images:
|
|
||||||
{{- range $i, $component := .Components }}
|
|
||||||
- name: fluxcd/{{$component}}
|
|
||||||
{{- if eq $arch "amd64" }}
|
|
||||||
newName: {{$registry}}/{{$component}}
|
|
||||||
{{- else }}
|
|
||||||
newName: {{$registry}}/{{$component}}-arm64
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
`
|
|
||||||
|
|
||||||
var kustomizationRolesTmpl = `---
|
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
resources:
|
|
||||||
- rbac.yaml
|
|
||||||
nameSuffix: -{{.Namespace}}
|
|
||||||
`
|
|
||||||
|
|
||||||
var nodeSelectorTmpl = `---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: all
|
|
||||||
spec:
|
|
||||||
template:
|
|
||||||
spec:
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/arch: {{.Arch}}
|
|
||||||
kubernetes.io/os: linux
|
|
||||||
{{- if .ImagePullSecret }}
|
|
||||||
imagePullSecrets:
|
|
||||||
- name: {{.ImagePullSecret}}
|
|
||||||
{{- end }}
|
|
||||||
`
|
|
||||||
|
|
||||||
func downloadManifests(version string, tmpDir string) error {
|
|
||||||
ghURL := "https://github.com/fluxcd/toolkit/releases/latest/download/manifests.tar.gz"
|
|
||||||
if strings.HasPrefix(version, "v") {
|
|
||||||
ghURL = fmt.Sprintf("https://github.com/fluxcd/toolkit/releases/download/%s/manifests.tar.gz", version)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", ghURL, nil)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to create HTTP request for %s, error: %w", ghURL, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// download
|
|
||||||
resp, err := http.DefaultClient.Do(req.WithContext(ctx))
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to download artifact from %s, error: %w", ghURL, err)
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
// check response
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
return fmt.Errorf("faild to download artifact from %s, status: %s", ghURL, resp.Status)
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract
|
|
||||||
if _, err = untar.Untar(resp.Body, tmpDir); err != nil {
|
|
||||||
return fmt.Errorf("faild to untar manifests from %s, error: %w", ghURL, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func genInstallManifests(version string, namespace string, components []string,
|
|
||||||
watchAllNamespaces, networkPolicy bool, registry, imagePullSecret, arch, logLevel, tmpDir string) error {
|
|
||||||
eventsAddr := ""
|
|
||||||
if utils.containsItemString(components, defaultNotification) {
|
|
||||||
eventsAddr = fmt.Sprintf("http://%s/", defaultNotification)
|
|
||||||
}
|
|
||||||
|
|
||||||
model := struct {
|
|
||||||
Version string
|
|
||||||
Namespace string
|
|
||||||
Components []string
|
|
||||||
EventsAddr string
|
|
||||||
Registry string
|
|
||||||
ImagePullSecret string
|
|
||||||
Arch string
|
|
||||||
WatchAllNamespaces bool
|
|
||||||
NetworkPolicy bool
|
|
||||||
LogLevel string
|
|
||||||
}{
|
|
||||||
Version: version,
|
|
||||||
Namespace: namespace,
|
|
||||||
Components: components,
|
|
||||||
EventsAddr: eventsAddr,
|
|
||||||
Registry: registry,
|
|
||||||
ImagePullSecret: imagePullSecret,
|
|
||||||
Arch: arch,
|
|
||||||
WatchAllNamespaces: watchAllNamespaces,
|
|
||||||
NetworkPolicy: networkPolicy,
|
|
||||||
LogLevel: logLevel,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := downloadManifests(version, tmpDir); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.execTemplate(model, namespaceTmpl, path.Join(tmpDir, "namespace.yaml")); err != nil {
|
|
||||||
return fmt.Errorf("generate namespace failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.execTemplate(model, labelsTmpl, path.Join(tmpDir, "labels.yaml")); err != nil {
|
|
||||||
return fmt.Errorf("generate labels failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.execTemplate(model, nodeSelectorTmpl, path.Join(tmpDir, "node-selector.yaml")); err != nil {
|
|
||||||
return fmt.Errorf("generate node selector failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.execTemplate(model, kustomizationTmpl, path.Join(tmpDir, "kustomization.yaml")); err != nil {
|
|
||||||
return fmt.Errorf("generate kustomization failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.MkdirAll(path.Join(tmpDir, "roles"), os.ModePerm); err != nil {
|
|
||||||
return fmt.Errorf("generate roles failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.execTemplate(model, kustomizationRolesTmpl, path.Join(tmpDir, "roles/kustomization.yaml")); err != nil {
|
|
||||||
return fmt.Errorf("generate roles failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.copyFile(filepath.Join(tmpDir, "rbac.yaml"), filepath.Join(tmpDir, "roles/rbac.yaml")); err != nil {
|
|
||||||
return fmt.Errorf("generate rbac failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func buildKustomization(base, manifests string) error {
|
|
||||||
kfile := filepath.Join(base, "kustomization.yaml")
|
|
||||||
|
|
||||||
fs := filesys.MakeFsOnDisk()
|
|
||||||
if !fs.Exists(kfile) {
|
|
||||||
return fmt.Errorf("%s not found", kfile)
|
|
||||||
}
|
|
||||||
|
|
||||||
opt := krusty.MakeDefaultOptions()
|
|
||||||
k := krusty.MakeKustomizer(fs, opt)
|
|
||||||
m, err := k.Run(base)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
resources, err := m.AsYaml()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := fs.WriteFile(manifests, resources); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,13 @@ import (
|
||||||
// Generate returns the install manifests as a multi-doc YAML.
|
// Generate returns the install manifests as a multi-doc YAML.
|
||||||
// The manifests are built from a GitHub release or from a
|
// The manifests are built from a GitHub release or from a
|
||||||
// Kustomize overlay if the supplied Options.BaseURL is a local path.
|
// Kustomize overlay if the supplied Options.BaseURL is a local path.
|
||||||
func Generate(options Options) (string, error) {
|
func Generate(options Options) ([]byte, error) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), options.Timeout)
|
ctx, cancel := context.WithTimeout(context.Background(), options.Timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
tmpDir, err := ioutil.TempDir("", options.Namespace)
|
tmpDir, err := ioutil.TempDir("", options.Namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("temp dir error: %w", err)
|
return nil, fmt.Errorf("temp dir error: %w", err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
|
@ -42,26 +42,26 @@ func Generate(options Options) (string, error) {
|
||||||
|
|
||||||
if !strings.HasPrefix(options.BaseURL, "http") {
|
if !strings.HasPrefix(options.BaseURL, "http") {
|
||||||
if err := build(options.BaseURL, output); err != nil {
|
if err := build(options.BaseURL, output); err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := fetch(ctx, options.BaseURL, options.Version, tmpDir); err != nil {
|
if err := fetch(ctx, options.BaseURL, options.Version, tmpDir); err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := generate(tmpDir, options); err != nil {
|
if err := generate(tmpDir, options); err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := build(tmpDir, output); err != nil {
|
if err := build(tmpDir, output); err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content, err := ioutil.ReadFile(output)
|
content, err := ioutil.ReadFile(output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(content), nil
|
return content, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ func TestGenerate(t *testing.T) {
|
||||||
|
|
||||||
for _, component := range opts.Components {
|
for _, component := range opts.Components {
|
||||||
img := fmt.Sprintf("%s/%s", opts.Registry, component)
|
img := fmt.Sprintf("%s/%s", opts.Registry, component)
|
||||||
if !strings.Contains(output, img) {
|
if !strings.Contains(string(output), img) {
|
||||||
t.Errorf("component image '%s' not found", img)
|
t.Errorf("component image '%s' not found", img)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(output)
|
fmt.Println(string(output))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue