Path: blob/main/install/installer/third_party/charts/charts.go
2499 views
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package charts56import (7"embed"8"io/fs"9"io/ioutil"10"os"11"path/filepath"12"strings"13)1415type Chart struct {16// Name of the Helm chart - this is free text, but should be the same as the chart name17Name string1819// The entire chart content20Content *embed.FS2122// Location is the location of the chart within the content23Location string2425// AdditionalFiles list files in the content filesystem that26// would be applied via "kubectl apply -f"27AdditionalFiles []string28}2930// Export writes the content of the chart to the dest location31func (c *Chart) Export(dest string) error {32return fs.WalkDir(c.Content, ".", func(path string, d fs.DirEntry, err error) error {33if !strings.HasPrefix(path, c.Location) {34return nil35}3637dst := filepath.Join(dest, strings.TrimPrefix(path, c.Location))38if d.IsDir() {39err := os.MkdirAll(dst, 0755)40if err != nil {41return err42}43} else {44fc, err := c.Content.ReadFile(path)45if err != nil {46return err47}48err = ioutil.WriteFile(dst, fc, 0644)49if err != nil {50return err51}52}5354return nil55})56}575859