Compare commits
63 Commits
release/v2
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f02db7ed08 | ||
|
|
9b76ba19a8 | ||
|
|
1e7dd5dfd8 | ||
|
|
d6dec730d8 | ||
|
|
0ba28f3f91 | ||
|
|
55936e9366 | ||
|
|
6ecad4783f | ||
|
|
5759d08473 | ||
|
|
5048de80f0 | ||
|
|
97a437d059 | ||
|
|
cfb28ffdc0 | ||
|
|
ae9ef62f39 | ||
|
|
69feb7214a | ||
|
|
e95da82f5a | ||
|
|
7c5f9befb4 | ||
|
|
26a8d0c1c7 | ||
|
|
833815c71d | ||
|
|
31287b9b27 | ||
|
|
28f5b553a2 | ||
|
|
b33f173670 | ||
|
|
d8c6ee167c | ||
|
|
e288cb2771 | ||
|
|
5f2a6ebc2b | ||
|
|
cdc37c304a | ||
|
|
60e4d99b57 | ||
|
|
8229ffb674 | ||
|
|
9b944da896 | ||
|
|
5b37a6b04b | ||
|
|
9f18062d43 | ||
|
|
1055f28524 | ||
|
|
7b0021c1a8 | ||
|
|
ba997449aa | ||
|
|
ca2f0205c4 | ||
|
|
058525fe37 | ||
|
|
686ee31f8a | ||
|
|
767f235f94 | ||
|
|
d5a2c66746 | ||
|
|
f2ff083b8e | ||
|
|
8c45f25f33 | ||
|
|
f85cbfa9c8 | ||
|
|
71a3dad213 | ||
|
|
72e0535958 | ||
|
|
4f2d1c3a2a | ||
|
|
8e99cf7c93 | ||
|
|
2bb7f38603 | ||
|
|
0fe4449870 | ||
|
|
7c5fb2297c | ||
|
|
f4a811fbd3 | ||
|
|
bb3726bb87 | ||
|
|
333c8fe704 | ||
|
|
83213ce83f | ||
|
|
69718599ac | ||
|
|
0255957dd7 | ||
|
|
69b4b85cd9 | ||
|
|
a9b5be7ff4 | ||
|
|
1b46056e7d | ||
|
|
039d79b3c2 | ||
|
|
66b8aca399 | ||
|
|
41c413e178 | ||
|
|
d5f8720c4d | ||
|
|
e6eb9d79e3 | ||
|
|
b90d1738a9 | ||
|
|
f9e66dee9e |
6
.github/labels.yaml
vendored
6
.github/labels.yaml
vendored
@@ -44,12 +44,12 @@
|
||||
description: Feature request proposals in the RFC format
|
||||
color: '#D621C3'
|
||||
aliases: ['area/RFC']
|
||||
- name: backport:release/v2.4.x
|
||||
description: To be backported to release/v2.4.x
|
||||
color: '#ffd700'
|
||||
- name: backport:release/v2.5.x
|
||||
description: To be backported to release/v2.5.x
|
||||
color: '#ffd700'
|
||||
- name: backport:release/v2.6.x
|
||||
description: To be backported to release/v2.6.x
|
||||
color: '#ffd700'
|
||||
- name: backport:release/v2.7.x
|
||||
description: To be backported to release/v2.7.x
|
||||
color: '#ffd700'
|
||||
|
||||
2
.github/workflows/backport.yaml
vendored
2
.github/workflows/backport.yaml
vendored
@@ -10,4 +10,4 @@ jobs:
|
||||
pull-requests: write # for creating pull requests against release branches.
|
||||
uses: fluxcd/gha-workflows/.github/workflows/backport.yaml@v0.4.0
|
||||
secrets:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||
|
||||
@@ -49,7 +49,8 @@ you might want to take a look at the [introductory talk and demo](https://www.yo
|
||||
This project is composed of:
|
||||
|
||||
- [flux2](https://github.com/fluxcd/flux2): The Flux CLI
|
||||
- [source-manager](https://github.com/fluxcd/source-controller): Kubernetes operator for managing sources (Git and Helm repositories, S3-compatible Buckets)
|
||||
- [source-controller](https://github.com/fluxcd/source-controller): Kubernetes operator for managing sources (Git, OCI and Helm repositories, S3-compatible Buckets)
|
||||
- [source-watcher](https://github.com/fluxcd/source-watcher): Kubernetes operator for advanced source composition and decomposition patterns
|
||||
- [kustomize-controller](https://github.com/fluxcd/kustomize-controller): Kubernetes operator for building GitOps pipelines with Kustomize
|
||||
- [helm-controller](https://github.com/fluxcd/helm-controller): Kubernetes operator for building GitOps pipelines with Helm
|
||||
- [notification-controller](https://github.com/fluxcd/notification-controller): Kubernetes operator for handling inbound and outbound events
|
||||
@@ -67,10 +68,9 @@ for source changes.
|
||||
|
||||
Prerequisites:
|
||||
|
||||
* go >= 1.24
|
||||
* go >= 1.25
|
||||
* kubectl >= 1.30
|
||||
* kustomize >= 5.0
|
||||
* coreutils (on Mac OS)
|
||||
|
||||
Install the [controller-runtime/envtest](https://github.com/kubernetes-sigs/controller-runtime/tree/master/tools/setup-envtest) binaries with:
|
||||
|
||||
|
||||
@@ -52,12 +52,14 @@ guides](https://fluxcd.io/flux/gitops-toolkit/source-watcher/).
|
||||
|
||||
### Components
|
||||
|
||||
- [Source Controller](https://fluxcd.io/flux/components/source/)
|
||||
- [Source Controllers](https://fluxcd.io/flux/components/source/)
|
||||
- [GitRepository CRD](https://fluxcd.io/flux/components/source/gitrepositories/)
|
||||
- [OCIRepository CRD](https://fluxcd.io/flux/components/source/ocirepositories/)
|
||||
- [HelmRepository CRD](https://fluxcd.io/flux/components/source/helmrepositories/)
|
||||
- [HelmChart CRD](https://fluxcd.io/flux/components/source/helmcharts/)
|
||||
- [Bucket CRD](https://fluxcd.io/flux/components/source/buckets/)
|
||||
- [ExternalArtifact CRD](https://fluxcd.io/flux/components/source/externalartifacts/)
|
||||
- [ArtifactGenerator CRD](https://fluxcd.io/flux/components/source/artifactgenerators/)
|
||||
- [Kustomize Controller](https://fluxcd.io/flux/components/kustomize/)
|
||||
- [Kustomization CRD](https://fluxcd.io/flux/components/kustomize/kustomizations/)
|
||||
- [Helm Controller](https://fluxcd.io/flux/components/helm/)
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -98,13 +97,6 @@ func buildKsCmdRun(cmd *cobra.Command, args []string) (err error) {
|
||||
return fmt.Errorf("invalid resource path %q", buildKsArgs.path)
|
||||
}
|
||||
|
||||
// Normalize the path to handle Windows absolute and relative paths correctly
|
||||
buildKsArgs.path, err = filepath.Abs(buildKsArgs.path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to resolve absolute path: %w", err)
|
||||
}
|
||||
buildKsArgs.path = filepath.Clean(buildKsArgs.path)
|
||||
|
||||
if fs, err := os.Stat(buildKsArgs.path); err != nil || !fs.IsDir() {
|
||||
return fmt.Errorf("invalid resource path %q", buildKsArgs.path)
|
||||
}
|
||||
|
||||
@@ -218,65 +218,3 @@ spec:
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestBuildKustomizationPathNormalization verifies that absolute and complex
|
||||
// paths are normalized to prevent path concatenation bugs (issue #5673).
|
||||
// Without normalization, paths could be duplicated like: /path/test/path/test/file
|
||||
func TestBuildKustomizationPathNormalization(t *testing.T) {
|
||||
// Get absolute path to testdata to test absolute path handling
|
||||
absTestDataPath, err := filepath.Abs("testdata/build-kustomization/podinfo")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get absolute path: %v", err)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args string
|
||||
resultFile string
|
||||
assertFunc string
|
||||
}{
|
||||
{
|
||||
name: "build with absolute path",
|
||||
args: "build kustomization podinfo --path " + absTestDataPath,
|
||||
resultFile: "./testdata/build-kustomization/podinfo-result.yaml",
|
||||
assertFunc: "assertGoldenTemplateFile",
|
||||
},
|
||||
{
|
||||
name: "build with complex relative path (parent dir)",
|
||||
args: "build kustomization podinfo --path ./testdata/build-kustomization/../build-kustomization/podinfo",
|
||||
resultFile: "./testdata/build-kustomization/podinfo-result.yaml",
|
||||
assertFunc: "assertGoldenTemplateFile",
|
||||
},
|
||||
{
|
||||
name: "build with path containing redundant separators",
|
||||
args: "build kustomization podinfo --path ./testdata//build-kustomization//podinfo",
|
||||
resultFile: "./testdata/build-kustomization/podinfo-result.yaml",
|
||||
assertFunc: "assertGoldenTemplateFile",
|
||||
},
|
||||
}
|
||||
|
||||
tmpl := map[string]string{
|
||||
"fluxns": allocateNamespace("flux-system"),
|
||||
}
|
||||
setup(t, tmpl)
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var assert assertFunc
|
||||
|
||||
switch tt.assertFunc {
|
||||
case "assertGoldenTemplateFile":
|
||||
assert = assertGoldenTemplateFile(tt.resultFile, tmpl)
|
||||
case "assertError":
|
||||
assert = assertError(tt.resultFile)
|
||||
}
|
||||
|
||||
cmd := cmdTestCase{
|
||||
args: tt.args + " -n " + tmpl["fluxns"],
|
||||
assert: assert,
|
||||
}
|
||||
|
||||
cmd.runTestCmd(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,10 +182,6 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
|
||||
return fmt.Errorf("chart or chart-ref is required")
|
||||
}
|
||||
|
||||
if helmReleaseArgs.chart != "" && helmReleaseArgs.chartRef != "" {
|
||||
return fmt.Errorf("cannot use --chart in combination with --chart-ref")
|
||||
}
|
||||
|
||||
sourceLabels, err := parseLabels()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -42,11 +42,6 @@ func TestCreateHelmRelease(t *testing.T) {
|
||||
args: "create helmrelease podinfo --export",
|
||||
assert: assertError("chart or chart-ref is required"),
|
||||
},
|
||||
{
|
||||
name: "chart and chartRef used in combination",
|
||||
args: "create helmrelease podinfo --chart podinfo --chart-ref foobar/podinfo --export",
|
||||
assert: assertError("cannot use --chart in combination with --chart-ref"),
|
||||
},
|
||||
{
|
||||
name: "unknown source kind",
|
||||
args: "create helmrelease podinfo --source foobar/podinfo --chart podinfo --export",
|
||||
|
||||
84
cmd/flux/export_source_external.go
Normal file
84
cmd/flux/export_source_external.go
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright 2025 The Flux 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 main
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
||||
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
||||
)
|
||||
|
||||
var exportSourceExternalCmd = &cobra.Command{
|
||||
Use: "external [name]",
|
||||
Short: "Export ExternalArtifact sources in YAML format",
|
||||
Long: "The export source external command exports one or all ExternalArtifact sources in YAML format.",
|
||||
Example: ` # Export all ExternalArtifact sources
|
||||
flux export source external --all > sources.yaml
|
||||
|
||||
# Export a specific ExternalArtifact
|
||||
flux export source external my-artifact > source.yaml`,
|
||||
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.ExternalArtifactKind)),
|
||||
RunE: exportWithSecretCommand{
|
||||
list: externalArtifactListAdapter{&sourcev1.ExternalArtifactList{}},
|
||||
object: externalArtifactAdapter{&sourcev1.ExternalArtifact{}},
|
||||
}.run,
|
||||
}
|
||||
|
||||
func init() {
|
||||
exportSourceCmd.AddCommand(exportSourceExternalCmd)
|
||||
}
|
||||
|
||||
func exportExternalArtifact(source *sourcev1.ExternalArtifact) any {
|
||||
gvk := sourcev1.GroupVersion.WithKind(sourcev1.ExternalArtifactKind)
|
||||
export := sourcev1.ExternalArtifact{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: gvk.Kind,
|
||||
APIVersion: gvk.GroupVersion().String(),
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: source.Name,
|
||||
Namespace: source.Namespace,
|
||||
Labels: source.Labels,
|
||||
Annotations: source.Annotations,
|
||||
},
|
||||
Spec: source.Spec,
|
||||
}
|
||||
return export
|
||||
}
|
||||
|
||||
func getExternalArtifactSecret(source *sourcev1.ExternalArtifact) *types.NamespacedName {
|
||||
// ExternalArtifact does not have a secretRef in its spec, this satisfies the interface
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ex externalArtifactAdapter) secret() *types.NamespacedName {
|
||||
return getExternalArtifactSecret(ex.ExternalArtifact)
|
||||
}
|
||||
|
||||
func (ex externalArtifactListAdapter) secretItem(i int) *types.NamespacedName {
|
||||
return getExternalArtifactSecret(&ex.ExternalArtifactList.Items[i])
|
||||
}
|
||||
|
||||
func (ex externalArtifactAdapter) export() any {
|
||||
return exportExternalArtifact(ex.ExternalArtifact)
|
||||
}
|
||||
|
||||
func (ex externalArtifactListAdapter) exportItem(i int) any {
|
||||
return exportExternalArtifact(&ex.ExternalArtifactList.Items[i])
|
||||
}
|
||||
@@ -110,6 +110,12 @@ func TestExport(t *testing.T) {
|
||||
"testdata/export/bucket.yaml",
|
||||
tmpl,
|
||||
},
|
||||
{
|
||||
"source external",
|
||||
"export source external flux-system",
|
||||
"testdata/export/external-artifact.yaml",
|
||||
tmpl,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range cases {
|
||||
|
||||
@@ -59,6 +59,10 @@ var getSourceAllCmd = &cobra.Command{
|
||||
apiType: helmChartType,
|
||||
list: &helmChartListAdapter{&sourcev1.HelmChartList{}},
|
||||
},
|
||||
{
|
||||
apiType: externalArtifactType,
|
||||
list: &externalArtifactListAdapter{&sourcev1.ExternalArtifactList{}},
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range allSourceCmd {
|
||||
|
||||
108
cmd/flux/get_source_external.go
Normal file
108
cmd/flux/get_source_external.go
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
Copyright 2025 The Flux 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 main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
||||
|
||||
"github.com/fluxcd/flux2/v2/internal/utils"
|
||||
)
|
||||
|
||||
var getSourceExternalCmd = &cobra.Command{
|
||||
Use: "external",
|
||||
Short: "Get ExternalArtifact source statuses",
|
||||
Long: `The get sources external command prints the status of the ExternalArtifact sources.`,
|
||||
Example: ` # List all ExternalArtifacts and their status
|
||||
flux get sources external
|
||||
|
||||
# List ExternalArtifacts from all namespaces
|
||||
flux get sources external --all-namespaces`,
|
||||
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.ExternalArtifactKind)),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
get := getCommand{
|
||||
apiType: externalArtifactType,
|
||||
list: &externalArtifactListAdapter{&sourcev1.ExternalArtifactList{}},
|
||||
funcMap: make(typeMap),
|
||||
}
|
||||
|
||||
err := get.funcMap.registerCommand(get.apiType.kind, func(obj runtime.Object) (summarisable, error) {
|
||||
o, ok := obj.(*sourcev1.ExternalArtifact)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("impossible to cast type %#v to ExternalArtifact", obj)
|
||||
}
|
||||
|
||||
sink := &externalArtifactListAdapter{&sourcev1.ExternalArtifactList{
|
||||
Items: []sourcev1.ExternalArtifact{
|
||||
*o,
|
||||
}}}
|
||||
return sink, nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := get.run(cmd, args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
getSourceCmd.AddCommand(getSourceExternalCmd)
|
||||
}
|
||||
|
||||
func (a *externalArtifactListAdapter) summariseItem(i int, includeNamespace bool, includeKind bool) []string {
|
||||
item := a.Items[i]
|
||||
var revision string
|
||||
if item.Status.Artifact != nil {
|
||||
revision = item.Status.Artifact.Revision
|
||||
}
|
||||
status, msg := statusAndMessage(item.Status.Conditions)
|
||||
revision = utils.TruncateHex(revision)
|
||||
msg = utils.TruncateHex(msg)
|
||||
|
||||
var source string
|
||||
if item.Spec.SourceRef != nil {
|
||||
source = fmt.Sprintf("%s/%s/%s",
|
||||
item.Spec.SourceRef.Kind,
|
||||
item.Spec.SourceRef.Namespace,
|
||||
item.Spec.SourceRef.Name)
|
||||
}
|
||||
return append(nameColumns(&item, includeNamespace, includeKind),
|
||||
revision, source, status, msg)
|
||||
}
|
||||
|
||||
func (a externalArtifactListAdapter) headers(includeNamespace bool) []string {
|
||||
headers := []string{"Name", "Revision", "Source", "Ready", "Message"}
|
||||
if includeNamespace {
|
||||
headers = append([]string{"Namespace"}, headers...)
|
||||
}
|
||||
return headers
|
||||
}
|
||||
|
||||
func (a externalArtifactListAdapter) statusSelectorMatches(i int, conditionType, conditionStatus string) bool {
|
||||
item := a.Items[i]
|
||||
return statusMatches(conditionType, conditionStatus, item.Status.Conditions)
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func main() {
|
||||
|
||||
// This is required because controller-runtime expects its consumers to
|
||||
// set a logger through log.SetLogger within 30 seconds of the program's
|
||||
// initalization. If not set, the entire debug stack is printed as an
|
||||
// initialization. If not set, the entire debug stack is printed as an
|
||||
// error, see: https://github.com/kubernetes-sigs/controller-runtime/blob/ed8be90/pkg/log/log.go#L59
|
||||
// Since we have our own logging and don't care about controller-runtime's
|
||||
// logger, we configure it's logger to do nothing.
|
||||
@@ -225,7 +225,9 @@ func configureDefaultNamespace() {
|
||||
func readPasswordFromStdin(prompt string) (string, error) {
|
||||
var out string
|
||||
var err error
|
||||
fmt.Fprint(os.Stdout, prompt)
|
||||
if _, err := fmt.Fprint(os.Stdout, prompt); err != nil {
|
||||
return "", fmt.Errorf("failed to write prompt: %w", err)
|
||||
}
|
||||
stdinFD := int(os.Stdin.Fd())
|
||||
if term.IsTerminal(stdinFD) {
|
||||
var inBytes []byte
|
||||
|
||||
@@ -195,3 +195,37 @@ func (a helmRepositoryListAdapter) asClientList() client.ObjectList {
|
||||
func (a helmRepositoryListAdapter) len() int {
|
||||
return len(a.HelmRepositoryList.Items)
|
||||
}
|
||||
|
||||
// sourcev1.ExternalArtifact
|
||||
|
||||
var externalArtifactType = apiType{
|
||||
kind: sourcev1.ExternalArtifactKind,
|
||||
humanKind: "source external-artifact",
|
||||
groupVersion: sourcev1.GroupVersion,
|
||||
}
|
||||
|
||||
type externalArtifactAdapter struct {
|
||||
*sourcev1.ExternalArtifact
|
||||
}
|
||||
|
||||
func (a externalArtifactAdapter) asClientObject() client.Object {
|
||||
return a.ExternalArtifact
|
||||
}
|
||||
|
||||
func (a externalArtifactAdapter) deepCopyClientObject() client.Object {
|
||||
return a.ExternalArtifact.DeepCopy()
|
||||
}
|
||||
|
||||
// sourcev1.ExternalArtifactList
|
||||
|
||||
type externalArtifactListAdapter struct {
|
||||
*sourcev1.ExternalArtifactList
|
||||
}
|
||||
|
||||
func (a externalArtifactListAdapter) asClientList() client.ObjectList {
|
||||
return a.ExternalArtifactList
|
||||
}
|
||||
|
||||
func (a externalArtifactListAdapter) len() int {
|
||||
return len(a.ExternalArtifactList.Items)
|
||||
}
|
||||
|
||||
12
cmd/flux/testdata/export/external-artifact.yaml
vendored
Normal file
12
cmd/flux/testdata/export/external-artifact.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1
|
||||
kind: ExternalArtifact
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
sourceRef:
|
||||
apiVersion: source.example.com/v1alpha1
|
||||
kind: GitHubRelease
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
12
cmd/flux/testdata/export/objects.yaml
vendored
12
cmd/flux/testdata/export/objects.yaml
vendored
@@ -165,3 +165,15 @@ spec:
|
||||
endpoint: s3.amazonaws.com
|
||||
region: us-east-1
|
||||
timeout: 30s
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1
|
||||
kind: ExternalArtifact
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
sourceRef:
|
||||
apiVersion: source.example.com/v1alpha1
|
||||
kind: GitHubRelease
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
|
||||
2
go.mod
2
go.mod
@@ -51,7 +51,7 @@ require (
|
||||
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
|
||||
github.com/spf13/cobra v1.10.1
|
||||
github.com/theckman/yacspin v0.13.12
|
||||
golang.org/x/crypto v0.44.0
|
||||
golang.org/x/crypto v0.45.0
|
||||
golang.org/x/term v0.37.0
|
||||
golang.org/x/text v0.31.0
|
||||
k8s.io/api v0.34.2
|
||||
|
||||
4
go.sum
4
go.sum
@@ -645,8 +645,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU=
|
||||
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
|
||||
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
|
||||
@@ -520,30 +520,32 @@ func (b *Builder) do(ctx context.Context, kustomization kustomizev1.Kustomizatio
|
||||
return nil, fmt.Errorf("kustomize build failed: %w", err)
|
||||
}
|
||||
|
||||
if kustomization.Spec.PostBuild == nil {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
data, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&kustomization)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, res := range m.Resources() {
|
||||
// run variable substitutions
|
||||
if kustomization.Spec.PostBuild != nil {
|
||||
data, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&kustomization)
|
||||
outRes, err := kustomize.SubstituteVariables(ctx,
|
||||
b.client,
|
||||
unstructured.Unstructured{Object: data},
|
||||
res,
|
||||
kustomize.SubstituteWithDryRun(b.dryRun),
|
||||
kustomize.SubstituteWithStrict(b.strictSubst),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("var substitution failed for '%s': %w", res.GetName(), err)
|
||||
}
|
||||
|
||||
if outRes != nil {
|
||||
_, err = m.Replace(res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
outRes, err := kustomize.SubstituteVariables(ctx,
|
||||
b.client,
|
||||
unstructured.Unstructured{Object: data},
|
||||
res,
|
||||
kustomize.SubstituteWithDryRun(b.dryRun),
|
||||
kustomize.SubstituteWithStrict(b.strictSubst),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("var substitution failed for '%s': %w", res.GetName(), err)
|
||||
}
|
||||
|
||||
if outRes != nil {
|
||||
_, err = m.Replace(res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user