mirror of https://github.com/fluxcd/flux2.git
commit
d3e529b8a4
@ -0,0 +1,88 @@
|
||||
// +build unit
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExport(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
arg string
|
||||
goldenFile string
|
||||
}{
|
||||
{
|
||||
"alert-provider",
|
||||
"export alert-provider slack",
|
||||
"testdata/export/provider.yaml",
|
||||
},
|
||||
{
|
||||
"alert",
|
||||
"export alert flux-system",
|
||||
"testdata/export/alert.yaml",
|
||||
},
|
||||
{
|
||||
"image policy",
|
||||
"export image policy flux-system",
|
||||
"testdata/export/image-policy.yaml",
|
||||
},
|
||||
{
|
||||
"image repository",
|
||||
"export image repository flux-system",
|
||||
"testdata/export/image-repo.yaml",
|
||||
},
|
||||
{
|
||||
"image update",
|
||||
"export image update flux-system",
|
||||
"testdata/export/image-update.yaml",
|
||||
},
|
||||
{
|
||||
"source git",
|
||||
"export source git flux-system",
|
||||
"testdata/export/git-repo.yaml",
|
||||
},
|
||||
{
|
||||
"source helm",
|
||||
"export source helm flux-system",
|
||||
"testdata/export/helm-repo.yaml",
|
||||
},
|
||||
{
|
||||
"receiver",
|
||||
"export receiver flux-system",
|
||||
"testdata/export/receiver.yaml",
|
||||
},
|
||||
{
|
||||
"kustomization",
|
||||
"export kustomization flux-system",
|
||||
"testdata/export/ks.yaml",
|
||||
},
|
||||
{
|
||||
"helmrelease",
|
||||
"export helmrelease flux-system",
|
||||
"testdata/export/helm-release.yaml",
|
||||
},
|
||||
{
|
||||
"bucket",
|
||||
"export source bucket flux-system",
|
||||
"testdata/export/bucket.yaml",
|
||||
},
|
||||
}
|
||||
|
||||
objectFile := "testdata/export/objects.yaml"
|
||||
tmpl := map[string]string{
|
||||
"fluxns": allocateNamespace("flux-system"),
|
||||
}
|
||||
testEnv.CreateObjectFile(objectFile, tmpl, t)
|
||||
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cmd := cmdTestCase{
|
||||
args: tt.arg + " -n=" + tmpl["fluxns"],
|
||||
assert: assertGoldenTemplateFile(tt.goldenFile, tmpl),
|
||||
}
|
||||
|
||||
cmd.runTestCmd(t)
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
---
|
||||
apiVersion: notification.toolkit.fluxcd.io/v1beta1
|
||||
kind: Alert
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
eventSeverity: info
|
||||
eventSources:
|
||||
- kind: GitRepository
|
||||
name: '*'
|
||||
- kind: Kustomization
|
||||
name: '*'
|
||||
providerRef:
|
||||
name: slack
|
||||
summary: Slacktest Notification
|
||||
|
@ -0,0 +1,14 @@
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta1
|
||||
kind: Bucket
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
bucketName: podinfo
|
||||
endpoint: s3.amazonaws.com
|
||||
interval: 5m0s
|
||||
provider: aws
|
||||
region: us-east-1
|
||||
timeout: 30s
|
||||
|
@ -0,0 +1,16 @@
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta1
|
||||
kind: GitRepository
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
gitImplementation: go-git
|
||||
interval: 5m0s
|
||||
ref:
|
||||
branch: main
|
||||
secretRef:
|
||||
name: flux-system
|
||||
timeout: 20s
|
||||
url: ssh://git@github.com/example/repo
|
||||
|
@ -0,0 +1,18 @@
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta1
|
||||
kind: HelmRelease
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
chart:
|
||||
spec:
|
||||
chart: podinfo
|
||||
reconcileStrategy: ChartVersion
|
||||
sourceRef:
|
||||
kind: HelmRepository
|
||||
name: flux-systen
|
||||
namespace: {{ .fluxns }}
|
||||
version: '*'
|
||||
interval: 5m0s
|
||||
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta1
|
||||
kind: HelmRepository
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
interval: 5m0s
|
||||
timeout: 1m0s
|
||||
url: https://stefanprodan.github.io/podinfo
|
||||
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
apiVersion: image.toolkit.fluxcd.io/v1beta1
|
||||
kind: ImagePolicy
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
imageRepositoryRef:
|
||||
name: flux-system
|
||||
policy:
|
||||
semver:
|
||||
range: 5.0.x
|
||||
|
@ -0,0 +1,10 @@
|
||||
---
|
||||
apiVersion: image.toolkit.fluxcd.io/v1beta1
|
||||
kind: ImageRepository
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
image: ghcr.io/test/podinfo
|
||||
interval: 1m0s
|
||||
|
@ -0,0 +1,20 @@
|
||||
---
|
||||
apiVersion: image.toolkit.fluxcd.io/v1beta1
|
||||
kind: ImageUpdateAutomation
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
git:
|
||||
commit:
|
||||
author:
|
||||
email: fluxcdbot@users.noreply.github.com
|
||||
name: fluxcdbot
|
||||
interval: 1m0s
|
||||
sourceRef:
|
||||
kind: GitRepository
|
||||
name: flux-system
|
||||
update:
|
||||
path: ./clusters/my-cluster
|
||||
strategy: Setters
|
||||
|
@ -0,0 +1,14 @@
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
|
||||
kind: Kustomization
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
interval: 5m0s
|
||||
path: ./infrastructure/
|
||||
prune: true
|
||||
sourceRef:
|
||||
kind: GitRepository
|
||||
name: flux-system
|
||||
|
@ -0,0 +1,153 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: {{ .fluxns }}
|
||||
---
|
||||
apiVersion: notification.toolkit.fluxcd.io/v1beta1
|
||||
kind: Provider
|
||||
metadata:
|
||||
name: slack
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
type: slack
|
||||
channel: 'A channel with spacess'
|
||||
address: https://hooks.slack.com/services/mock
|
||||
---
|
||||
apiVersion: notification.toolkit.fluxcd.io/v1beta1
|
||||
kind: Alert
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
summary: "Slacktest Notification"
|
||||
providerRef:
|
||||
name: slack
|
||||
eventSeverity: info
|
||||
eventSources:
|
||||
- kind: "GitRepository"
|
||||
name: "*"
|
||||
- kind: "Kustomization"
|
||||
name: "*"
|
||||
---
|
||||
apiVersion: image.toolkit.fluxcd.io/v1beta1
|
||||
kind: ImageRepository
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
image: ghcr.io/test/podinfo
|
||||
interval: 1m0s
|
||||
---
|
||||
apiVersion: image.toolkit.fluxcd.io/v1beta1
|
||||
kind: ImagePolicy
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
imageRepositoryRef:
|
||||
name: flux-system
|
||||
policy:
|
||||
semver:
|
||||
range: 5.0.x
|
||||
---
|
||||
apiVersion: image.toolkit.fluxcd.io/v1beta1
|
||||
kind: ImageUpdateAutomation
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
interval: 1m0s
|
||||
sourceRef:
|
||||
kind: GitRepository
|
||||
name: flux-system
|
||||
git:
|
||||
commit:
|
||||
author:
|
||||
email: fluxcdbot@users.noreply.github.com
|
||||
name: fluxcdbot
|
||||
messageTemplate: '{{range .Updated.Images}}{{println .}}{{end}}'
|
||||
update:
|
||||
path: ./clusters/my-cluster
|
||||
strategy: Setters
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta1
|
||||
kind: GitRepository
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
ref:
|
||||
branch: main
|
||||
secretRef:
|
||||
name: flux-system
|
||||
interval: 5m
|
||||
url: ssh://git@github.com/example/repo
|
||||
---
|
||||
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
|
||||
kind: Kustomization
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
path: ./infrastructure/
|
||||
sourceRef:
|
||||
kind: GitRepository
|
||||
name: flux-system
|
||||
interval: 5m
|
||||
prune: true
|
||||
---
|
||||
apiVersion: notification.toolkit.fluxcd.io/v1beta1
|
||||
kind: Receiver
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
type: github
|
||||
events:
|
||||
- "ping"
|
||||
- "push"
|
||||
secretRef:
|
||||
name: webhook-token
|
||||
resources:
|
||||
- kind: GitRepository
|
||||
name: flux-system
|
||||
namespace: flux-system
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta1
|
||||
kind: HelmRepository
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
interval: 5m
|
||||
timeout: 1m0s
|
||||
url: https://stefanprodan.github.io/podinfo
|
||||
---
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta1
|
||||
kind: HelmRelease
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
interval: 5m
|
||||
chart:
|
||||
spec:
|
||||
chart: podinfo
|
||||
sourceRef:
|
||||
kind: HelmRepository
|
||||
name: flux-systen
|
||||
namespace: {{ .fluxns }}
|
||||
---
|
||||
apiVersion: source.toolkit.fluxcd.io/v1beta1
|
||||
kind: Bucket
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
interval: 5m
|
||||
provider: aws
|
||||
bucketName: podinfo
|
||||
endpoint: s3.amazonaws.com
|
||||
region: us-east-1
|
||||
timeout: 30s
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
apiVersion: notification.toolkit.fluxcd.io/v1beta1
|
||||
kind: Provider
|
||||
metadata:
|
||||
name: slack
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
address: https://hooks.slack.com/services/mock
|
||||
channel: A channel with spacess
|
||||
type: slack
|
||||
|
@ -0,0 +1,18 @@
|
||||
---
|
||||
apiVersion: notification.toolkit.fluxcd.io/v1beta1
|
||||
kind: Receiver
|
||||
metadata:
|
||||
name: flux-system
|
||||
namespace: {{ .fluxns }}
|
||||
spec:
|
||||
events:
|
||||
- ping
|
||||
- push
|
||||
resources:
|
||||
- kind: GitRepository
|
||||
name: flux-system
|
||||
namespace: flux-system
|
||||
secretRef:
|
||||
name: webhook-token
|
||||
type: github
|
||||
|
Loading…
Reference in New Issue