-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow ValuesFile from GCS #9182
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,9 @@ package helm | |
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"path" | ||
"path/filepath" | ||
"runtime" | ||
"strconv" | ||
"strings" | ||
|
@@ -27,13 +30,19 @@ import ( | |
|
||
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/constants" | ||
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/docker" | ||
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/gcs" | ||
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/graph" | ||
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/output/log" | ||
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest" | ||
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util" | ||
maps "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util/map" | ||
) | ||
|
||
const ( | ||
gcsPrefix = "gs://" | ||
valueFileFromGCS = "valuefiles_from_gcs" | ||
) | ||
|
||
// ConstructOverrideArgs creates the command line arguments for overrides | ||
func ConstructOverrideArgs(r *latest.HelmRelease, builds []graph.Artifact, args []string, manifestOverrides map[string]string) ([]string, error) { | ||
for _, k := range maps.SortKeys(r.SetValues) { | ||
|
@@ -86,7 +95,25 @@ func ConstructOverrideArgs(r *latest.HelmRelease, builds []graph.Artifact, args | |
} | ||
|
||
for _, v := range r.ValuesFiles { | ||
exp, err := homedir.Expand(v) | ||
tempValueFile := v | ||
|
||
//if the file starts with gs:// then download it in tmp dir | ||
if strings.HasPrefix(v, gcsPrefix) { | ||
tempDir, err := os.MkdirTemp("", valueFileFromGCS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the condition's body can be extracted for better readability There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion, yes separated to the new function. |
||
if err != nil { | ||
return nil, fmt.Errorf("failed to create the tmp directory: %w", err) | ||
} | ||
|
||
//get a filename from gcs | ||
tempValueFile = filepath.Join(tempDir, path.Base(v)) | ||
|
||
gcs := gcs.Gsutil{} | ||
if err := gcs.Copy(context.Background(), v, tempValueFile, false); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated to |
||
return nil, fmt.Errorf("failed to copy valuesFile from GCS: %w", err) | ||
} | ||
} | ||
|
||
exp, err := homedir.Expand(tempValueFile) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to expand %q: %w", v, err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like it'll be better to contribute to the helm repository
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skaffold has already been integrated with GCP, so I thought to make the change here.