mirror of https://github.com/fluxcd/flux2.git
Compare commits
69 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
f2f7d59577 | 3 weeks ago |
|
|
7459e457bf | 3 weeks ago |
|
|
145f98b53a | 3 weeks ago |
|
|
6c58ea576e | 4 weeks ago |
|
|
580ef30c8f | 4 weeks ago |
|
|
94e9af6b2a | 1 month ago |
|
|
3fb05a604f | 1 month ago |
|
|
9b76ba19a8 | 1 month ago |
|
|
1e7dd5dfd8 | 1 month ago |
|
|
d6dec730d8 | 2 months ago |
|
|
0ba28f3f91 | 2 months ago |
|
|
55936e9366 | 2 months ago |
|
|
6ecad4783f | 2 months ago |
|
|
5759d08473 | 2 months ago |
|
|
5048de80f0 | 2 months ago |
|
|
97a437d059 | 2 months ago |
|
|
cfb28ffdc0 | 2 months ago |
|
|
ae9ef62f39 | 2 months ago |
|
|
69feb7214a | 2 months ago |
|
|
e95da82f5a | 2 months ago |
|
|
7c5f9befb4 | 2 months ago |
|
|
26a8d0c1c7 | 2 months ago |
|
|
833815c71d | 2 months ago |
|
|
31287b9b27 | 2 months ago |
|
|
28f5b553a2 | 2 months ago |
|
|
b33f173670 | 2 months ago |
|
|
d8c6ee167c | 2 months ago |
|
|
e288cb2771 | 2 months ago |
|
|
5f2a6ebc2b | 2 months ago |
|
|
cdc37c304a | 3 months ago |
|
|
60e4d99b57 | 3 months ago |
|
|
8229ffb674 | 3 months ago |
|
|
9b944da896 | 3 months ago |
|
|
5b37a6b04b | 3 months ago |
|
|
9f18062d43 | 3 months ago |
|
|
1055f28524 | 3 months ago |
|
|
7b0021c1a8 | 3 months ago |
|
|
ba997449aa | 3 months ago |
|
|
ca2f0205c4 | 3 months ago |
|
|
058525fe37 | 3 months ago |
|
|
686ee31f8a | 3 months ago |
|
|
767f235f94 | 3 months ago |
|
|
d5a2c66746 | 3 months ago |
|
|
f2ff083b8e | 3 months ago |
|
|
8c45f25f33 | 3 months ago |
|
|
f85cbfa9c8 | 3 months ago |
|
|
71a3dad213 | 3 months ago |
|
|
72e0535958 | 3 months ago |
|
|
4f2d1c3a2a | 3 months ago |
|
|
8e99cf7c93 | 3 months ago |
|
|
2bb7f38603 | 3 months ago |
|
|
0fe4449870 | 3 months ago |
|
|
7c5fb2297c | 3 months ago |
|
|
f4a811fbd3 | 3 months ago |
|
|
bb3726bb87 | 3 months ago |
|
|
333c8fe704 | 3 months ago |
|
|
83213ce83f | 3 months ago |
|
|
69718599ac | 3 months ago |
|
|
0255957dd7 | 3 months ago |
|
|
69b4b85cd9 | 3 months ago |
|
|
a9b5be7ff4 | 3 months ago |
|
|
1b46056e7d | 3 months ago |
|
|
039d79b3c2 | 3 months ago |
|
|
66b8aca399 | 3 months ago |
|
|
41c413e178 | 3 months ago |
|
|
d5f8720c4d | 3 months ago |
|
|
e6eb9d79e3 | 3 months ago |
|
|
b90d1738a9 | 3 months ago |
|
|
f9e66dee9e | 3 months ago |
@ -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])
|
||||||
|
}
|
||||||
@ -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)
|
||||||
|
}
|
||||||
@ -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 }}
|
||||||
Loading…
Reference in New Issue