Skip to content

Commit 7545cf8

Browse files
authored
Merge branch 'main' into skip-tenant-ns-create
2 parents a1e9d0a + 55936e9 commit 7545cf8

40 files changed

+631
-416
lines changed

.github/workflows/conformance.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
matrix:
7777
# Keep this list up-to-date with https://endoflife.date/kubernetes
7878
# Available versions can be found with "replicated cluster versions"
79-
K3S_VERSION: [ 1.32.8, 1.33.4 ]
79+
K3S_VERSION: [ 1.32.9, 1.33.5, 1.34.1 ]
8080
fail-fast: false
8181
steps:
8282
- name: Checkout
@@ -120,8 +120,7 @@ jobs:
120120
run: TEST_KUBECONFIG=${{ steps.prep.outputs.kubeconfig-path }} make e2e
121121
- name: Run flux bootstrap
122122
run: |
123-
./bin/flux bootstrap git --manifests ./manifests/install/ \
124-
--components-extra=image-reflector-controller,image-automation-controller \
123+
./bin/flux bootstrap git --manifests ./manifests/test/ \
125124
--url=https://github.com/fluxcd-testing/${{ steps.prep.outputs.cluster }} \
126125
--branch=main \
127126
--path=clusters/k3s \
@@ -169,7 +168,7 @@ jobs:
169168
strategy:
170169
matrix:
171170
# Keep this list up-to-date with https://endoflife.date/red-hat-openshift
172-
OPENSHIFT_VERSION: [ 4.19.0-okd ]
171+
OPENSHIFT_VERSION: [ 4.19.0-okd, 4.20.0-okd ]
173172
fail-fast: false
174173
steps:
175174
- name: Checkout
@@ -212,7 +211,6 @@ jobs:
212211
- name: Run flux bootstrap
213212
run: |
214213
./bin/flux bootstrap git --manifests ./manifests/openshift/ \
215-
--components-extra=image-reflector-controller,image-automation-controller \
216214
--url=https://github.com/fluxcd-testing/${{ steps.prep.outputs.cluster }} \
217215
--branch=main \
218216
--path=clusters/openshift \

.github/workflows/e2e-bootstrap.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
echo "test_repo_name=$TEST_REPO_NAME" >> $GITHUB_OUTPUT
5252
- name: bootstrap init
5353
run: |
54-
./bin/flux bootstrap github --manifests ./manifests/install/ \
54+
./bin/flux bootstrap github --manifests ./manifests/test/ \
5555
--owner=fluxcd-testing \
5656
--image-pull-secret=ghcr-auth \
5757
--registry-creds=fluxcd:$GITHUB_TOKEN \
@@ -66,7 +66,7 @@ jobs:
6666
kubectl -n flux-system get secret ghcr-auth | grep dockerconfigjson
6767
- name: bootstrap no-op
6868
run: |
69-
./bin/flux bootstrap github --manifests ./manifests/install/ \
69+
./bin/flux bootstrap github --manifests ./manifests/test/ \
7070
--owner=fluxcd-testing \
7171
--image-pull-secret=ghcr-auth \
7272
--repository=${{ steps.vars.outputs.test_repo_name }} \
@@ -78,7 +78,7 @@ jobs:
7878
- name: bootstrap customize
7979
run: |
8080
make setup-bootstrap-patch
81-
./bin/flux bootstrap github --manifests ./manifests/install/ \
81+
./bin/flux bootstrap github --manifests ./manifests/test/ \
8282
--owner=fluxcd-testing \
8383
--repository=${{ steps.vars.outputs.test_repo_name }} \
8484
--branch=main \
@@ -98,13 +98,14 @@ jobs:
9898
- name: test image automation
9999
run: |
100100
make setup-image-automation
101-
./bin/flux bootstrap github --manifests ./manifests/install/ \
101+
./bin/flux bootstrap github --manifests ./manifests/test/ \
102102
--owner=fluxcd-testing \
103103
--repository=${{ steps.vars.outputs.test_repo_name }} \
104104
--branch=main \
105105
--path=test-cluster \
106106
--read-write-key
107107
./bin/flux reconcile image repository podinfo
108+
./bin/flux reconcile image policy podinfo
108109
./bin/flux reconcile image update flux-system
109110
./bin/flux get images all
110111
./bin/flux -n flux-system events --for ImageUpdateAutomation/flux-system

.github/workflows/e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
./bin/flux check --pre
6666
- name: flux install --manifests
6767
run: |
68-
./bin/flux install --manifests ./manifests/install/
68+
./bin/flux install --manifests ./manifests/test/
6969
- name: flux create secret
7070
run: |
7171
./bin/flux create secret git git-ssh-test \

cmd/flux/export_source_external.go

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
Copyright 2025 The Flux authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"github.com/spf13/cobra"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
"k8s.io/apimachinery/pkg/types"
23+
24+
sourcev1 "github.com/fluxcd/source-controller/api/v1"
25+
)
26+
27+
var exportSourceExternalCmd = &cobra.Command{
28+
Use: "external [name]",
29+
Short: "Export ExternalArtifact sources in YAML format",
30+
Long: "The export source external command exports one or all ExternalArtifact sources in YAML format.",
31+
Example: ` # Export all ExternalArtifact sources
32+
flux export source external --all > sources.yaml
33+
34+
# Export a specific ExternalArtifact
35+
flux export source external my-artifact > source.yaml`,
36+
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.ExternalArtifactKind)),
37+
RunE: exportWithSecretCommand{
38+
list: externalArtifactListAdapter{&sourcev1.ExternalArtifactList{}},
39+
object: externalArtifactAdapter{&sourcev1.ExternalArtifact{}},
40+
}.run,
41+
}
42+
43+
func init() {
44+
exportSourceCmd.AddCommand(exportSourceExternalCmd)
45+
}
46+
47+
func exportExternalArtifact(source *sourcev1.ExternalArtifact) any {
48+
gvk := sourcev1.GroupVersion.WithKind(sourcev1.ExternalArtifactKind)
49+
export := sourcev1.ExternalArtifact{
50+
TypeMeta: metav1.TypeMeta{
51+
Kind: gvk.Kind,
52+
APIVersion: gvk.GroupVersion().String(),
53+
},
54+
ObjectMeta: metav1.ObjectMeta{
55+
Name: source.Name,
56+
Namespace: source.Namespace,
57+
Labels: source.Labels,
58+
Annotations: source.Annotations,
59+
},
60+
Spec: source.Spec,
61+
}
62+
return export
63+
}
64+
65+
func getExternalArtifactSecret(source *sourcev1.ExternalArtifact) *types.NamespacedName {
66+
// ExternalArtifact does not have a secretRef in its spec, this satisfies the interface
67+
return nil
68+
}
69+
70+
func (ex externalArtifactAdapter) secret() *types.NamespacedName {
71+
return getExternalArtifactSecret(ex.ExternalArtifact)
72+
}
73+
74+
func (ex externalArtifactListAdapter) secretItem(i int) *types.NamespacedName {
75+
return getExternalArtifactSecret(&ex.ExternalArtifactList.Items[i])
76+
}
77+
78+
func (ex externalArtifactAdapter) export() any {
79+
return exportExternalArtifact(ex.ExternalArtifact)
80+
}
81+
82+
func (ex externalArtifactListAdapter) exportItem(i int) any {
83+
return exportExternalArtifact(&ex.ExternalArtifactList.Items[i])
84+
}

cmd/flux/export_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ func TestExport(t *testing.T) {
110110
"testdata/export/bucket.yaml",
111111
tmpl,
112112
},
113+
{
114+
"source external",
115+
"export source external flux-system",
116+
"testdata/export/external-artifact.yaml",
117+
tmpl,
118+
},
113119
}
114120

115121
for _, tt := range cases {

cmd/flux/reconcile_helmrelease.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"fmt"
2121

2222
"github.com/spf13/cobra"
23-
"k8s.io/apimachinery/pkg/types"
2423

2524
helmv2 "github.com/fluxcd/helm-controller/api/v2"
2625
sourcev1 "github.com/fluxcd/source-controller/api/v1"
@@ -67,7 +66,7 @@ func (obj helmReleaseAdapter) reconcileSource() bool {
6766
return rhrArgs.syncHrWithSource
6867
}
6968

70-
func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName) {
69+
func (obj helmReleaseAdapter) getSource() (reconcileSource, sourceReference) {
7170
var (
7271
name string
7372
ns string
@@ -78,21 +77,26 @@ func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName
7877
if ns == "" {
7978
ns = obj.Namespace
8079
}
81-
namespacedName := types.NamespacedName{
82-
Name: name,
83-
Namespace: ns,
80+
srcRef := sourceReference{
81+
kind: obj.Spec.ChartRef.Kind,
82+
name: name,
83+
namespace: ns,
8484
}
85-
if obj.Spec.ChartRef.Kind == sourcev1.HelmChartKind {
85+
switch obj.Spec.ChartRef.Kind {
86+
case sourcev1.HelmChartKind:
8687
return reconcileWithSourceCommand{
8788
apiType: helmChartType,
8889
object: helmChartAdapter{&sourcev1.HelmChart{}},
8990
force: true,
90-
}, namespacedName
91+
}, srcRef
92+
case sourcev1.OCIRepositoryKind:
93+
return reconcileCommand{
94+
apiType: ociRepositoryType,
95+
object: ociRepositoryAdapter{&sourcev1.OCIRepository{}},
96+
}, srcRef
97+
default:
98+
return nil, srcRef
9199
}
92-
return reconcileCommand{
93-
apiType: ociRepositoryType,
94-
object: ociRepositoryAdapter{&sourcev1.OCIRepository{}},
95-
}, namespacedName
96100
default:
97101
// default case assumes the HelmRelease is using a HelmChartTemplate
98102
ns = obj.Spec.Chart.Spec.SourceRef.Namespace
@@ -104,9 +108,10 @@ func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName
104108
apiType: helmChartType,
105109
object: helmChartAdapter{&sourcev1.HelmChart{}},
106110
force: true,
107-
}, types.NamespacedName{
108-
Name: name,
109-
Namespace: ns,
111+
}, sourceReference{
112+
kind: sourcev1.HelmChartKind,
113+
name: name,
114+
namespace: ns,
110115
}
111116
}
112117
}

cmd/flux/reconcile_kustomization.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package main
1818

1919
import (
2020
"github.com/spf13/cobra"
21-
"k8s.io/apimachinery/pkg/types"
2221

2322
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
2423
sourcev1 "github.com/fluxcd/source-controller/api/v1"
@@ -62,8 +61,8 @@ func (obj kustomizationAdapter) reconcileSource() bool {
6261
return rksArgs.syncKsWithSource
6362
}
6463

65-
func (obj kustomizationAdapter) getSource() (reconcileSource, types.NamespacedName) {
66-
var cmd reconcileCommand
64+
func (obj kustomizationAdapter) getSource() (reconcileSource, sourceReference) {
65+
var cmd reconcileSource
6766
switch obj.Spec.SourceRef.Kind {
6867
case sourcev1.OCIRepositoryKind:
6968
cmd = reconcileCommand{
@@ -82,9 +81,10 @@ func (obj kustomizationAdapter) getSource() (reconcileSource, types.NamespacedNa
8281
}
8382
}
8483

85-
return cmd, types.NamespacedName{
86-
Name: obj.Spec.SourceRef.Name,
87-
Namespace: obj.Spec.SourceRef.Namespace,
84+
return cmd, sourceReference{
85+
kind: obj.Spec.SourceRef.Kind,
86+
name: obj.Spec.SourceRef.Name,
87+
namespace: obj.Spec.SourceRef.Namespace,
8888
}
8989
}
9090

cmd/flux/reconcile_source_chart.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package main
1818

1919
import (
2020
"github.com/spf13/cobra"
21-
"k8s.io/apimachinery/pkg/types"
2221

2322
sourcev1 "github.com/fluxcd/source-controller/api/v1"
2423
)
@@ -58,8 +57,8 @@ func (obj helmChartAdapter) reconcileSource() bool {
5857
return rhcArgs.syncHrWithSource
5958
}
6059

61-
func (obj helmChartAdapter) getSource() (reconcileSource, types.NamespacedName) {
62-
var cmd reconcileCommand
60+
func (obj helmChartAdapter) getSource() (reconcileSource, sourceReference) {
61+
var cmd reconcileSource
6362
switch obj.Spec.SourceRef.Kind {
6463
case sourcev1.HelmRepositoryKind:
6564
cmd = reconcileCommand{
@@ -78,9 +77,10 @@ func (obj helmChartAdapter) getSource() (reconcileSource, types.NamespacedName)
7877
}
7978
}
8079

81-
return cmd, types.NamespacedName{
82-
Name: obj.Spec.SourceRef.Name,
83-
Namespace: obj.Namespace,
80+
return cmd, sourceReference{
81+
kind: obj.Spec.SourceRef.Kind,
82+
name: obj.Spec.SourceRef.Name,
83+
namespace: obj.Namespace,
8484
}
8585
}
8686

cmd/flux/reconcile_with_source.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ import (
1515
"github.com/fluxcd/flux2/v2/internal/utils"
1616
)
1717

18+
type sourceReference struct {
19+
kind string
20+
name string
21+
namespace string
22+
}
23+
1824
type reconcileWithSource interface {
1925
adapter
2026
reconcilable
2127
reconcileSource() bool
22-
getSource() (reconcileSource, types.NamespacedName)
28+
getSource() (reconcileSource, sourceReference)
2329
}
2430

2531
type reconcileSource interface {
@@ -61,14 +67,17 @@ func (reconcile reconcileWithSourceCommand) run(cmd *cobra.Command, args []strin
6167
}
6268

6369
if reconcile.object.reconcileSource() || reconcile.force {
64-
reconcileCmd, nsName := reconcile.object.getSource()
70+
reconcileCmd, srcRef := reconcile.object.getSource()
71+
if reconcileCmd == nil {
72+
return fmt.Errorf("cannot reconcile source of kind %s", srcRef.kind)
73+
}
74+
6575
nsCopy := *kubeconfigArgs.Namespace
66-
if nsName.Namespace != "" {
67-
*kubeconfigArgs.Namespace = nsName.Namespace
76+
if srcRef.namespace != "" {
77+
*kubeconfigArgs.Namespace = srcRef.namespace
6878
}
6979

70-
err := reconcileCmd.run(nil, []string{nsName.Name})
71-
if err != nil {
80+
if err := reconcileCmd.run(nil, []string{srcRef.name}); err != nil {
7281
return err
7382
}
7483
*kubeconfigArgs.Namespace = nsCopy
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
apiVersion: source.toolkit.fluxcd.io/v1
3+
kind: ExternalArtifact
4+
metadata:
5+
name: flux-system
6+
namespace: {{ .fluxns }}
7+
spec:
8+
sourceRef:
9+
apiVersion: source.example.com/v1alpha1
10+
kind: GitHubRelease
11+
name: flux-system
12+
namespace: {{ .fluxns }}

0 commit comments

Comments
 (0)