1
0
mirror of synced 2026-03-01 11:16:56 +00:00

Compare commits

...

1010 Commits

Author SHA1 Message Date
Stefan Prodan
6d110cdfb1 Merge pull request #3229 from fluxcd/rfc-0002-cosign
RFC-0002: Add Cosign verification for Helm OCI charts
2022-10-24 12:24:16 +03:00
Stefan Prodan
d015895caa RFC-0002: Add Cosign verification for Helm OCI charts
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-23 12:09:34 +03:00
Stefan Prodan
64e76a23c6 Merge pull request #3242 from fluxcd/kube-1.25.3
Update dependencies
2022-10-21 22:07:03 +03:00
Stefan Prodan
f5006aa239 Update dependencies
- Kubernetes packages to v1.25.3
- Fix CVE-2022-32149
- Sync tests go.mod with root

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-21 21:29:17 +03:00
Stefan Prodan
4bd06771ae Merge pull request #3187 from fluxcd/update-components
Update toolkit components
2022-10-21 20:59:27 +03:00
fluxcdbot
4643f8383e Update toolkit components
- helm-controller to v0.26.0
  https://github.com/fluxcd/helm-controller/blob/v0.26.0/CHANGELOG.md
- kustomize-controller to v0.30.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.30.0/CHANGELOG.md
- source-controller to v0.31.0
  https://github.com/fluxcd/source-controller/blob/v0.31.0/CHANGELOG.md
- notification-controller to v0.28.0
  https://github.com/fluxcd/notification-controller/blob/v0.28.0/CHANGELOG.md
- image-reflector-controller to v0.22.1
  https://github.com/fluxcd/image-reflector-controller/blob/v0.22.1/CHANGELOG.md
- image-automation-controller to v0.26.1
  https://github.com/fluxcd/image-automation-controller/blob/v0.26.1/CHANGELOG.md

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-21 20:37:09 +03:00
Philip Laine
b82759b35a Merge pull request #3237 from fluxcd/move/bootstrap
Move bootstrap package from internal to pkg
2022-10-21 13:47:39 +02:00
Philip Laine
0343575146 Move bootstrap package from internal to pkg
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2022-10-21 11:54:28 +02:00
Stefan Prodan
e7847b75db Merge pull request #3236 from fluxcd/ci-refactor
ci: Refactor GitHub workflows
2022-10-21 10:56:24 +03:00
Stefan Prodan
bb1078d610 ci: Refactor GitHub workflows
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-21 09:46:10 +03:00
Stefan Prodan
6f6c097980 Merge pull request #3232 from eddie-knight/fix/workflow-permissions
Additional workflow permissions tweaks
2022-10-20 21:15:55 +03:00
Eddie Knight
73692df272 Additional workflow permissions tweaks
Signed-off-by: Eddie Knight <knight@linux.com>
2022-10-20 12:48:05 -05:00
Stefan Prodan
138cba6e57 Merge pull request #3231 from eddie-knight/fix/workflow-permissions
Adjusted workflow permissions
2022-10-20 20:35:08 +03:00
Eddie Knight
2abf932ee4 Updated scan & update permissions
Signed-off-by: Eddie Knight <knight@linux.com>
2022-10-20 12:09:34 -05:00
Eddie Knight
939a75115c Adjusted workflow permissions
Signed-off-by: Eddie Knight <knight@linux.com>
2022-10-20 11:04:49 -05:00
Stefan Prodan
9f41efb6f7 Merge pull request #3224 from developer-guy/feature/diff
Add `diff artifact` command
2022-10-20 13:46:15 +03:00
Batuhan Apaydın
c3d7cad53e feat: diff artifact capability added
Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com>
2022-10-20 13:23:50 +03:00
Stefan Prodan
463f9fbc64 Merge pull request #3218 from fluxcd/dependabot/github_actions/peter-evans/create-pull-request-4
Bump peter-evans/create-pull-request from 3 to 4
2022-10-19 17:19:08 +03:00
dependabot[bot]
4a51b111e6 Bump peter-evans/create-pull-request from 3 to 4
Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 3 to 4.
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](https://github.com/peter-evans/create-pull-request/compare/v3...v4)

---
updated-dependencies:
- dependency-name: peter-evans/create-pull-request
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-19 13:48:54 +00:00
Philip Laine
63ebd7fd09 Merge pull request #3217 from fluxcd/dependabot/github_actions/hashicorp/setup-terraform-2.0.2
Bump hashicorp/setup-terraform from 1 to 2.0.2
2022-10-19 15:48:10 +02:00
dependabot[bot]
c31367909e Bump hashicorp/setup-terraform from 1 to 2.0.2
Bumps [hashicorp/setup-terraform](https://github.com/hashicorp/setup-terraform) from 1 to 2.0.2.
- [Release notes](https://github.com/hashicorp/setup-terraform/releases)
- [Changelog](https://github.com/hashicorp/setup-terraform/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/setup-terraform/compare/v1...v2.0.2)

---
updated-dependencies:
- dependency-name: hashicorp/setup-terraform
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-19 13:26:45 +00:00
Stefan Prodan
0f0649a674 Merge pull request #3219 from fluxcd/dependabot/github_actions/github/codeql-action-2
Bump github/codeql-action from 1 to 2
2022-10-19 16:26:04 +03:00
dependabot[bot]
09cbf348a7 Bump github/codeql-action from 1 to 2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-18 07:32:38 +00:00
Stefan Prodan
287bc520b1 Merge pull request #3220 from fluxcd/fix-dependabot
Only run e2e tests for Dependabot PRs
2022-10-18 10:31:58 +03:00
Stefan Prodan
65a2ceec5c Only run e2e tests for Dependabot PRs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-17 19:49:57 +03:00
Stefan Prodan
516399bf81 Merge pull request #3216 from fluxcd/dependabot
Enable Dependabot for GitHub Actions
2022-10-17 19:20:42 +03:00
Stefan Prodan
4ea70765af Enable Dependabot for GitHub Actions
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-17 18:57:09 +03:00
Stefan Prodan
d6372e396b Merge pull request #3213 from fluxcd/fossa-badge
Add FOSSA license scanning badge
2022-10-17 17:02:33 +03:00
Stefan Prodan
7b20ad5dd2 Add link to roadmap, adopters and ecosystem
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-17 16:38:20 +03:00
Stefan Prodan
3d962136a8 Add FOSSA license scanning badge
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-17 16:36:25 +03:00
Stefan Prodan
f3386505cf Merge pull request #3214 from eddie-knight/docs/artifact-hub-badge
Added ArtifactHub badge
2022-10-17 16:36:11 +03:00
Eddie Knight
f4c8da35e8 Added ArtifactHub badge
Signed-off-by: Eddie Knight <iv.eddieknight@gmail.com>
2022-10-15 11:03:04 -05:00
Philip Laine
cc3f2c7bde Merge pull request #3197 from fluxcd/move-uninstall
Move uninstall code to pkg
2022-10-13 11:07:38 +02:00
Philip Laine
80b87729b6 Move uninstall code to pkg
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2022-10-12 19:25:14 +02:00
Philip Laine
2282223592 Merge pull request #3198 from fluxcd/discard-logger
Add nop logger
2022-10-12 14:14:51 +02:00
Philip Laine
f6c96aea48 Add discard logger
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2022-10-12 11:55:00 +02:00
Stefan Prodan
1fa48bf916 Merge pull request #3190 from developer-guy/feature/3180
Accept a file path as input for `flux build|push artifact`
2022-10-11 14:56:19 +03:00
Batuhan Apaydın
d49b77c8d2 chore: bump the pkg/oci package to v0.12.0
Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com>
2022-10-11 14:32:24 +03:00
Stefan Prodan
91132e9c87 Merge pull request #3174 from fluxcd/fix/azure-libgit2
Update libgit2 version in Azure e2e tests
2022-10-07 16:43:56 +03:00
Philip Laine
4680abe951 Update libgit2 version in Azure e2e tests
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2022-10-07 15:26:06 +02:00
Stefan Prodan
2963708a6c Merge pull request #3162 from somtochiama/fix-oci
Update golden file for `get source oci`
2022-10-06 13:50:16 +02:00
Somtochi Onyekwere
1f57cf3d31 Update oci golden file
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-09-30 06:04:38 +01:00
Stefan Prodan
80611ec70e Merge pull request #3161 from fluxcd/rfc-0003-implemented
Update RFC-0003 implementation history
2022-09-29 21:59:25 +03:00
Stefan Prodan
d37bb42995 Update RFC-0003 implementation history
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-29 21:32:34 +03:00
Stefan Prodan
1bf63a94c2 Merge pull request #3149 from fluxcd/update-components
Update toolkit components
2022-09-29 21:27:56 +03:00
Stefan Prodan
cad251444c Update OCI golden files
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-29 21:06:57 +03:00
fluxcdbot
358c6d38b7 Update toolkit components
- helm-controller to v0.25.0
  https://github.com/fluxcd/helm-controller/blob/v0.25.0/CHANGELOG.md
- kustomize-controller to v0.29.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.29.0/CHANGELOG.md
- source-controller to v0.30.0
  https://github.com/fluxcd/source-controller/blob/v0.30.0/CHANGELOG.md
- notification-controller to v0.27.0
  https://github.com/fluxcd/notification-controller/blob/v0.27.0/CHANGELOG.md
- image-reflector-controller to v0.22.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.22.0/CHANGELOG.md
- image-automation-controller to v0.26.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.26.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-09-29 18:04:36 +00:00
Stefan Prodan
b8fd46d0df Merge pull request #3098 from Santosh1176/monitoring
[Grafana] Use `container_memory_working_set_bytes` to report memory consumption
2022-09-29 11:16:10 +03:00
Santosh Kaluskar
6a1ba3c545 monitoring: use container_memory_working_set_bytes
Signed-off-by: Santosh Kaluskar <dtshbl@gmail.com>
2022-09-29 07:49:13 +00:00
Stefan Prodan
33a874800b Merge pull request #3154 from fluxcd/rfc-0003-cosign
[RFC-0003] Add Cosign keyless specification
2022-09-29 09:42:20 +03:00
Stefan Prodan
f417352370 Add Cosign keyless specification
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-29 09:20:46 +03:00
Stefan Prodan
72d90b5692 Merge pull request #3153 from fluxcd/build-go1.19
Build with Go 1.19
2022-09-29 00:21:18 +03:00
Stefan Prodan
d7dadb4425 e2e: Update bootstrap test to Kubernetes 1.25.2
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-28 23:54:08 +03:00
Stefan Prodan
348408e16e Build with Go 1.19
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-28 22:05:48 +03:00
Stefan Prodan
04de52044a Merge pull request #3117 from carlosonunez-vmw/main
Maintain original scheme when using --token-auth
2022-09-28 10:51:06 +03:00
Carlos Nunez
45a00a0170 Maintain original scheme when using --token-auth
If you're using an HTTP-based Git server with Flux, you need to provide `--token-auth` to avoid triggering an SSH host key check (see [here](https://github.com/fluxcd/flux2/issues/2825#issuecomment-1151355914)). Unfortunately, doing this forces the URL in the `GitRepository` resource created during bootstrapping to always use `https`. This will cause Kustomization reconcile errors for servers that do not have HTTPS enabled or do not have the appropriate certs installed or available.

This pull request fixes this by keeping the repository URL scheme intact when using `--token-auth`.

Signed-off-by: Carlos Nunez <75340335+carlosonunez-vmw@users.noreply.github.com>
2022-09-27 22:14:29 -05:00
Stefan Prodan
1ac380a7f9 Merge pull request #3145 from fluxcd/component-label
Add component label for controllers and their CRDs
2022-09-26 14:45:26 +03:00
Stefan Prodan
2971d34a13 Add component label for controllers and their CRDs
Label each controller deployment, service, service account and CRDs with `app.kubernetes.io/component: <controller-name>`.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-26 14:08:32 +03:00
Stefan Prodan
90f0d81532 Merge pull request #3097 from fluxcd/oci-insecure-flag
Add `--insecure` flag to `flux create source oci`
2022-09-12 15:37:52 +03:00
Stefan Prodan
d5262404f3 Add insecure flag to flux create source oci
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-12 14:31:03 +03:00
Stefan Prodan
03c3cb860a Update Azure e2e dependencies
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-12 14:21:46 +03:00
Stefan Prodan
a1faa1d965 Merge pull request #3091 from fluxcd/update-components
Update toolkit components
2022-09-12 14:14:52 +03:00
fluxcdbot
c40d290e46 Update toolkit components
- helm-controller to v0.24.0
  https://github.com/fluxcd/helm-controller/blob/v0.24.0/CHANGELOG.md
- kustomize-controller to v0.28.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.28.0/CHANGELOG.md
- source-controller to v0.29.0
  https://github.com/fluxcd/source-controller/blob/v0.29.0/CHANGELOG.md
- notification-controller to v0.26.0
  https://github.com/fluxcd/notification-controller/blob/v0.26.0/CHANGELOG.md
- image-reflector-controller to v0.21.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.21.0/CHANGELOG.md
- image-automation-controller to v0.25.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.25.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-09-12 10:44:50 +00:00
Stefan Prodan
5106a71e6a Merge pull request #3079 from ManoManoTech/push-autologin
Support autologin when pushing OCI artifacts
2022-09-12 13:43:20 +03:00
Adrien Fillon
491acf57ad Setup CodeQL CI job with Go 1.18
Signed-off-by: Adrien Fillon <adrien.fillon@manomano.com>
2022-09-12 12:08:47 +02:00
Adrien Fillon
0694a9582f Support logging in directly to the provider when pushing OCI artifacts
I've noticed during CI, that the current command
already expected a configured Docker client to
push artifacts to authenticated registries.

Some users might not want to have the Docker client
in their process (like a CI job) or build an handcrafted
config.json file.

This would allow this kind of behavior:

```
flux push artifact oci://my-registry.dev/foo:v1 \
  --source xxx \
  --revision xxx \
  --path . \
  --creds $TOKEN # Authenticate via "Bearer $TOKEN" Authorization header
```

Or via Autologin:

```
flux push artifact oci://012345678901.dkr.ecr.us-east-1.amazonaws.com/foo:v1 \
  --source xxx \
  --revision xxx \
  --path . \
  --provider aws
```

This has been implemented for:

* flux push artifact
* flux list artifact
* flux tag artifact
* flux pull artifact

This will require another PR in https://github.com/fluxcd/pkg/pull/352

Signed-off-by: Adrien Fillon <adrien.fillon@manomano.com>
2022-09-12 12:08:47 +02:00
Stefan Prodan
0c817378cf Merge pull request #3085 from souleb/reconcile-repository
[bootstrap] Make sure we reconcile with the right reconciliation method
2022-09-12 12:47:27 +03:00
Soule BA
ec2aa13165 Make sure we reconcile with the right reconciliation method
Signed-off-by: Soule BA <soule@weave.works>
2022-09-12 09:34:24 +02:00
Stefan Prodan
c921cf0d54 Merge pull request #3087 from somtochiama/notify-finalize
Remove finalizers for notification controllers
2022-09-11 15:48:33 +03:00
Somtochi Onyekwere
11dd0d918c remove finalizers for notification controllers
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-09-11 13:16:53 +01:00
Stefan Prodan
467969de0f Merge pull request #3088 from fluxcd/flux-manifests
Publish the install manifests to GHCR and DockerHub as OCI artifacts
2022-09-09 15:23:34 +03:00
Stefan Prodan
bdc5ae4573 Publish install manifests to GHCR and DockerHub as OCI artifacts
Add workflow to build and push the install manifests to:
- ghcr.io/fluxcd/flux-manifests
- docker.io/fluxcd/flux-manifests
The OCI artifacts are signed with Cosign and GitHub OIDC (keyless).
The manifests pushed to GHCR have the container images set to ghcr.io/fluxcd/<controller-name> while the manifests pushed to DockerHub have the controller images set to docker.io/fluxcd/<controller-name>.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-09 14:49:58 +03:00
Stefan Prodan
1eb4b67013 Merge pull request #3082 from fluxcd/uninstall-oci-repos
Remove finalizers for OCI repositories on uninstall
2022-09-08 11:07:21 +03:00
Stefan Prodan
e777947539 Remove finalizers for OCI repositories on uninstall
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-08 10:43:31 +03:00
Stefan Prodan
70b906cae2 Merge pull request #3053 from dholbach/revert-3034-fix/broken-edit-page-links-2203
Revert "Fix broken "edit this page" links in Flux CLI section"
2022-09-06 16:52:19 +03:00
Daniel Holbach
c57afa1e56 Revert "Fix broken "edit this page" links in Flux CLI section"
Signed-off-by: Daniel Holbach <daniel@weave.works>
2022-09-06 15:20:42 +02:00
Stefan Prodan
73668d19d9 Merge pull request #3073 from acondrat/patch-1
Filter out non-running pods in Prometheus
2022-09-06 16:09:57 +03:00
Arcadie Condrat
82f847e21d Filter out non-running pods in Prometheus
Prometheus job generated by the PodMonitor does not exclude non-running pods. All the "completed" Pods are still going to be  listed as targets in Prometheus and marked as down. This issue is related to PodMonitor implementation and is discussed in prometheus-operator/prometheus-operator#4816

Signed-off-by: Arcadie Condrat <arcadie.condrat@gmail.com>
2022-09-05 11:34:39 +02:00
Stefan Prodan
753b2e6eda Merge pull request #3063 from somtochiama/update-runtime
Update `flux logs` to accomodate the new format
2022-09-01 19:17:49 +03:00
Somtochi Onyekwere
7b95e90a33 Update flux logs to accomodate the new format
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-31 17:58:43 +01:00
Stefan Prodan
7824229d7b Merge pull request #3052 from dholbach/update-flux-docs-structure
update to new doc links structure
2022-08-30 16:08:53 +03:00
Daniel Holbach
20557f9f15 update to new doc links structure
Signed-off-by: Daniel Holbach <daniel@weave.works>
2022-08-30 14:50:05 +02:00
Stefan Prodan
6430f2b4b0 Merge pull request #3048 from fluxcd/azure-e2e-updates
Update packages in Azure e2e tests
2022-08-30 10:29:46 +03:00
Stefan Prodan
92e136ed54 Update packages in Azure e2e tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2022-08-29 16:50:26 +02:00
Stefan Prodan
e79b008878 Merge pull request #3050 from fluxcd/oci-rfc-updates
Status update for RFC-0002 and RFC-0003
2022-08-29 17:09:30 +03:00
Stefan Prodan
43cdea01d6 Status update for RFC-0002 and RFC-0003
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-29 16:31:51 +03:00
Stefan Prodan
6ddaedb4fc Merge pull request #3049 from fluxcd/kube-1.25
Update Kubernetes dependencies to v1.25.0
2022-08-29 15:24:31 +03:00
Stefan Prodan
b4fef0a6b9 Update Kubernetes dependencies to v1.25.0
- update `k8s.io` packages to match the Kubernetes v1.25.0 release
- update `kubectl` to v1.25.0 in the flux-cli container image
- update `go.mod` to Go 1.18

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-29 15:03:36 +03:00
Stefan Prodan
735ebd3336 Merge pull request #2999 from fluxcd/update-components
Update toolkit components
2022-08-29 14:28:37 +03:00
Stefan Prodan
a5a9158a24 Add provider to Helm OCI tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-29 14:09:42 +03:00
fluxcdbot
93fdd795da Update toolkit components
- helm-controller to v0.23.1
  https://github.com/fluxcd/helm-controller/blob/v0.23.1/CHANGELOG.md
- kustomize-controller to v0.27.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.27.1/CHANGELOG.md
- source-controller to v0.28.0
  https://github.com/fluxcd/source-controller/blob/v0.28.0/CHANGELOG.md
- notification-controller to v0.25.2
  https://github.com/fluxcd/notification-controller/blob/v0.25.2/CHANGELOG.md
- image-reflector-controller to v0.20.1
  https://github.com/fluxcd/image-reflector-controller/blob/v0.20.1/CHANGELOG.md
- image-automation-controller to v0.24.2
  https://github.com/fluxcd/image-automation-controller/blob/v0.24.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-08-29 10:57:30 +00:00
Stefan Prodan
18c944d18a Merge pull request #3034 from snebel29/fix/broken-edit-page-links-2203
Fix broken "edit this page" links in Flux CLI section #2203
2022-08-26 10:03:36 +03:00
Sven Nebel
2c9ef85f6d Fix broken "edit this page" links in Flux CLI section #2203
Signed-off-by: Sven Nebel <nebel.sven@gmail.com>
2022-08-25 21:01:53 +01:00
Stefan Prodan
80669d71ef Merge pull request #3028 from snebel29/update/terraform-exec-dep
Update tests/azure github.com/hashicorp/terraform-exec to v0.16.1
2022-08-25 18:02:36 +03:00
Sven Nebel
b993d17148 Update tests/azure dependency
- Update "github.com/hashicorp/terraform-exec" to v0.16.1
- Replace "github.com/hashicorp/terraform-exec/tfinstall" with "github.com/hashicorp/hc-install"
- Fix typos and wording in README.md

Signed-off-by: Sven Nebel <nebel.sven@gmail.com>
2022-08-25 15:13:47 +01:00
Stefan Prodan
c454dd481b Merge pull request #3025 from fluxcd/rfc-0002-auth
[RFC-0002] Add auth specification for Helm OCI
2022-08-25 15:09:45 +03:00
Stefan Prodan
07de9d9ffe [RFC-0002] Add auth specification for Helm OCI
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-25 12:16:02 +03:00
Stefan Prodan
9f26b09a06 Merge pull request #3019 from somtochiama/get-cmd
Improve error message in get cmd
2022-08-24 14:59:41 +03:00
Somtochi Onyekwere
ad0f3373b6 Improve error message in get cmd
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-24 11:35:46 +01:00
Stefan Prodan
f880cce4f9 Merge pull request #3024 from fluxcd/validate-version
Add version validation to install commands
2022-08-24 13:27:27 +03:00
Stefan Prodan
8a0fd6ddf9 Add version validation to install commands
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-24 11:58:29 +03:00
Stefan Prodan
c56f338b12 Merge pull request #3014 from fluxcd/oci-mediatype
[RFC-0003] Select layer by OCI media type
2022-08-23 17:21:49 +03:00
Stefan Prodan
463d241a91 Update TODOs for RFC-0003
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-23 16:03:40 +03:00
Stefan Prodan
db0920ba32 Clarify the layer selection behaviour
Co-authored-by: Hidde Beydals <hiddeco@users.noreply.github.com>
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-23 16:03:37 +03:00
Stefan Prodan
16d3180e42 [RFC-0003] OCI select layer by media type
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-23 16:03:37 +03:00
Stefan Prodan
81d2ad8245 Merge pull request #2998 from somtochiama/filter-artifact
Add `--filter-semver` and `--filter-regex` flags to `list artifacts`
2022-08-23 11:00:22 +03:00
Somtochi Onyekwere
96d1c1b2bd Add --filter-semver and regex flags to list artifact
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-22 20:35:15 +01:00
Stefan Prodan
545949c67f Merge pull request #2996 from fluxcd/go-git-providers-up
Update dependencies
2022-08-17 17:52:52 +03:00
Stefan Prodan
342bb81687 Update kubectl to v1.24.3 in flux-cli image
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-17 17:12:54 +03:00
Stefan Prodan
60b483569d Update dependencies
- fluxcd/go-git-providers v0.8.0
- google/go-containerregistry v0.11.0
- homeport/dyff v1.5.5
- spf13/cobra v1.5.0
- k8s.io/cli-runtime v0.24.3

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-17 17:12:48 +03:00
Stefan Prodan
b7a2fb4be0 Merge pull request #2997 from fluxcd/make-ghcr-default
Use ghcr.io in the static manifests
2022-08-17 17:11:02 +03:00
Stefan Prodan
5bdc083ce2 Use ghcr.io in the static manifests
Use the same container registry as `flux install` for the static install manifests.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-17 16:48:52 +03:00
Stefan Prodan
787b6953c8 Merge pull request #2995 from fluxcd/oci-ignore
Add `--ignore-paths` arg to `flux build|push artifact`
2022-08-17 15:33:01 +03:00
Stefan Prodan
40717fa4f4 Exclude VCS files by default from OCI artifacts
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-17 13:49:38 +03:00
Stefan Prodan
899a1fffca Add --ignore-paths arg to flux build|push artifact
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-16 15:31:39 +03:00
Stefan Prodan
02b38ac8e0 Merge pull request #2945 from somtochiama/reset-test-arg
Reset flag after executing command in tests
2022-08-12 14:00:48 +03:00
Somtochi Onyekwere
5dcd599612 reset cmd flags
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-12 10:49:00 +01:00
Stefan Prodan
854ec02823 Merge pull request #2979 from fluxcd/oci-rfcs-update
Status update for RFC-0002 and RFC-0003
2022-08-11 18:25:39 +03:00
Stefan Prodan
9386b9e0c3 Status update for RFC-0002 and RFC-0003
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-11 17:34:37 +03:00
Stefan Prodan
f2d749069e Merge pull request #2966 from fluxcd/update-components
Update toolkit components
2022-08-11 17:29:33 +03:00
fluxcdbot
d4169aa4dd Update toolkit components
- kustomize-controller to v0.27.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.27.0/CHANGELOG.md
- source-controller to v0.26.1
  https://github.com/fluxcd/source-controller/blob/v0.26.1/CHANGELOG.md
- notification-controller to v0.25.1
  https://github.com/fluxcd/notification-controller/blob/v0.25.1/CHANGELOG.md
- image-reflector-controller to v0.20.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.20.0/CHANGELOG.md
- image-automation-controller to v0.24.1
  https://github.com/fluxcd/image-automation-controller/blob/v0.24.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-08-11 14:03:13 +00:00
Stefan Prodan
c06072d5cf Merge pull request #2856 from fluxcd/oci
[RFC-0003] Add commands for managing OCI artifacts
2022-08-11 17:02:01 +03:00
Max Jonas Werner
7e2d235f53 Merge pull request #2971 from fluxcd/trace-ocirepo
Make `flux trace` work with OCIRepository
2022-08-10 14:56:26 +02:00
Max Jonas Werner
b810aea6cc Make flux trace work with OCIRepository
* Added support for OCIRepositories to `flux trace`
* Changed indentation to compensate new, longer field name "Source
  Revision"
* Added unit tests for the new output

closes #2970

Signed-off-by: Max Jonas Werner <max@e13.dev>
2022-08-10 14:37:28 +02:00
Stefan Prodan
75a879c770 OCI docs improvements
Co-authored-by: Kingdon Barrett <kingdon@weave.works>
Co-authored-by: Sunny <darkowlzz@protonmail.com>
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-10 12:02:30 +03:00
Stefan Prodan
d4c5a137a1 Add examples for pushing artifacts with GH Actions
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 13:51:14 +03:00
Stefan Prodan
d4718f6ff4 Improve artifact commands docs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 13:27:45 +03:00
Stefan Prodan
ac9b3d193d Update controllers with OCI support
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:45:33 +03:00
Stefan Prodan
7c7e76f9f0 Use fluxcd/pkg/oci/client
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:45:00 +03:00
Stefan Prodan
08401f62b2 Add OCI provider arg
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:45:00 +03:00
Kingdon Barrett
69e26ca1d9 Pull artifact not push artifact
Fixup docs string to match pull command

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2022-08-09 12:45:00 +03:00
Somtochi Onyekwere
41aac68193 Add link to kubectl repo
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-09 12:44:59 +03:00
Somtochi Onyekwere
fcd38c9395 Fix cli description
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-09 12:44:59 +03:00
Somtochi Onyekwere
fe4b65972a Update cli description
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-09 12:44:59 +03:00
Somtochi Onyekwere
4c576bf599 Add create oci secret command
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-09 12:44:59 +03:00
Stefan Prodan
70d30fd52e Update golden files to latest digest
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:59 +03:00
Stefan Prodan
803104578f Add make build-dev command
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:59 +03:00
Stefan Prodan
030b6bc77c Update source-controller with OCI metadata
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:59 +03:00
Somtochi Onyekwere
009413affd Add test for annotations
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-09 12:44:59 +03:00
Somtochi Onyekwere
9e76787e9f working golden files
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-09 12:44:58 +03:00
Somtochi Onyekwere
b78bbd5b9d fill test files
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-09 12:44:58 +03:00
Somtochi Onyekwere
3e15e83926 Add test for tag/list/build/pull/push artifacts
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-09 12:44:58 +03:00
Stefan Prodan
1b327e9d4e Show artifact digest in list output
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:58 +03:00
Stefan Prodan
7dd736954b Use OCI standard annotations
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:58 +03:00
Stefan Prodan
6b98590461 Add --cert-ref to flux create source oci
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:58 +03:00
Stefan Prodan
8049634e4d Add oci:// prefix
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:58 +03:00
Somtochi Onyekwere
adc7981f22 Add tests for source oci command
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-09 12:44:58 +03:00
Stefan Prodan
30e5389d02 Run e2e tests for PRs against oci branch
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:57 +03:00
Stefan Prodan
b6a78f42ea Update SC with OCI semver support
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:57 +03:00
Stefan Prodan
e4fb8e75f9 Add e2e tests for artifact commands
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:57 +03:00
Stefan Prodan
2f35367a7f Add list artifacts command
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:57 +03:00
Stefan Prodan
2d8db4f20d Implement OCIRepository commands
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:57 +03:00
Stefan Prodan
12a491f538 Update controllers to OCI preview images
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:57 +03:00
Stefan Prodan
9503ecafb1 Add artifact commands
Implement build, push, pull and tag artifact commands.
For authentication purposes, all `flux <verb> artifact` commands are using the '~/.docker/config.json' config file and the Docker credential helpers.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:57 +03:00
Stefan Prodan
e927d39a27 Add OCI internal package
Implement OCI artifacts operations using crane

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-09 12:44:56 +03:00
Stefan Prodan
ac50aea21f Merge pull request #2964 from pjbgf/clean-up
Add validation to namespace flag
2022-08-08 15:53:55 +03:00
Paulo Gomes
c45536723c add validation to namespace flag
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-08-08 12:52:02 +01:00
Paulo Gomes
fb1de8c649 remove unused func
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-08-05 19:07:04 +01:00
Stefan Prodan
e1c082e5ac Merge pull request #2955 from somtochiama/logs-test
fix log filter and add tests for `flux logs`
2022-08-03 10:19:25 +03:00
Somtochi Onyekwere
1889b64b4e remove print statement
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-02 19:55:52 +01:00
Somtochi Onyekwere
0cfdc5d674 move struct definition
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-02 19:46:19 +01:00
Somtochi Onyekwere
96afee996a Add unit tests for flux logs
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-08-02 19:44:23 +01:00
Stefan Prodan
da9747a406 Merge pull request #2951 from fluxcd/oci-oidc-auth
[RFC-0003] Add the provider field for OIDC auth
2022-08-02 13:03:56 +03:00
Stefan Prodan
36d219e05c [RFC-0003] Add the provider field for OIDC auth
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-08-02 11:46:20 +03:00
Hidde Beydals
ea2de24ade Merge pull request #2940 from fluxcd/fix-srcinfo-bin
AUR: further solve `.SRCINFO` issues
2022-07-28 16:27:01 +00:00
Hidde Beydals
f01911d0e2 AUR: further solve .SRCINFO issues
Due to the release CI job running on an Ubuntu machine, we do not have
easy access to `makepkg` to generate the `.SRCINFO` using `--printsrcinfo`
as this is a `pacman` specific utility, and instead we maintain a
template.

Historically seen, something went wrong here while the `PKGBUILD` file
became more complex and certain fields added there were not _also_
included in the `.SRCINFO` template.

This commit ensures everything is restored to working state, and
provides the proper fix for what was attempted in #2917. In addition,
checksums are now included in the file.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-07-28 15:48:27 +00:00
Hidde Beydals
43eb9327d5 Merge pull request #2937 from fluxcd/fix-srcinfo-bin
AUR: ensure `pkgname` is bottom entry in .SRCINFO
2022-07-28 07:41:02 +00:00
Hidde Beydals
ca212ac592 AUR: ensure pkgname is bottom entry in .SRCINFO
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-07-28 07:13:34 +00:00
Sunny
fe3e0efcf1 Merge pull request #2932 from fluxcd/update-components
Update toolkit components
2022-07-27 21:33:58 +05:30
fluxcdbot
ed7a880287 Update toolkit components
- source-controller to v0.25.11
  https://github.com/fluxcd/source-controller/blob/v0.25.11/CHANGELOG.md
- image-reflector-controller to v0.19.4
  https://github.com/fluxcd/image-reflector-controller/blob/v0.19.4/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-07-27 15:47:46 +00:00
Stefan Prodan
e94853f023 Merge pull request #2917 from morancj/aur-srcinfo
SRCINFO: fix path
2022-07-26 14:27:01 +02:00
Ciaran Moran
cbecd8ab56 SRCINFO: consistent style
Signed-off-by: Ciaran Moran <ciaran@weave.works>
2022-07-18 11:48:38 +01:00
Ciaran Moran
feaab54f70 SRCINFO: fix path
Signed-off-by: Ciaran Moran <ciaran@weave.works>
2022-07-18 11:29:15 +01:00
Paulo Gomes
02e12cf871 Merge pull request #2905 from fluxcd/update-components
Update toolkit components
2022-07-18 09:06:13 +01:00
fluxcdbot
7aeec0a0c4 Update toolkit components
- helm-controller to v0.22.2
  https://github.com/fluxcd/helm-controller/blob/v0.22.2/CHANGELOG.md
- kustomize-controller to v0.26.3
  https://github.com/fluxcd/kustomize-controller/blob/v0.26.3/CHANGELOG.md
- source-controller to v0.25.10
  https://github.com/fluxcd/source-controller/blob/v0.25.10/CHANGELOG.md
- notification-controller to v0.24.1
  https://github.com/fluxcd/notification-controller/blob/v0.24.1/CHANGELOG.md
- image-reflector-controller to v0.19.3
  https://github.com/fluxcd/image-reflector-controller/blob/v0.19.3/CHANGELOG.md
- image-automation-controller to v0.23.5
  https://github.com/fluxcd/image-automation-controller/blob/v0.23.5/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-07-15 18:02:07 +00:00
Stefan Prodan
abeea06e72 Merge pull request #2601 from fluxcd/rfc-kubernetes-oci
[RFC-0003] Flux OCI support for Kubernetes manifests
2022-07-08 12:11:29 +03:00
Stefan Prodan
4a55b828b1 Mark RFC-0003 as implementable
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 17:02:19 +03:00
Stefan Prodan
6b9c0a5e48 Add oci:// proto to the spec
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:45 +03:00
Stefan Prodan
e060873246 Add examples for flux build, push and list commands
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:42 +03:00
Stefan Prodan
143609b9fb Add specification for spec.url
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:41 +03:00
Stefan Prodan
a22438b7fa Add design details
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:41 +03:00
Stefan Prodan
34321983e7 Add OCI artifact type to alternatives
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:41 +03:00
Stefan Prodan
44762933b3 Add flux tag artifact command
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:41 +03:00
Stefan Prodan
2912d1d437 Add serviceAccountName to auth spec
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:41 +03:00
Stefan Prodan
4885278691 Restructure the OCI auth spec
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:41 +03:00
Stefan Prodan
8a7c94180b Add client certificate authentication
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:41 +03:00
Stefan Prodan
183b9a7ee0 Add auto-login feature
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:41 +03:00
Stefan Prodan
0fc582d6fd Add user stories for publishing and reconciling OCI artifacts
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:40 +03:00
Stefan Prodan
c7a6ed53ca Add proposal for adding OCI support for Kubernetes manifests to Flux
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-07-06 16:57:40 +03:00
Stefan Prodan
547e39d24c Merge pull request #2881 from fluxcd/update-components
Update toolkit components
2022-06-29 16:36:18 +03:00
fluxcdbot
115b58fe49 Update toolkit components
- kustomize-controller to v0.26.2
  https://github.com/fluxcd/kustomize-controller/blob/v0.26.2/CHANGELOG.md
- source-controller to v0.25.9
  https://github.com/fluxcd/source-controller/blob/v0.25.9/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-06-29 13:14:11 +00:00
Stefan Prodan
613e270d00 Merge pull request #2851 from TianZong48/fix-logs-stream
logs: write into writer from io.Pipe instead of os.Stdout
2022-06-28 19:27:30 +03:00
TianZong48
c24e738973 logs: write into writer from io.Pipe instead os.Stdout
Signed-off-by: TianZong48 <tianzong48@gmail.com>
2022-06-28 23:27:32 +08:00
Stefan Prodan
e2fb6089c9 Merge pull request #2877 from sympatheticmoose/patch-1
Add the `--branch` arg to the basic auth example
2022-06-28 14:43:42 +03:00
David Harris
95eb7aede0 add branch to basic auth example
Without a reference specified, the create command will fail. 

Signed-off-by: David Harris <david.harris@weave.works>
2022-06-27 21:08:48 +01:00
Stefan Prodan
3cef177e24 Merge pull request #2839 from fluxcd/update-components
Update toolkit components
2022-06-24 16:36:58 +03:00
fluxcdbot
c430556498 Update toolkit components
- source-controller to v0.25.8
  https://github.com/fluxcd/source-controller/blob/v0.25.8/CHANGELOG.md
- image-reflector-controller to v0.19.2
  https://github.com/fluxcd/image-reflector-controller/blob/v0.19.2/CHANGELOG.md
- image-automation-controller to v0.23.4
  https://github.com/fluxcd/image-automation-controller/blob/v0.23.4/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-06-24 12:29:23 +00:00
Stefan Prodan
ff9c982df4 Merge pull request #2867 from fluxcd/image-finalizers
Remove image finalizers on uninstall
2022-06-24 12:46:28 +03:00
Stefan Prodan
724c93c23d Remove image finalizers on uninstall
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-24 11:34:53 +03:00
Hidde Beydals
769e20423d Merge pull request #2844 from fluxcd/fix-logs-multiple-containers
logs: select manager container when multiple exist
2022-06-23 14:14:58 +02:00
Hidde Beydals
d12e697769 logs: select manager container when multiple exist
This sets the container to `manager` which is used by all Flux
controllers as the container name.

The other options I thought about were selecting the first, or doing
something with image detection. But both can be sensitive to either
users adding their patch as a first entry, or e.g. mirroring the image
to a different name.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-06-23 13:52:08 +02:00
Stefan Prodan
874b05c5da Merge pull request #2829 from SomtochiAma/update-valuesFrom
Accept multiple values for `flux create hr --values-from`
2022-06-23 14:25:11 +03:00
Somtochi Onyekwere
1894b90d84 Accept multiple valuesFrom for create_helmrelease
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-06-23 09:09:22 +01:00
Stefan Prodan
cdf5bf3c9e Merge pull request #2862 from bplasmeijer/bugs/monitoring-configmap-in-wrong-namespace
Put the dashboard configmap in the right namespace for monitoring
2022-06-23 08:47:19 +03:00
bart-plasmeijer
5f35bd4e00 put the dashboard config map in the right namespace
Signed-off-by: Bart Plasmeijer <bart.plasmeijer@gmail.com>
2022-06-22 23:05:48 +02:00
Stefan Prodan
12504c76d0 Merge pull request #2859 from SomtochiAma/oci-success-msg
Return different success message for `oci` type - `reconcile_source_helm`
2022-06-22 18:37:11 +03:00
Somtochi Onyekwere
7346b1a762 Return a different success message for helm oci
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-06-22 12:03:20 +01:00
Stefan Prodan
f7d616d223 Merge pull request #2823 from fluxcd/check-crds
Add CRDs to `flux check` command
2022-06-10 12:00:45 +03:00
Stefan Prodan
443e5b5539 Fail check if no controllers or crds are found
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-09 09:27:27 +03:00
Stefan Prodan
f6c14c939d Add CRDs to flux check command
Verify that the Flux CRDs are registered on the cluster and print their version.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-09 09:17:15 +03:00
Stefan Prodan
a602c57e5d Merge pull request #2820 from fluxcd/update-pkgs
Update dependencies
2022-06-08 15:59:06 +03:00
Stefan Prodan
9ae41899a8 Update go-getter to fix CVEs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-08 15:33:47 +03:00
Stefan Prodan
cfdd5f0284 Update kubectl to v1.24.1 in flux-cli image
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-08 15:27:08 +03:00
Stefan Prodan
04b0a0a7ae Update dependencies
- fluxcd/pkg/kustomize v0.5.2
- fluxcd/pkg/runtime v0.16.2
- fluxcd/pkg/ssa v0.17.0
- fluxcd/pkg/ssh v0.5.0
- cli-utils v0.31.2

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-08 15:26:33 +03:00
Stefan Prodan
83fcac1868 Merge pull request #2814 from fluxcd/update-components
Update toolkit components
2022-06-08 15:20:41 +03:00
fluxcdbot
efb0ecb4f9 Update toolkit components
- helm-controller to v0.22.1
  https://github.com/fluxcd/helm-controller/blob/v0.22.1/CHANGELOG.md
- kustomize-controller to v0.26.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.26.1/CHANGELOG.md
- source-controller to v0.25.5
  https://github.com/fluxcd/source-controller/blob/v0.25.5/CHANGELOG.md
- image-reflector-controller to v0.19.1
  https://github.com/fluxcd/image-reflector-controller/blob/v0.19.1/CHANGELOG.md
- image-automation-controller to v0.23.2
  https://github.com/fluxcd/image-automation-controller/blob/v0.23.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-06-08 12:02:56 +00:00
Stefan Prodan
7498d516d4 Merge pull request #2811 from fluxcd/rfc-0002-status-update
[RFC-0002] Update status and implementation history
2022-06-07 12:47:58 +03:00
Stefan Prodan
2fe3362c3d [RFC-0002] Update status and implementation history
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-07 12:21:19 +03:00
Stefan Prodan
6473331399 Merge pull request #2809 from fluxcd/update-components
Update source-controller to v0.25.3
2022-06-06 16:12:30 +03:00
fluxcdbot
6f85363e58 Update toolkit components
- source-controller to v0.25.3
  https://github.com/fluxcd/source-controller/blob/v0.25.3/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-06-06 12:39:05 +00:00
Stefan Prodan
02c0d3bd0d Merge pull request #2807 from fluxcd/update-azure-deps
Update dependencies
2022-06-04 08:12:50 +03:00
Stefan Prodan
f1f4cc007a Update dependencies
- sync tests/azure with main go.mod
- update homeport/dyff to v1.5.4
- update k8s.io/apiextensions-apiserver to v0.24.1

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-03 17:51:43 +03:00
Stefan Prodan
7293771766 Merge pull request #2796 from fluxcd/update-components
Update toolkit components
2022-06-03 17:41:06 +03:00
fluxcdbot
25d065c211 Update toolkit components
- helm-controller to v0.22.0
  https://github.com/fluxcd/helm-controller/blob/v0.22.0/CHANGELOG.md
- source-controller to v0.25.2
  https://github.com/fluxcd/source-controller/blob/v0.25.2/CHANGELOG.md
- image-automation-controller to v0.23.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.23.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-06-03 14:01:51 +00:00
Stefan Prodan
bf14f47459 Merge pull request #2806 from fluxcd/monitoring-logs
monitoring: Add Grafana Loki HR and Flux logs dashboard
2022-06-03 13:24:37 +03:00
Stefan Prodan
8576073b9d monitoring: Add Grafana Loki HR and Flux logs dashboard
- add loki-stack HelmRelease to install Loki and Promtail in the monitoring namespace
- make the loki-stack HelmRelease depend on kube-prometheus-stack to install Loki's datasource and service monitors in the correct order
- add a Grafana dashboard for displaying and filtering the Flux controllers JSON logs

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-03 12:50:41 +03:00
Max Jonas Werner
cbe1331815 Merge pull request #2802 from fluxcd/kubeconfig-secret-ref
Add `--kubeconfig-secret-ref` to `flux create ks|hr`
2022-06-02 15:49:19 +02:00
Stefan Prodan
998b763cf9 Add --kubeconfig-secret-ref to flux create ks|hr
Allow specifying the name of the Kubernetes Secret that contains a key with the kubeconfig file for connecting to a remote cluster.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-02 16:10:31 +03:00
Stefan Prodan
15e8f106ce Merge pull request #2801 from fluxcd/e2e-arm64-kube-1.24
e2e: Update ARM64 runners to Kubernetes 1.24
2022-06-02 15:33:02 +03:00
Stefan Prodan
9aee262054 e2e: Update ARM64 runners to Kubernetes 1.24
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-06-02 15:18:01 +03:00
Stefan Prodan
c718336143 Merge pull request #2792 from SomtochiAma/flux-diff
Handle multi-doc yaml for flux build
2022-06-02 15:08:27 +03:00
Somtochi Onyekwere
355ed94852 check for correct kustomization in multi-doc yaml
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-06-02 11:23:58 +01:00
Stefan Prodan
56c5e784fb Merge pull request #2787 from vipulnewaskar7/main
Add `--allow-insecure-http` to `bootstrap git`
2022-06-02 13:19:33 +03:00
Vipul Newaskar
0a30bc1024 allow http git repos connections while bootstrap
Updated misleading error message

Signed-off-by: Vipul Newaskar <vipulnewaskar7@gmail.com>
2022-06-02 10:32:58 +05:30
Vipul Newaskar
a55548de07 allow http git repos connections while bootstrap
This change will allow user to bootstrap with http git urls
But user must explicitely set --allow-insecure-http=true

Signed-off-by: Vipul Newaskar <vipulnewaskar7@gmail.com>
2022-06-02 10:32:58 +05:30
Stefan Prodan
b84e613b5e Merge pull request #2781 from fluxcd/create-source-helm-oci
Add OCI support to `create source helm`
2022-06-01 20:29:40 +03:00
Max Jonas Werner
6b9e6cb9a5 Merge branch 'main' into create-source-helm-oci 2022-06-01 16:35:26 +02:00
Max Jonas Werner
f24c4034e2 Merge pull request #2775 from fluxcd/update-components
Update toolkit components
2022-06-01 16:35:02 +02:00
fluxcdbot
797352e4fa Update toolkit components
- kustomize-controller to v0.26.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.26.0/CHANGELOG.md
- source-controller to v0.25.0
  https://github.com/fluxcd/source-controller/blob/v0.25.0/CHANGELOG.md
- notification-controller to v0.24.0
  https://github.com/fluxcd/notification-controller/blob/v0.24.0/CHANGELOG.md
- image-reflector-controller to v0.19.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.19.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-06-01 14:08:16 +00:00
Max Jonas Werner
7d742924f6 bump SC version in azure test module
Signed-off-by: Max Jonas Werner <mail@makk.es>
2022-06-01 16:06:45 +02:00
Max Jonas Werner
e19ea796b1 Add OCI support to create source helm
closes #2774

Signed-off-by: Max Jonas Werner <mail@makk.es>
2022-06-01 15:59:52 +02:00
Stefan Prodan
bcef28e80b Merge pull request #2782 from fluxcd/monitoring-refactoring
Refactor Flux Prometheus monitoring stack
2022-05-30 11:02:21 +03:00
Stefan Prodan
4acef9d508 Add Flux events to dashboard annotations
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-29 17:46:02 +03:00
Stefan Prodan
8128fc190d Update kube-prometheus-stack chart to v35
- Automate kube-prometheus-stack helm release upgrades for the v35.x range
- Remove deprecated Grafana settings
- Set Prometheus retention to 24h
- Label Flux dashboards and PodMonitors with `app.kubernetes.io/component: monitoring`
- Change the `podMonitorSelector` to match the label `app.kubernetes.io/component: monitoring`

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-29 16:14:18 +03:00
Stefan Prodan
2ba0c4435e Remove deprecated monitoring stack
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-29 16:09:57 +03:00
Stefan Prodan
b8164717da Merge pull request #2767 from takirala/tga/add-ignore-field
Add `--ignore-paths` flag to `flux create source (git|bucket)`
2022-05-28 16:02:34 +03:00
Tarun Gupta Akirala
ed88e9dec5 feat: add --ignore-paths flag to flux create source (git|bucket)
A new --ignore-paths flag is added to following commands:

flux create source git --ignore-paths ...
flux create source bucket --ignore-paths ...

A StringSliceVar is used which supports specifying the flag multiple
times to populate a list or either a comma seperated string value

A unit test with a golden file is added to validate the flag

Signed-off-by: Tarun Gupta Akirala <takirala@users.noreply.github.com>
2022-05-27 09:45:25 -07:00
Stefan Prodan
5ebb985b10 Merge pull request #2778 from fluxcd/go-git-providers
Update go-git-providers to v0.6.0
2022-05-27 17:43:32 +03:00
Stefan Prodan
7f5f80286e Update go-git-providers to v0.6.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-27 17:17:02 +03:00
Stefan Prodan
3cd0bc9672 Merge pull request #2773 from fluxcd/update-deps
Update dependencies
2022-05-27 14:52:11 +03:00
Stefan Prodan
95f896e92c Update fluxcd/pkg/ssh to v0.4.1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-27 14:24:25 +03:00
Stefan Prodan
0b9e3d24ef Update GitHub actions
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-27 13:35:13 +03:00
Stefan Prodan
3f0efc9435 Update dependencies
- Update Kubernetes packages to v1.24
- Update go-yaml to v3.0.0 (fix CVE-2022-28948)
- Update fluxcd/pkg/runtime to v0.15.1

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-27 13:29:20 +03:00
Stefan Prodan
64205cf523 Merge pull request #2727 from thedataflows/thedataflows/grafana-dashboard
grafana: display exported ns, slight resizing, default sorting by state
2022-05-26 14:46:22 +03:00
Cristian Chiru
38c62d46c7 [grafana dashboard] display exported namespace, slight resizing, default sorting by state
Signed-off-by: Cristian Chiru <cristi.chiru@gmail.com>
2022-05-26 14:21:39 +03:00
Stefan Prodan
b1ac3a26f4 Merge pull request #2769 from fluxcd/go-1.18
Update Go to 1.18 in CI
2022-05-25 13:47:43 +03:00
Stefan Prodan
b795e612f7 Update Go to v1.18
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-25 11:43:30 +03:00
Stefan Prodan
a1a2286794 Update Alpine to v3.16
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-25 11:04:26 +03:00
Hidde Beydals
8c5d83d9fe Merge pull request #2764 from fluxcd/fix-rel-paths-custom-bootstrap
Ensure proper FS root is set while bootstrapping
2022-05-24 12:40:46 +02:00
Hidde Beydals
5130a154e4 Ensure proper FS root is set while bootstrapping
This ensures relative paths to e.g. bases can be used.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-24 12:14:21 +02:00
Max Jonas Werner
938f2570ef Merge pull request #2747 from dholbach/update-maintainers-file
Move MAINTAINERS to f/community
2022-05-18 18:16:10 +02:00
Daniel Holbach
97a7b4450f Move MAINTAINERS to f/community
Signed-off-by: Daniel Holbach <daniel@weave.works>
2022-05-18 17:28:49 +02:00
Max Jonas Werner
46fbc7c71b Merge pull request #2748 from makkes/debug-e2e-failure
fix e2e tests
2022-05-18 17:28:28 +02:00
Max Jonas Werner
e35da1c890 trim prefix from server version
It's not part of the `flux check` output.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2022-05-18 17:08:50 +02:00
Max Jonas Werner
9af6175302 fix e2e check test
The output of `kubectl version` has changed with newer kubectl version
from

```
{
  "serverVersion": ...,
  "clientVersion": ...
}
```

to

```
{
  "serverVersion": ...,
  "clientVersion": ...,
  "kustomizeVersion": ...
}
```

So the `kustomizeVersion` field is new which causes the JSON
unmarshaling to fail.

We now just unmarshal it to `map[string]interface{}` and peel the
server git version out of that map manually w/o unmarshalling the JSON
into a custom type.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2022-05-18 16:51:18 +02:00
Max Jonas Werner
e1def4f8ac make e2e test easier to debug
Signed-off-by: Max Jonas Werner <mail@makk.es>
2022-05-18 16:36:18 +02:00
Hidde Beydals
e09078f697 Merge pull request #2703 from aryan9600/fix-securefs-macos 2022-05-04 11:58:16 +02:00
Sanskar Jaiswal
7232ff9ea0 modify tmp dir generation to be absolute on all OSes
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2022-05-04 15:13:39 +05:30
Stefan Prodan
45876a723c Merge pull request #2701 from fluxcd/add-sa-read
Grant service account read-only access to controllers
2022-05-04 11:33:15 +03:00
Stefan Prodan
1ece35e4c5 Add leader election required permissions
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-04 11:11:51 +03:00
Stefan Prodan
5dee903374 Grant service account read-only access to controllers
For image automation to use a service account to authenticate to container registries, the controllers needs read-only access to service accounts.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-04 10:47:04 +03:00
Stefan Prodan
4dd20af7e0 Merge pull request #2700 from fluxcd/fix-bootstrap-fs
MacOS: fix bootstrap manifest generation
2022-05-04 10:01:42 +03:00
Stefan Prodan
b9fbdfc9a4 Fix bootstrap manifest generation
Use the OS package to write the generated files on disk instead of Flux  secure FS package which is meant for read operations.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-05-04 09:41:26 +03:00
Hidde Beydals
ab00e348a4 Merge pull request #2698 from fluxcd/update-deps 2022-05-03 21:26:22 +02:00
Hidde Beydals
b5c0ae9d5a build: update various CI dependencies
- kind to v0.12.0
- kubectl to v1.23.6
- helm to v3.8.2
- runner to v2.291.1

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-03 21:07:35 +02:00
Hidde Beydals
8e4044eed9 Update dependencies
- github.com/fluxcd/pkg/runtime to v0.14.2
- github.com/google/go-cmp to v0.5.8
- golang.org/x/crypto to v0.0.0-20220427172511-eb4f295cb31f
- k8s.io/cli-runtime to v0.23.6
- k8s.io/kubectl to v0.23.6

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-03 21:07:35 +02:00
Hidde Beydals
7034ef46af Merge pull request #2695 from fluxcd/update-components 2022-05-03 20:45:53 +02:00
Hidde Beydals
8dfbe952ae tests/azure: update toolkit components
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-03 20:19:29 +02:00
fluxcdbot
f1e9da56dc Update toolkit components
- helm-controller to v0.21.0
  https://github.com/fluxcd/helm-controller/blob/v0.21.0/CHANGELOG.md
- kustomize-controller to v0.25.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.25.0/CHANGELOG.md
- source-controller to v0.24.4
  https://github.com/fluxcd/source-controller/blob/v0.24.4/CHANGELOG.md
- notification-controller to v0.23.5
  https://github.com/fluxcd/notification-controller/blob/v0.23.5/CHANGELOG.md
- image-reflector-controller to v0.18.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.18.0/CHANGELOG.md
- image-automation-controller to v0.22.1
  https://github.com/fluxcd/image-automation-controller/blob/v0.22.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-05-03 18:17:11 +00:00
Hidde Beydals
f924c5f76d Merge pull request #2651 from fluxcd/customize-kustomize-fs 2022-05-03 14:25:27 +02:00
Hidde Beydals
57442e8faa kustomize: use FS from fluxcd/pkg
This switches to a secure FS implementation in most places, except for
where we can not make changes at this moment because it would break
behavior.

Not handled in this commit:

- Allowing the root for `manifestgen` packages to be configured.
- Allowing the user to define a working root while building locally.
- Defaulting to the secure FS implementation in
  `kustomization.MakeDefaultOptions`. Problem here is that constructing
  the secure FS could result in an error, which we can not surface
  without signature changes to the constructor func.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-03 13:52:51 +02:00
Hidde Beydals
95bfd3b3a4 Merge pull request #2686 from fluxcd/update-components 2022-04-28 11:03:09 +02:00
Hidde Beydals
2858e83fe1 tests/azure: update toolkit components
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-28 10:42:42 +02:00
fluxcdbot
5430152c7f Update toolkit components
- kustomize-controller to v0.24.4
  https://github.com/fluxcd/kustomize-controller/blob/v0.24.4/CHANGELOG.md
- source-controller to v0.24.3
  https://github.com/fluxcd/source-controller/blob/v0.24.3/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-04-28 08:35:38 +00:00
Stefan Prodan
3433079121 Merge pull request #2638 from pjbgf/paulo-maintainers
Add Paulo Gomes to maintainer's list
2022-04-27 15:32:19 +03:00
Paulo Gomes
151b84b8fe Add Paulo Gomes to maintainer's list
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-04-27 13:07:07 +01:00
Hidde Beydals
e3e01cb5da Merge pull request #2679 from fluxcd/update-components 2022-04-26 09:51:17 +02:00
Hidde Beydals
c4c890d4e9 tests/azure: update toolkit components
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-26 09:31:11 +02:00
fluxcdbot
64a473db2e Update toolkit components
- source-controller to v0.24.2
  https://github.com/fluxcd/source-controller/blob/v0.24.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-04-26 07:29:06 +00:00
Hidde Beydals
cc9bcbaefd Merge pull request #2668 from fluxcd/update-components 2022-04-22 12:26:17 +02:00
Hidde Beydals
787d491bd5 tests/azure: update toolkit components
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-22 12:09:27 +02:00
fluxcdbot
5c4991299c Update toolkit components
- kustomize-controller to v0.24.3
  https://github.com/fluxcd/kustomize-controller/blob/v0.24.3/CHANGELOG.md
- source-controller to v0.24.1
  https://github.com/fluxcd/source-controller/blob/v0.24.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-04-22 10:09:00 +00:00
Hidde Beydals
33ac3ef2c6 Merge pull request #2662 from fluxcd/update-components 2022-04-21 11:52:23 +02:00
Hidde Beydals
c7504442bd tests/azure: update toolkit components
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-21 11:31:07 +02:00
fluxcdbot
1a546a1d82 Update toolkit components
- kustomize-controller to v0.24.2
  https://github.com/fluxcd/kustomize-controller/blob/v0.24.2/CHANGELOG.md
- notification-controller to v0.23.4
  https://github.com/fluxcd/notification-controller/blob/v0.23.4/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-04-21 09:29:20 +00:00
Hidde Beydals
713365a12c Merge pull request #2657 from fluxcd/update-kc 2022-04-20 18:08:22 +02:00
Hidde Beydals
5d8248d31d Update kustomize-controller to v0.24.1
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-20 17:34:12 +02:00
Hidde Beydals
5346c1cca3 Merge pull request #2652 from fluxcd/update-components 2022-04-20 12:28:48 +02:00
Hidde Beydals
baadaa05d2 tests/azure: Update toolkit components
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-20 11:49:49 +02:00
fluxcdbot
224a1ce941 Update toolkit components
- helm-controller to v0.20.1
  https://github.com/fluxcd/helm-controller/blob/v0.20.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-04-20 09:46:28 +00:00
Hidde Beydals
52f1bfed4c Merge pull request #2646 from aryan9600/fix-mask-sops 2022-04-19 20:05:14 +02:00
Sanskar Jaiswal
5c9cbe676d handle secret types properly while masking sops data
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2022-04-19 23:12:00 +05:30
Hidde Beydals
e25bb74c05 Merge pull request #2649 from fluxcd/update-deps 2022-04-19 19:21:45 +02:00
Hidde Beydals
c2f465e246 Update dependencies
- github.com/ProtonMail/go-crypto to v0.0.0-20220407094043-a94812496cf5
- github.com/fluxcd/pkg/kustomize to v0.2.0
- github.com/fluxcd/pkg/runtime to v0.14.1
- github.com/fluxcd/pkg/ssa to v0.15.2
- golang.org/x/crypto to v0.0.0-20220411220226-7b82a4e95df4
- golang.org/x/term to v0.0.0-20220411215600-e5f449aeb171
- k8s.io/cli-runtime to v0.23.5
- k8s.io/kubectl to v0.23.5
- sigs.k8s.io/cli-utils to v0.29.4
- sigs.k8s.io/kustomize/api to v0.11.4
- sigs.k8s.io/kustomize/kyaml to v0.13.6

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-19 18:27:33 +02:00
Hidde Beydals
6bbbf16140 tests/azure: update dependencies
This does not include an update of `github.com/hashicorp/terraform-exec`
to `v0.16.1`, as it contains a breaking change. `tfinstall` has been
removed and needs to be replaced with `github.com/hashicorp/hc-install`.

- github.com/fluxcd/helm-controller/api to v0.20.0
- github.com/fluxcd/image-automation-controller/api to v0.22.0
- github.com/fluxcd/image-reflector-controller/api to v0.17.2
- github.com/fluxcd/kustomize-controller/api to v0.24.0
- github.com/fluxcd/notification-controller/api to v0.23.3
- github.com/fluxcd/pkg/apis/meta to v0.12.2
- github.com/fluxcd/pkg/runtime to v0.14.1
- github.com/fluxcd/source-controller/api to v0.24.0
- k8s.io/api to v0.23.5
- k8s.io/apimachinery to v0.23.5
- k8s.io/client-go to v0.23.5
- sigs.k8s.io/controller-runtime to v0.11.2

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-19 18:23:42 +02:00
Hidde Beydals
c5cdb70031 Merge pull request #2617 from fluxcd/update-components 2022-04-19 18:20:30 +02:00
fluxcdbot
2955cd70a8 Update toolkit components
- helm-controller to v0.20.0
  https://github.com/fluxcd/helm-controller/blob/v0.20.0/CHANGELOG.md
- kustomize-controller to v0.24.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.24.0/CHANGELOG.md
- source-controller to v0.24.0
  https://github.com/fluxcd/source-controller/blob/v0.24.0/CHANGELOG.md
- notification-controller to v0.23.3
  https://github.com/fluxcd/notification-controller/blob/v0.23.3/CHANGELOG.md
- image-reflector-controller to v0.17.2
  https://github.com/fluxcd/image-reflector-controller/blob/v0.17.2/CHANGELOG.md
- image-automation-controller to v0.22.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.22.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-04-19 15:45:35 +00:00
Stefan Prodan
7b4940914c Merge pull request #2597 from fluxcd/rfc-helm-oci
[RFC-0002] Flux OCI support for Helm
2022-04-13 11:01:25 +03:00
Stefan Prodan
30f977a7cb Assign RFC-0002 to Helm OCI proposal
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-04-13 10:27:11 +03:00
Stefan Prodan
e06fa24616 Add dedicated reconcilers to the design docs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-04-12 15:09:51 +03:00
Stefan Prodan
20d7d0c78a Add image registry example to story 2
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-04-12 15:08:31 +03:00
Stefan Prodan
606078c1b3 Add chart update automation to Git
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-04-12 15:08:31 +03:00
Stefan Prodan
0135eb19d4 Add proposal for adding Helm OCI support to Flux Source API
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-04-12 15:08:30 +03:00
Stefan Prodan
8b989190c4 Merge pull request #2631 from canidam/add-bootstrap-git-pass-from-stdin-and-env
bootstrap git: Allow the password to be specified with GIT_PASSWORD env var
2022-04-12 14:59:17 +03:00
Chen Anidam
a85ea59824 Read password of generic git bootstrap command from env or stdin
Signed-off-by: Chen Anidam <canidam@gmail.com>
2022-04-12 12:17:11 +03:00
Stefan Prodan
d012f0f2bc Merge pull request #2624 from kingdonb/docs-when-prune-enabled
Add detail to delete docs
2022-04-07 19:47:22 +03:00
Kingdon Barrett
7e2b63ea5d add detail to delete docs
Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2022-04-07 08:29:57 -04:00
Stefan Prodan
cb53243fc1 Merge pull request #2611 from souleb/diff-local-kustomization
Add an option to diff with a local Flux Kustomization file
2022-04-05 19:40:11 +03:00
Soule BA
5536af9756 Add an option to diff with a local kustomization file
If implemented, users will be able to provide a local kustomization file
to `flux build/diff`.

Signed-off-by: Soule BA <soule@weave.works>
2022-04-05 17:21:11 +02:00
Stefan Prodan
28087c1d76 Merge pull request #2616 from SomtochiAma/resume-all-wait
Add cli flags for chart interval and reconcile strategy
2022-04-05 17:19:07 +03:00
Somtochi Onyekwere
b80f32ce7d Add cli flags for chart interval and reconcile strategy
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-04-05 12:56:50 +01:00
Stefan Prodan
8bad59ebde Merge pull request #2609 from darkowlzz/grafana-dashboard-labelvalues
monitoring-config: set grafana dashboards labelValues
2022-04-03 09:46:23 +03:00
Sunny
b44e4617e0 monitoring-config: grafana dashboards labelValue
Since kube-prometheus-stack helm chart v32.2.0, the `labelValue` has to
be set to "1" for the default grafana dashboard label selector to select
the flux dashboard configuration.

Also, update kube-prometheus-stack to v34.7.0, latest.

Refer: eba5b198f5

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2022-04-02 23:55:11 +05:30
Stefan Prodan
5d99e3d191 Merge pull request #2607 from souleb/issue-2598
[Diff] Update pkg/kustomize to v0.1.0
2022-04-01 17:45:01 +03:00
Soule BA
1807852b6b Update pkg/kustomize to v0.1.0
If implemented this fixes a bug where retrieving the groupVersion.Group
of a kustomization were returning an empty string.

Signed-off-by: Soule BA <soule@weave.works>
2022-04-01 10:27:37 +02:00
Hidde Beydals
4f4a5c0ba0 Merge pull request #2594 from fluxcd/update-components 2022-03-30 20:41:16 +02:00
fluxcdbot
24188e58ff Update toolkit components
- kustomize-controller to v0.22.3
  https://github.com/fluxcd/kustomize-controller/blob/v0.22.3/CHANGELOG.md
- source-controller to v0.22.5
  https://github.com/fluxcd/source-controller/blob/v0.22.5/CHANGELOG.md
- notification-controller to v0.23.2
  https://github.com/fluxcd/notification-controller/blob/v0.23.2/CHANGELOG.md
- image-automation-controller to v0.21.3
  https://github.com/fluxcd/image-automation-controller/blob/v0.21.3/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-03-30 17:39:09 +00:00
Stefan Prodan
e2be598988 Merge pull request #2584 from souleb/update-homeport-dyff
Diff: Update homeport/Dyff to v1.5.2
2022-03-29 10:16:39 +03:00
Soule BA
9e2a4f329b Update homeport/Dyff to v1.5.2
If implmented, this will provide an inline diff for configmaps with the
command `flux diff``.

Signed-off-by: Soule BA <soule@weave.works>
2022-03-29 08:52:53 +02:00
Stefan Prodan
574b86cbca Merge pull request #2534 from jooooel/joel/update_docs
Add coreutils (for Mac OS) as a dependency
2022-03-29 08:26:45 +03:00
jooooel
4b7042cc46 Add coreutils (for Mac OS) as a dependency
Signed-off-by: jooooel <jooooel@users.noreply.github.com>
2022-03-28 20:34:07 +02:00
Sunny
5ae4711f7b Merge pull request #2583 from fluxcd/update-components
Update toolkit components
2022-03-28 22:41:58 +05:30
fluxcdbot
97a53b1536 Update toolkit components
- source-controller to v0.22.4
  https://github.com/fluxcd/source-controller/blob/v0.22.4/CHANGELOG.md
- image-automation-controller to v0.21.2
  https://github.com/fluxcd/image-automation-controller/blob/v0.21.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-03-28 16:52:13 +00:00
Hidde Beydals
cc982cf3b1 Merge pull request #2577 from fluxcd/update-components 2022-03-25 19:10:52 +01:00
fluxcdbot
3f652f8b05 Update toolkit components
- helm-controller to v0.18.2
  https://github.com/fluxcd/helm-controller/blob/v0.18.2/CHANGELOG.md
- kustomize-controller to v0.22.2
  https://github.com/fluxcd/kustomize-controller/blob/v0.22.2/CHANGELOG.md
- source-controller to v0.22.3
  https://github.com/fluxcd/source-controller/blob/v0.22.3/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-03-25 17:50:26 +00:00
Hidde Beydals
dcd86dec6e Merge pull request #2572 from fluxcd/client-rate-limit-args 2022-03-25 11:08:07 +01:00
Stefan Prodan
0d8194c800 Add the kube client qps and burst to the global args
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-03-25 10:43:59 +01:00
Stefan Prodan
150d9d7ae6 Merge pull request #2570 from fluxcd/update-components
Update toolkit components
2022-03-24 09:45:29 +02:00
Stefan Prodan
694f1797d2 Update packages for Azure e2e testing
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-03-24 09:23:35 +02:00
fluxcdbot
116be0cfed Update toolkit components
- kustomize-controller to v0.22.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.22.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-03-24 07:01:20 +00:00
Hidde Beydals
aa2b5ae18d Merge pull request #2569 from fluxcd/update-components 2022-03-23 21:47:35 +01:00
Hidde Beydals
e2ccbe2088 tests/azure: update toolkit components
- helm-controller to v0.18.1
  https://github.com/fluxcd/helm-controller/blob/v0.18.1/CHANGELOG.md
- source-controller to v0.22.2
  https://github.com/fluxcd/source-controller/blob/v0.22.2/CHANGELOG.md
- notification-controller to v0.23.1
  https://github.com/fluxcd/notification-controller/blob/v0.23.1/CHANGELOG.md
- image-reflector-controller to v0.17.1
  https://github.com/fluxcd/image-reflector-controller/blob/v0.17.1/CHANGELOG.md
- image-automation-controller to v0.21.1
  https://github.com/fluxcd/image-automation-controller/blob/v0.21.1/CHANGELOG.md

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-23 21:33:34 +01:00
Hidde Beydals
775891fc88 build: ensure component update runs with make tidy
This to include the `-compat` flag.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-23 21:32:00 +01:00
fluxcdbot
c85954ddef Update toolkit components
- helm-controller to v0.18.1
  https://github.com/fluxcd/helm-controller/blob/v0.18.1/CHANGELOG.md
- source-controller to v0.22.2
  https://github.com/fluxcd/source-controller/blob/v0.22.2/CHANGELOG.md
- notification-controller to v0.23.1
  https://github.com/fluxcd/notification-controller/blob/v0.23.1/CHANGELOG.md
- image-reflector-controller to v0.17.1
  https://github.com/fluxcd/image-reflector-controller/blob/v0.17.1/CHANGELOG.md
- image-automation-controller to v0.21.1
  https://github.com/fluxcd/image-automation-controller/blob/v0.21.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-03-23 21:30:38 +01:00
Hidde Beydals
dd6db2cbd9 Merge pull request #2566 from fluxcd/fix-resume-bucket 2022-03-23 14:50:41 +01:00
Stefan Prodan
5f74c7d294 Fix resume source bucket panic
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-03-23 15:33:57 +02:00
Hidde Beydals
ed87a632b0 Merge pull request #2565 from fluxcd/source-create-wait 2022-03-23 12:55:08 +01:00
Hidde Beydals
3edcd16b62 fix: wait for Source objects observed generation
This ensures the command will wait for the object to report a Ready
Condition with an ObservedGeneration matching the Generation of the
resource. Ensuring that when a "create" is actually a mutation, it waits
instead of prematurely assuming the Source to be Ready.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-23 12:38:42 +01:00
Hidde Beydals
b01d3aeecd Merge pull request #2561 from fluxcd/update-deps 2022-03-23 11:55:57 +01:00
Hidde Beydals
0717c8bdbb Update fluxcd/source-controller to v0.22.1
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-23 11:33:35 +01:00
Hidde Beydals
f1e4561bdd tests/azure: update dependencies
- github.com/Azure/azure-event-hubs-go/v3 to v3.3.17
- github.com/fluxcd/helm-controller/api to v0.18.0
- github.com/fluxcd/image-automation-controller/api to v0.21.0
- github.com/fluxcd/image-reflector-controller/api to v0.17.0
- github.com/fluxcd/kustomize-controller/api to v0.22.0
- github.com/fluxcd/notification-controller/api to v0.23.0
- github.com/fluxcd/pkg/runtime to v0.13.2
- github.com/hashicorp/terraform-exec to v0.15.0
- github.com/libgit2/git2go/v31 to v31.7.9
- github.com/stretchr/testify to v1.7.1
- go.uber.org/multierr to v1.8.0
- k8s.io/api to v0.23.4
- k8s.io/client-go to v0.23.4

For `github.com/hashicorp/terraform-exec`, a newer version (v0.16.0)
is availabe. This version however contains a breaking change (as it
removes the `tfinstall` module), which I did not want to deal with at
the moment.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-23 11:33:35 +01:00
Hidde Beydals
efe9a30523 Update dependencies
- github.com/Masterminds/semver/v3 to v3.1.1
- github.com/ProtonMail/go-crypto to v0.0.0-20220113124808-70ae35bab23f
- github.com/cyphar/filepath-securejoin to v0.2.3
- github.com/fluxcd/pkg/kustomize to v0.0.3
- github.com/fluxcd/pkg/runtime to v0.13.2
- github.com/fluxcd/pkg/ssa to v0.15.1
- github.com/fluxcd/pkg/ssh to v0.3.2
- github.com/fluxcd/pkg/untar to v0.1.0
- github.com/fluxcd/pkg/version to v0.1.0
- github.com/gonvenience/bunt to v1.3.3
- github.com/gonvenience/ytbx to v1.4.4
- github.com/google/go-containerregistry to v0.8.0
- github.com/homeport/dyff to v1.5.1
- github.com/olekukonko/tablewriter to v0.0.5
- github.com/spf13/cobra to v1.4.0
- golang.org/x/crypto to v0.0.0-20220321153916-2c7772ba3064
- k8s.io/kubectl to v0.23.4
- k8s.io/cli-runtime to v0.23.4
- sigs.k8s.io/cli-utils to v0.29.3

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-23 11:33:35 +01:00
Paulo Gomes
e5ede275f8 Update Source API to v1beta2
The creation of oldConditions, statusableConditions and
reconcilableConditions is an adhoc solution to deal with the upstream
changes on `pkg/apis/meta`, which are yet to be replicated across other
Flux API components.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-03-23 11:33:35 +01:00
fluxcdbot
a929d24924 Update toolkit components
- helm-controller to v0.18.0
  https://github.com/fluxcd/helm-controller/blob/v0.18.0/CHANGELOG.md
- kustomize-controller to v0.22.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.22.0/CHANGELOG.md
- source-controller to v0.22.0
  https://github.com/fluxcd/source-controller/blob/v0.22.0/CHANGELOG.md
- notification-controller to v0.23.0
  https://github.com/fluxcd/notification-controller/blob/v0.23.0/CHANGELOG.md
- image-reflector-controller to v0.17.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.17.0/CHANGELOG.md
- image-automation-controller to v0.21.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.21.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-03-23 11:33:35 +01:00
Stefan Prodan
368f2d3542 Merge pull request #2564 from fluxcd/dot-domain-nc
Use absolute domain name for the events address
2022-03-23 12:17:35 +02:00
Stefan Prodan
139bbbb87c Use absolute domain name for the events address
Add ending dot to the events address to be consistent with source controller address.
This will affect bootstrap and install by setting `--events-addr=http://notification-controller.flux-system.svc.cluster.local./`.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-03-23 11:57:46 +02:00
Stefan Prodan
51f5d85861 Merge pull request #2559 from fluxcd/fix-non-fast-forward
Retry bootstrap operations on Git conflict errors
2022-03-22 17:12:31 +02:00
Stefan Prodan
7756faec1f Retry bootstrap operations on Git conflict errors
When running bootstrap in-parallel for many clusters that target the same repository, the 2nd commit with the sync files fails with ` non-fast-forward update`. We now detect the conflict, and we retry the operations by creating a fresh clone from upstream.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-03-22 16:09:31 +02:00
Sunny
d9e3e3aa95 Merge pull request #2542 from fluxcd/update-components
Update toolkit components
2022-03-16 03:16:19 +05:30
fluxcdbot
ff65491bb6 Update toolkit components
- helm-controller to v0.17.2
  https://github.com/fluxcd/helm-controller/blob/v0.17.2/CHANGELOG.md
- notification-controller to v0.22.3
  https://github.com/fluxcd/notification-controller/blob/v0.22.3/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-03-15 20:41:25 +00:00
Stefan Prodan
8f514d8991 Merge pull request #2530 from fluxcd/components-extra-example
Add components-extra example usage to CLI help
2022-03-11 11:34:22 +02:00
Stefan Prodan
2e1000c31a Add components-extra example usage to CLI help
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-03-11 09:19:56 +02:00
Stefan Prodan
c5171a1f2e Merge pull request #2512 from souleb/introduce-printer-interface
Introduce a printer interface for flux resources
2022-03-07 13:55:33 +02:00
Soule BA
7359e63960 Introduce a printer interface for flux resource
If implemented, there will a common interface to print flux resource.

We are adding new way to print resource information e.g. diff of
objects.

Signed-off-by: Soule BA <soule@weave.works>
2022-03-07 12:15:35 +01:00
Stefan Prodan
307309504b Merge pull request #2484 from cuishuang/main
all: fix some typos
2022-03-02 14:23:04 +02:00
cuishuang
1fda202cf9 all: fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-02 19:36:08 +08:00
Sunny
7e634c154f Merge pull request #2483 from fluxcd/update-components
Update toolkit components
2022-03-01 21:18:05 +05:30
fluxcdbot
3c72e35381 Update toolkit components
- image-automation-controller to v0.20.1
  https://github.com/fluxcd/image-automation-controller/blob/v0.20.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-03-01 15:07:34 +00:00
Stefan Prodan
7e23430882 Merge pull request #2467 from fluxcd/update-get-column-order
Update `get` subcommand column order
2022-02-28 15:34:38 +02:00
Sunny
2c4c3fd749 test: ignore golden template files with -update
Add a template values check in the `assertGoldenTemplateFile()` function
to only update golden files if they aren't templates. A note is printed
when an update to a template golden file is needed and `-update` flag
can't update it.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2022-02-28 08:56:08 +05:30
Sunny
edaf6ca522 Add test flag -update to update the golden files
Test flag `-update` can be used to update all the golden files whenever
the CLI output changes.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2022-02-24 08:58:19 +05:30
Sunny
21f0d5d82c Move MESSAGE to the end of get subcommand output
Message content could be long compared to other fields. Moving it to
the end helps improve the visibility of the other fields.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2022-02-24 04:21:47 +05:30
Stefan Prodan
059751b3c9 Merge pull request #2462 from fluxcd/update-components
Update notification-controller to v0.22.2
2022-02-23 15:53:19 +02:00
fluxcdbot
05479756d8 Update toolkit components
- notification-controller to v0.22.2
  https://github.com/fluxcd/notification-controller/blob/v0.22.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-02-23 13:37:43 +00:00
Stefan Prodan
34e19cb638 Merge pull request #2440 from fluxcd/diagrams
Add e2e sequence diagrams
2022-02-23 13:52:55 +02:00
Stefan Prodan
5312f81c8e Add e2e sequence diagrams
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-02-23 13:28:25 +02:00
Stefan Prodan
7f02898539 Merge pull request #2460 from fluxcd/update-components
Update toolkit components
2022-02-23 13:27:31 +02:00
fluxcdbot
8aabc544f1 Update toolkit components
- helm-controller to v0.17.1
  https://github.com/fluxcd/helm-controller/blob/v0.17.1/CHANGELOG.md
- kustomize-controller to v0.21.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.21.1/CHANGELOG.md
- notification-controller to v0.22.1
  https://github.com/fluxcd/notification-controller/blob/v0.22.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-02-23 09:00:51 +00:00
Stefan Prodan
3b62955e81 Merge pull request #2450 from SomtochiAma/resume-all-wait
Add `--wait` flag to flux `resume` cmd
2022-02-21 12:26:53 +02:00
Somtochi Onyekwere
9c76ba903b add wait flag to flux resume cmd
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-02-21 11:07:55 +01:00
Stefan Prodan
b4118b73ed Merge pull request #2448 from SomtochiAma/metadata-client
Use `metadata.Client` for reconcile operations
2022-02-21 12:02:53 +02:00
Somtochi Onyekwere
82a8697f28 Add gvk to rest of api type
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-02-21 10:40:35 +01:00
Stefan Prodan
5b9a1ce5c6 Merge pull request #2452 from souleb/fix-stringData-diff
Diff: fix stringData Secret issue
2022-02-21 11:20:24 +02:00
Soule BA
32ad462ebe Fix stringData Secret issue
This commit migrate to the last version of pkg/ssa v0.14.1 that contains a fix
for stringData secrets. The test case was changed accordingly to
    validate a stringData drift.

A progress-bar flag option has also been added in order to be able to
disable it.

Signed-off-by: Soule BA <soule@weave.works>
2022-02-18 17:18:16 +01:00
Stefan Prodan
1ff8c2806c Merge pull request #2441 from andrewjjenkins/fix-trace-test-tz
Fix failure in TestTrace/* when timezone isn't UTC
2022-02-17 13:51:46 +02:00
Andrew Jenkins
437a7a2852 Fix failure in TestTrace/* when timezone isn't UTC
The TestTrace/Deployment and TestTrace/HelmRelease test cases fail in
environments where the timezone isn't UTC, because they compare a local time
string to the golden file, which has time in UTC.  Here is an example:

```
--- FAIL: TestTrace (0.12s)
    --- FAIL: TestTrace/Deployment (0.08s)
        main_test.go:337: Mismatch from golden file 'testdata/trace/deployment.golden': Mismatch from expected value (-want +got):
              strings.Join({
                ... // 88 identical bytes
                " Flux\n---\nHelmRelease:    podinfo\nNamespace:      podinfo-8\nRevi",
                "sion:       6.0.0\nStatus:         Last reconciled at 2021-07-16 ",
            -   "15:42:20 +0000 UTC",
            +   "09:42:20 -0600 MDT",
                "\nMessage:        Release reconciliation succeeded\n---\nHelmChart:",
                "      podinfo-podinfo\nNamespace:      flux-system-9\nChart:      ",
                "    podinfo\nVersion:        6.0.0\nRevision:       6.0.0\nStatus: ",
                "        Last reconciled at 2021-07-16 ",
            -   "15:32:09 +0000 UTC",
            +   "09:32:09 -0600 MDT",
                "\nMessage:        Fetched revision: 6.0.0\n---\nHelmRepository: pod",
                "info\nNamespace:      flux-system-9\nURL:            https://stefa",
                "nprodan.github.io/podinfo\nRevision:       8411f23d07d3701f0e96e7",
                "d9e503b7936d7e1d56\nStatus:         Last reconciled at 2021-07-",
            -   "1",
                "1",
            -   " 00:25:46 +0000 UTC",
            +   "0 18:25:46 -0600 MDT",
                "\nMessage:        Fetched revision: 8411f23d07d3701f0e96e7d9e503b",
                "7936d7e1d56\n",
              }, "")
```

This commit fixes the issue by converting the golden test times to local
time before comparing. The utility function toLocalTime() is added to
trace_test.go, and then it is used to provide localized times as
template parameters to the golden files.

Signed-off-by: Andrew Jenkins <andrew@aspenmesh.io>
2022-02-16 09:36:00 -07:00
Stefan Prodan
412db70773 Merge pull request #2444 from fluxcd/update-components
Update toolkit components
2022-02-16 15:20:38 +02:00
fluxcdbot
a1bb6babed Update toolkit components
- helm-controller to v0.17.0
  https://github.com/fluxcd/helm-controller/blob/v0.17.0/CHANGELOG.md
- kustomize-controller to v0.21.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.21.0/CHANGELOG.md
- notification-controller to v0.22.0
  https://github.com/fluxcd/notification-controller/blob/v0.22.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-02-16 12:57:45 +00:00
Stefan Prodan
568c536c3c Merge pull request #2443 from SomtochiAma/log-bug
Validate that object name adheres to RFC 1123 for `flux create` commands
2022-02-16 14:57:00 +02:00
Somtochi Onyekwere
d7129d6b55 Remove validation from sub-commands
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-02-16 11:04:05 +01:00
Somtochi Onyekwere
4a893b13f8 validate that object name adheres to RFC 1123 for flux create commands
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-02-16 10:51:03 +01:00
Stefan Prodan
8c2983c958 Merge pull request #2439 from SomtochiAma/log-bug
Use text/template library instead of html/template for logs
2022-02-15 09:30:58 +02:00
Somtochi Onyekwere
a30ffdb176 Use text/template
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-02-14 23:59:20 +01:00
Stefan Prodan
7a306e69ab Merge pull request #2426 from foot/support-dot-prefixed-paths
Add support for Kustomizations with dot-prefixed paths
2022-02-14 12:32:25 +02:00
Simon Howe
23c4c2f1aa Adds test for parent directory
Signed-off-by: Simon Howe <footless@gmail.com>
2022-02-14 10:51:20 +01:00
Simon Howe
aac07f03d8 Adds test for using dot to represent pwd
Signed-off-by: Simon Howe <footless@gmail.com>
2022-02-14 10:48:58 +01:00
Simon Howe
f4418920fb Adds support for dot-prefixed paths in git
- in `flux bootstrap` and `flux create kustomization` etc.
- E.g. for example `--path=.flux` should work now
- Previous behaviour is to strip off any leading "." and leave you with
  "./flux" in the kustomizations / folder structure generated by `flux
  bootstrap`

Signed-off-by: Simon Howe <footless@gmail.com>
2022-02-14 09:10:18 +01:00
Stefan Prodan
7752206152 Merge pull request #2427 from souleb/issue-2411
Bootstrap bitbucket-server: Make sure we retrieve the right project
2022-02-12 15:40:29 +02:00
Soule BA
c950f8f817 Make sure bootstrap bitbucket-server retrieve the right project
When fetching a project by name, a list is returned. If implented, this
will make sure we return the right project from the list.

Signed-off-by: Soule BA <soule@weave.works>
2022-02-12 13:31:11 +01:00
Stefan Prodan
9276345fe7 Merge pull request #2425 from souleb/adding-a-simple-spinner
Add a simple spinner when running flux diff kustomization
2022-02-12 14:25:51 +02:00
Soule BA
01f910e257 Add a simple spinner when running flux diff kustomization
If implemented, users will see a spinner run while the diff is on-going.

Signed-off-by: Soule BA <soule@weave.works>
2022-02-11 18:11:28 +01:00
Stefan Prodan
de5f00016b Merge pull request #2418 from fluxcd/fix-bootstrap
Fix bootstrap: Reset schema cache after applying CRDs
2022-02-10 18:44:53 +02:00
Stefan Prodan
877729aca3 Fix bootstrap: Reset schema cache after applying CRDs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-02-10 18:09:06 +02:00
Stefan Prodan
f65d87b191 Merge pull request #2416 from fluxcd/update-components
Update kustomize-controller to v0.20.2
2022-02-10 16:55:01 +02:00
fluxcdbot
3b1d706b05 Update toolkit components
- kustomize-controller to v0.20.2
  https://github.com/fluxcd/kustomize-controller/blob/v0.20.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-02-10 10:45:36 +00:00
Stefan Prodan
b0552fa0de Merge pull request #2415 from fluxcd/iac-namespace-arg
Add GitRepository namespace arg to `flux create image update`
2022-02-10 12:44:58 +02:00
Stefan Prodan
cbca583f4b Add GitRepository namespace arg to flux create image update
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-02-10 10:52:51 +02:00
Stefan Prodan
a0520de7aa Merge pull request #2397 from fluxcd/ssa-v0.13.0
Fix bootstrap CRD wait race condition
2022-02-07 14:59:05 +02:00
Stefan Prodan
4602b72778 Fix bootstrap CRD wait race condition
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-02-07 14:28:56 +02:00
Stefan Prodan
e69a6ed91a Merge pull request #2398 from fluxcd/update-components
Update toolkit components
2022-02-07 14:28:20 +02:00
Stefan Prodan
9d6a037935 Update dependencies
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-02-07 14:09:23 +02:00
fluxcdbot
41df03f600 Update toolkit components
- kustomize-controller to v0.20.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.20.1/CHANGELOG.md
- source-controller to v0.21.2
  https://github.com/fluxcd/source-controller/blob/v0.21.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-02-07 11:45:14 +00:00
Stefan Prodan
ca92464ef6 Merge pull request #2392 from souleb/issue-2387
Mask dockerconfigjson secret types and support StringData secrets
2022-02-07 11:18:11 +02:00
Soule BA
2e9fd33ce5 Mask dockerconfigjson secret types and support StringData secrets
If implemented, flux diff kustomization will managed correctly sops
managed dockerconfigjson secrets.
Sops encrypted secret with stringData maps are supported too.

Signed-off-by: Soule BA <soule@weave.works>
2022-02-07 09:45:38 +01:00
Stefan Prodan
cf3f729f98 Merge pull request #2389 from souleb/fix-deleted-mess-diff
Fix wrong deletion message on flux diff
2022-02-07 10:09:51 +02:00
Soule BA
8b444283e6 Fix wrong deletion message on flux diff
If implemented, when an error happens when dry-running an object, we
return early. This match pkg ssa implementation

Signed-off-by: Soule BA <soule@weave.works>
2022-02-07 00:06:33 +01:00
Stefan Prodan
4b4e6b1be3 Merge pull request #2382 from SomtochiAma/commit-sha
Use `client.Patch` for suspend/resume operations
2022-02-04 13:39:52 +02:00
Somtochi Onyekwere
d3d271defe use client.Patch for suspend/resume operations
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-02-04 12:06:39 +01:00
Stefan Prodan
9bddabf4ff Merge pull request #2380 from souleb/fix-panic-orgref-var
Fix panic on bootstrap when orgRef is not retrieved
2022-02-04 10:29:26 +02:00
Soule BA
959ea6875a Fix panic on bootstrap when orgRef is not retrieved
If implemented, not retrieving an orgRef will always return an error

Signed-off-by: Soule BA <soule@weave.works>
2022-02-04 09:08:38 +01:00
Stefan Prodan
7b7eb011b0 Merge pull request #2377 from souleb/issue-2363
Fix `flux build/diff` when parsing SOPS encrypted secrets
2022-02-04 10:06:14 +02:00
Soule BA
997e6be3a2 Make sure to trim all sops data
If implemented this fixes #2363 and make sure we can build with sops
encrypted data

Signed-off-by: Soule BA <soule@weave.works>
2022-02-04 08:38:29 +01:00
Stefan Prodan
51af4bbf52 Merge pull request #2364 from robwittman/rwittman/add-github-gpg-signing
Add GPG signing to Github/Gitlab/Bitbucket bootstrap
2022-02-04 09:26:50 +02:00
Robert Wittman
e33198e750 Replace github boostrap GPG options
Signed-off-by: Robert Wittman <robkwittman@gmail.com>
2022-02-03 11:09:10 -05:00
Robert Wittman
e3f5a8fee3 Add GPG options to Gitlab and BitBucket bootstraps
Signed-off-by: Robert Wittman <robkwittman@gmail.com>
2022-02-03 11:07:55 -05:00
Robert Wittman
f8b58f8be9 Add GPG signing to Github bootstrap
Signed-off-by: Robert Wittman <robkwittman@gmail.com>
2022-02-03 11:03:35 -05:00
Stefan Prodan
55542a8086 Merge pull request #2376 from fluxcd/fix-azure-test
e2e: Fix Azure image update automation test
2022-02-03 17:04:01 +02:00
Stefan Prodan
70c8c0445c e2e: Fix Azure image update automation test
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-02-03 16:38:25 +02:00
Stefan Prodan
29c0bb4ce2 Merge pull request #2375 from souleb/issue-2365
Add contextual error code for flux diff kustomization
2022-02-03 16:35:45 +02:00
Soule BA
b86b195450 Add contextual error code for flux diff kustomization
If implemented, calling the diff command on kustomization will return 0,
1(if changes are identified), >1 for errors.

Signed-off-by: Soule BA <soule@weave.works>
2022-02-03 13:41:57 +01:00
Hidde Beydals
edf15894f8 Merge pull request #2368 from fluxcd/update-e2e-pkgs 2022-02-02 11:41:07 +01:00
Stefan Prodan
74878a9aef Update dependencies
Use Azure e2e dependencies and bump fluxcd/pkg/ssa to v0.12.0

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-02-02 11:50:39 +02:00
Stefan Prodan
82824b4fc6 Merge pull request #2345 from fluxcd/update-components
Update toolkit components
2022-02-01 12:39:35 +02:00
Stefan Prodan
141d71c39d Use CrossNamespaceSourceReference for image automations
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-02-01 12:12:59 +02:00
fluxcdbot
e9d6f271b5 Update toolkit components
- helm-controller to v0.16.0
  https://github.com/fluxcd/helm-controller/blob/v0.16.0/CHANGELOG.md
- kustomize-controller to v0.20.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.20.0/CHANGELOG.md
- source-controller to v0.21.1
  https://github.com/fluxcd/source-controller/blob/v0.21.1/CHANGELOG.md
- notification-controller to v0.21.0
  https://github.com/fluxcd/notification-controller/blob/v0.21.0/CHANGELOG.md
- image-reflector-controller to v0.16.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.16.0/CHANGELOG.md
- image-automation-controller to v0.20.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.20.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-02-01 09:48:15 +00:00
Stefan Prodan
8d4dee2aee Merge pull request #2356 from fluxcd/fix-diff-test-kubernetes-1.23.3
Adapt diff test to match Kubernetes 1.23.3 API response
2022-01-31 11:36:07 +02:00
Stefan Prodan
246af92386 Adapt diff test to match Kubernetes 1.23.3 API response
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-28 20:37:16 +02:00
Stefan Prodan
7c9957a18f Merge pull request #2348 from pjbgf/add-pkg-config
Add pkg-config to arm runners
2022-01-27 15:48:48 +02:00
Paulo Gomes
9e7018383a Add pkg-config to arm runners
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-01-27 13:28:46 +00:00
Stefan Prodan
920d6e5404 Merge pull request #2347 from stealthybox/fix-2346-usage-output
Fix output usage for `flux get <sources|images>`
2022-01-27 09:58:56 +02:00
leigh capili
57962347f2 Output Usage for flux get <sources|images>
Signed-off-by: leigh capili <leigh@null.net>
2022-01-26 16:03:22 -07:00
Stefan Prodan
6f053c45df Merge pull request #2343 from fluxcd/check-kubernetes-1.20.6
Set minimum supported version to Kubernetes 1.20.6
2022-01-26 12:22:13 +02:00
Stefan Prodan
f154326391 Set minimum supported version to Kubernetes 1.20.6
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-26 11:21:32 +02:00
Stefan Prodan
776a7fc9c0 Merge pull request #2342 from fluxcd/flux-cli-non-root
Run the CLI as non-root
2022-01-26 10:39:10 +02:00
Stefan Prodan
08412b72bc Run the CLI as non-root
Run the Flux CLI inside the container under the nobody user and group.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-26 09:51:50 +02:00
Stefan Prodan
030e166f43 Merge pull request #2336 from souleb/upgrade-go-git-provider
Upgrade go-git-providers to v0.5.3
2022-01-25 12:14:50 +02:00
Soule BA
d92dfc56b8 Upgrade go-git-providers to v0.5.3
Fixes bug reported on #2332

Signed-off-by: Soule BA <soule@weave.works>
2022-01-25 10:28:14 +01:00
Stefan Prodan
365d2d102d Merge pull request #2316 from pjbgf/warn-pod-security
[security] Enable pod security warnings for flux-system
2022-01-21 13:53:11 +02:00
Paulo Gomes
f7853c4ddf Enable pod security warnings for flux-system
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-01-21 11:23:56 +00:00
Hidde Beydals
0a6d5d9267 Merge pull request #2317 from souleb/update-diff-license-header 2022-01-20 17:42:51 +01:00
Soule BA
10b761e4e7 Add license Header to internal/build files
This adds an up to date license header to the files.

Signed-off-by: Soule BA <soule@weave.works>
2022-01-20 16:58:12 +01:00
Stefan Prodan
c6f2b410bc Merge pull request #2167 from souleb/flux-build-kustomization
Preview local changes with flux build/diff kustomization
2022-01-20 14:50:02 +02:00
Soule BA
306f8f5715 Add graceful shutdown when interrupted
If implemented this permit restoring a clean state in case of signal
interruption.

Signed-off-by: Soule BA <soule@weave.works>
2022-01-20 13:21:07 +01:00
Soule BA
f7d9ee90cd Add e2e tests for build/diff kustomization
Signed-off-by: Soule BA <soule@weave.works>
2022-01-20 11:51:57 +01:00
Soule BA
9376c9a946 Add a diff kustomization feature
If implemented it will permit queriying the Kubernetes API to fetch the specified
Flux Kustomization, then uses the specified path to build the overlay.
It will then ssa-dry-run apply and output the diff using homeport/dyff

Signed-off-by: Soule BA <soule@weave.works>
2022-01-20 11:51:56 +01:00
Soule BA
70fb87bc93 Add a build kustomization feature
If implemented it will permit queriying the Kubernetes API to fetch the specified
Flux Kustomization, then uses the specified path to build
the overlay.

Signed-off-by: Soule BA <soule@weave.works>
2022-01-20 11:51:56 +01:00
Stefan Prodan
63e54f3575 Merge pull request #2297 from SomtochiAma/commit-sha
Shorten Git SHA commit in `flux get` commands output
2022-01-20 12:36:18 +02:00
Somtochi Onyekwere
1e2a497108 Shorten sha commit
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-01-20 11:13:25 +01:00
Stefan Prodan
5d95a6e750 Merge pull request #2305 from fluxcd/kubectl-1.23.1
Update kubectl to 1.23.1 in flux-cli container image
2022-01-18 19:01:09 +02:00
Stefan Prodan
af00610a61 Update kubectl to 1.23.1 in flux-cli container image
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-18 18:34:16 +02:00
Stefan Prodan
809cb79828 Merge pull request #2304 from fluxcd/fix-release-notes-gen
ci: Fix release notes generator
2022-01-18 18:33:23 +02:00
Stefan Prodan
e44a58cba0 ci: Fix release notes generator
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-18 18:13:59 +02:00
Stefan Prodan
10046187a6 Merge pull request #2301 from fluxcd/cosign
Sign the release artifacts checksums and images
2022-01-18 14:56:47 +02:00
Stefan Prodan
a402461f9c Sign the release artifacts checksums and images
- add the Flux manifests and API schemas to checksums
- sign the checksum.txt with Cosign and GitHub OIDC
- sign the flux-cli container images with Cosign and GitHub OIDC

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-18 14:31:37 +02:00
Stefan Prodan
8a6771c9a9 Merge pull request #2300 from fluxcd/ci-fixes
Fix Azure e2e tests and GoReleaser buildx directive
2022-01-17 11:03:05 +02:00
Stefan Prodan
7173bd5945 Fix GoReleaser buildx directive
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-17 10:37:31 +02:00
Stefan Prodan
8e09ade41c Fix Azure e2e tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-17 10:36:03 +02:00
Stefan Prodan
6ceb8d8338 Merge pull request #2295 from fluxcd/sbom-spdx
Publish Flux Software Bill of Materials (SBOM)
2022-01-17 10:33:02 +02:00
Stefan Prodan
11296cd94f Publish Flux Software Bill of Materials (SBOM) in SPDX format
- generate SBOM for Flux Go modules with Syft
- publish the SBOM SPDX JSON files to GitHub releases with GoReleaser

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-14 16:36:49 +02:00
Aurel Canciu
677dca0bc4 Merge pull request #2296 from fluxcd/fix-pkgbuild-envtest
Fix Archlinux PKGBUILD check() run on ARM
2022-01-14 13:55:26 +01:00
Aurel Canciu
8e7b957164 Fix Archlinux PKGBUILD check() run on ARM
The check() run started to fail after #2288 since ENVTEST_ARCH was not
set correctly on ARM/ARM64. This should fix the problem for the flux-go
and flux-scm AUR packages.

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2022-01-14 13:20:19 +01:00
Stefan Prodan
8f93e2a9d4 Merge pull request #2294 from fluxcd/ci-del-repo
Improve the bootstrap e2e test workflow
2022-01-14 11:48:22 +02:00
Stefan Prodan
62755b4b75 Wait 60s for image automation before failing the test
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-14 10:30:36 +02:00
Stefan Prodan
dcfb745b1f Improve the bootstrap e2e cleanup
Delete the repository regardless of the bootstrap test exit code.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-13 20:44:02 +02:00
Stefan Prodan
f38b83231c Merge pull request #2291 from fluxcd/update-components
Update kustomize-controller to v0.19.1
2022-01-13 20:33:47 +02:00
fluxcdbot
269f5e2575 Update toolkit components
- kustomize-controller to v0.19.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.19.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-01-13 18:17:27 +00:00
Stefan Prodan
893596383a Merge pull request #2290 from fluxcd/ssa-v0.10.0
Update dependencies
2022-01-13 19:56:47 +02:00
Stefan Prodan
8c67708829 Update dependencies
- sigs.k8s.io/cli-utils v0.27.0
- github.com/fluxcd/pkg/ssa v0.10.0

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-13 19:37:14 +02:00
Stefan Prodan
c1528503b6 Merge pull request #2141 from schrej/feature/trace-simpler-arguments
Simplify arguments of flux trace command
2022-01-13 19:36:56 +02:00
Jakob Schrettenbrunner
d3c56eb3d3 trace: fix lint warning
Signed-off-by: Jakob Schrettenbrunner <jakob.schrettenbrunner@telekom.de>
2022-01-13 15:52:47 +01:00
Jakob Schrettenbrunner
b10eee87ee Simplify arguments of flux trace command
It now accepts arguments in the forms <resource>/<name>
and <resource> <name> instead of requiring api version and
kind as flags.

Signed-off-by: Jakob Schrettenbrunner <jakob.schrettenbrunner@telekom.de>
2022-01-13 15:52:47 +01:00
Hidde Beydals
83de469967 Merge pull request #2267 from tomalexander/add_git_build_dep 2022-01-13 15:22:23 +01:00
Tom Alexander
192978125f build/aur: fix the make target for the manifests
Signed-off-by: Tom Alexander <tom@fizz.buzz>
2022-01-13 14:58:46 +01:00
Tom Alexander
b4b3551e39 build/aur: add Git as flux-scm build dependency
Without git installed, makepkg fails to fetch the source. This breaks
the build for people who build their aur packages inside temporary
containers (for example aurutils with the -c flag).

Signed-off-by: Tom Alexander <tom@fizz.buzz>
2022-01-13 14:58:33 +01:00
Stefan Prodan
7f580e89d0 Merge pull request #2288 from aryan9600/aryan9600/setup-testenv
Fix makefile envtest setup and usage
2022-01-13 13:10:17 +02:00
Sanskar Jaiswal
81a087095a fix makefile envtest setup and usage
Refactor logic to install helper tools into one function in the
Makefile. Add support for envtest to help install tools like kubectl,
etcd which helps users run tests more conveniently.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2022-01-13 16:09:11 +05:30
Hidde Beydals
bcabde3bdb Merge pull request #2231 from achetronic/fix-bootstrap-https-port-overwrite 2022-01-13 11:02:22 +01:00
Alby Hernández
c190d80d4a Avoid overwriting the host port on http requests
Remove the overwrite of the repositoryURL.Host variable to include Git
servers deployed on non-standard https ports

Co-authored-by: Sebastián Vargas <develolux@gmail.com>

Signed-off-by: Alby Hernández <me@achetronic.com>
Signed-off-by: Alby Hernández <alby.hernandez@system73.com>
2022-01-13 10:32:10 +01:00
Stefan Prodan
11081e8cb2 Merge pull request #2285 from souleb/issue-2284
Update go-git-provider to fix GitLab bootstrap regression bug
2022-01-12 18:19:23 +02:00
Soule BA
c5890f08ef reverting go-git-provider to fix #2284
Signed-off-by: Soule BA <soule@weave.works>
2022-01-12 16:51:35 +01:00
Stefan Prodan
926d8a1c37 Merge pull request #2234 from souleb/issue-2207
Use provided SSH hostname to sync with SSH
2022-01-12 13:18:52 +02:00
Soule BA
da6dfd5a1b Use provided ssh hostname to sync with ssh
Signed-off-by: Soule BA <soule@weave.works>
2022-01-12 11:52:17 +01:00
Stefan Prodan
4318152141 Merge pull request #2281 from Skarlso/add_bindir_to_action
Add optional bindir input to Flux GitHub Action
2022-01-12 12:03:04 +02:00
Gergely Brautigam
759145704f Update the action to include an optional bindir
Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
2022-01-12 10:38:19 +01:00
Stefan Prodan
5cab8f4b11 Merge pull request #2280 from fluxcd/go-git-providers-v0.5.1
Update Git providers
2022-01-12 11:11:36 +02:00
Stefan Prodan
a0ce4b23d2 Update Git providers
- go-git-providers v0.5.1
- go-github v41.0.0
- go-gitlab v0.54.3

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-12 10:34:58 +02:00
Hidde Beydals
6d88a0c3ac Merge pull request #2278 from fluxcd/update-components 2022-01-11 18:22:19 +01:00
fluxcdbot
db44bcd88e Update toolkit components
- notification-controller to v0.20.1
  https://github.com/fluxcd/notification-controller/blob/v0.20.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-01-11 14:36:35 +00:00
Hidde Beydals
585ae5090d Merge pull request #2272 from fluxcd/x-crypto-patch 2022-01-10 19:32:32 +01:00
Hidde Beydals
fe46793c40 Update golang.org/x/crypto to latest main
This includes the full commit tree to solve both CVE-2020-29652 and
CVE-2021-43565:
8b5274cf68...5770296d90

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-01-10 19:02:47 +01:00
Stefan Prodan
be146b1cc9 Merge pull request #2271 from fluxcd/update-components-pkg
Update toolkit components and packages
2022-01-10 19:16:21 +02:00
Aurel Canciu
e46c7bd519 Update golang.org/x/crypto to fix CVE-2020-29652
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2022-01-10 17:47:23 +01:00
Aurel Canciu
f3d143e5ee Update Go to v1.17
Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2022-01-10 16:30:38 +01:00
Stefan Prodan
fc059df8ff Update controller-runtime dependencies
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-10 16:54:53 +02:00
fluxcdbot
6c047d1e2a Update toolkit components
- helm-controller to v0.15.0
  https://github.com/fluxcd/helm-controller/blob/v0.15.0/CHANGELOG.md
- kustomize-controller to v0.19.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.19.0/CHANGELOG.md
- source-controller to v0.20.1
  https://github.com/fluxcd/source-controller/blob/v0.20.1/CHANGELOG.md
- image-reflector-controller to v0.15.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.15.0/CHANGELOG.md
- image-automation-controller to v0.19.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.19.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2022-01-10 14:35:39 +00:00
Stefan Prodan
f6afe7f0ec Merge pull request #2144 from schrej/feature/cli-runtime
Use k8s.io/cli-runtime for kubernetes flags
2022-01-10 11:39:15 +02:00
Jakob Schrettenbrunner
ca7d2e783f Use k8s.io/cli-runtime for kubernetes flags
Signed-off-by: Jakob Schrettenbrunner <jakob.schrettenbrunner@telekom.de>
2022-01-07 16:01:24 +01:00
Max Jonas Werner
0b133ca9f2 Merge pull request #2212 from fluxcd/rfc-0001-extra
[RFC-0001] Memorandum on the authorization model
2021-12-21 13:01:56 +01:00
Michael Bridgen
ede6785e6b RFC on authorisation model
This gives a baseline for future changes, e.g., expanding where
namespace ACLs are used, switching access control to
untrusted-by-default.

The "Security considerations" section  was adapted from

    https://github.com/fluxcd/flux2/pull/2086

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-12-17 19:17:25 +00:00
Stefan Prodan
6d9f39d8ea Merge pull request #2223 from fluxcd/arm64-helm
Add the Helm CLI to the GitHub ARM64 runners setup
2021-12-17 13:16:02 +02:00
Stefan Prodan
fb637ea955 Add the Helm CLI to the GitHub ARM64 runners setup
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-12-17 12:33:27 +02:00
Aurel Canciu
e07558f5b7 Merge pull request #2213 from fluxcd/fix-bundle.sh
Fix ./manifests/scripts/bundle.sh path resolution
2021-12-13 14:23:25 +02:00
Aurel Canciu
b75dbf8c70 Fix ./manifests/scripts/bundle.sh path resolution
The script now uses the path of the script file itself to determine the
manifests directory paths. This fixes an issue when building the AUR
packages where the check() phase would fail because the git repository
of the package would be used and this would generate invalid paths.

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2021-12-13 12:57:33 +01:00
Stefan Prodan
062c1e59a9 Merge pull request #2208 from grafjo/bump_kube_prometheus_stack_23_2_0
Update kube-prometheus-stack to 23.2.0
2021-12-13 12:33:45 +02:00
Johannes Graf
ba5eea861e bump kube-prometheus-stack to 23.2.0
this release contains the prometheus operator in version 0.52.1

see https://github.com/fluxcd/flux2/issues/2192
https://github.com/fluxcd/flux2/pull/2193 for issues

Signed-off-by: Johannes Graf <graf@synyx.de>
2021-12-13 00:34:25 +01:00
Stefan Prodan
ff7df54899 Merge pull request #2178 from fluxcd/update-components
Update toolkit components
2021-12-09 21:00:42 +02:00
fluxcdbot
b75ce95086 Update toolkit components
- helm-controller to v0.14.1
  https://github.com/fluxcd/helm-controller/blob/v0.14.1/CHANGELOG.md
- kustomize-controller to v0.18.2
  https://github.com/fluxcd/kustomize-controller/blob/v0.18.2/CHANGELOG.md
- source-controller to v0.19.2
  https://github.com/fluxcd/source-controller/blob/v0.19.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-12-09 17:24:34 +00:00
Hidde Beydals
a86d94745a Merge pull request #2159 from fluxcd/trace-short-styling 2021-12-09 18:23:53 +01:00
Hidde Beydals
c13de6089a cmd: start trace short description with T
This fixes a styling issue:

```
$ flux --help

Command line utility for assembling Kubernetes CD pipelines the GitOps
way.

Usage:
  flux [command]

...

Available Commands:
  ...
  suspend     Suspend resources
  trace       trace an in-cluster object throughout the GitOps delivery
pipeline
  uninstall   Uninstall Flux and its custom resource definitions
...
```

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-12-09 17:35:53 +01:00
Stefan Prodan
3cb748a47e Merge pull request #2153 from fluxcd/e2e-calico-v3.20
e2e: Update Calico to v3.20
2021-12-09 17:59:19 +02:00
Stefan Prodan
3e6e93fab4 e2e: Update Calico to v3.20
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-12-09 17:26:37 +02:00
Stefan Prodan
5832811930 Merge pull request #2195 from Nalum/issue-2192
Removing Kubernetes API Request Duration Graph
2021-12-09 16:22:44 +02:00
Luke Mallon (Nalum)
6f0ea04ff3 [refactor] Update JSON from Grafana export
Signed-off-by: Luke Mallon (Nalum) <luke.mallon@weave.works>
2021-12-09 09:46:35 +00:00
Stefan Prodan
26ea167524 Merge pull request #2194 from kingdonb/fixup-monitoring-guide
monitoring: Pin kube-prometheus-stack  to v19.3.0
2021-12-09 10:04:31 +02:00
Kingdon Barrett
1393e7a62b pin monitoring release version at 19.3.0
Something in kube-prometheus-stack 20.0.0 has broken our example.
See https://github.com/fluxcd/flux2/pull/2193 for more information.

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2021-12-08 16:06:27 -05:00
Stefan Prodan
7e1fd499ca Merge pull request #2191 from fluxcd/equinix-runners
Run the ARM64 e2e tests on Equinix hardware
2021-12-08 18:35:42 +02:00
Stefan Prodan
309fd86b45 Run ARM64 e2e tests on Equinix hardware
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-12-08 18:07:43 +02:00
Max Jonas Werner
e14357f694 Merge pull request #2162 from dholbach/update-max
update Max email
2021-12-01 14:01:17 +01:00
Daniel Holbach
29f0adc587 update Max email
Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-12-01 12:14:42 +01:00
Stefan Prodan
3ab578747d Merge pull request #2085 from fluxcd/rfc-template
[RFC-0000] Introduce the Flux RFC template
2021-11-30 18:52:58 +02:00
Stefan Prodan
2c3cb1a664 Add template to RFC-0000
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-30 17:26:57 +02:00
Stefan Prodan
99a0c47277 Add RFC process
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-30 16:25:40 +02:00
Stefan Prodan
c5b2c6709a Add status, creation and last update date fields to RFC template
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-30 15:03:45 +02:00
Stefan Prodan
8354ac937c Introduce the Flux RFC template
The RFC template is heavily inspired by Rust RFCs and Kubernetes KEPs.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-30 15:03:45 +02:00
Daniel Holbach
aa5ad65286 Merge pull request #2147 from dholbach/change-relu-email
update Aurel's email
2021-11-26 14:54:54 +01:00
Daniel Holbach
05adb44416 update Aurel's email
Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-11-26 14:29:54 +01:00
Hidde Beydals
adf5a5278f Merge pull request #2135 from fluxcd/revert-json-schemas 2021-11-24 11:54:23 +01:00
Hidde Beydals
bb04ca36b2 Pin crdjsonschema action to commit
Pinned to commit before https://github.com/fluxcd/pkg/pull/189 due to
introduction faulty behavior.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-24 11:37:01 +01:00
Hidde Beydals
fc94b1af7a Revert "Merge pull request #2107 from chanwit/json_schemas"
This reverts commit 75a18b4548, reversing
changes made to e72214e266.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-24 11:36:53 +01:00
Hidde Beydals
d9886035c8 Merge pull request #2120 from fluxcd/update-components 2021-11-24 10:47:37 +01:00
Hidde Beydals
0e122863dd Update toolkit components tests
- helm-controller to v0.14.0
- kustomize-controller to v0.18.1
- source-controller to v0.19.0
- notification-controller to v0.19.0
- image-reflector-controller to v0.14.0
- image-automation-controller to v0.18.0

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-11-24 10:31:17 +01:00
fluxcdbot
3089f67946 Update toolkit components
- helm-controller to v0.14.0
  https://github.com/fluxcd/helm-controller/blob/v0.14.0/CHANGELOG.md
- kustomize-controller to v0.18.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.18.1/CHANGELOG.md
- source-controller to v0.19.0
  https://github.com/fluxcd/source-controller/blob/v0.19.0/CHANGELOG.md
- notification-controller to v0.19.0
  https://github.com/fluxcd/notification-controller/blob/v0.19.0/CHANGELOG.md
- image-reflector-controller to v0.14.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.14.0/CHANGELOG.md
- image-automation-controller to v0.18.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.18.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-11-23 16:06:57 +00:00
Stefan Prodan
3654e221a9 Merge pull request #2123 from SomtochiAma/gitlab-custom-ca
Fix GitHub bootstrap when using custom TLS CA
2021-11-23 17:31:56 +02:00
Somtochi Onyekwere
a26dd05c49 Remove extra space
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-11-23 16:17:10 +01:00
Stefan Prodan
6c844369be Merge pull request #2121 from SomtochiAma/gitlab-custom-ca
bootstrap: Add support for self-signed TLS certs by supplying a custom CA
2021-11-23 16:54:47 +02:00
Somtochi Onyekwere
a03574f8c3 Add caBundle to bitbucket
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-11-23 12:37:39 +01:00
Somtochi Onyekwere
43c6a1531a Add caBundle to gogit provider config
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-11-23 12:02:06 +01:00
Hidde Beydals
aed7341b34 Merge pull request #2113 from fluxcd/remove-ioutil 2021-11-22 17:32:30 +01:00
Stefan Prodan
8731f00347 Remove deprecated io/ioutil from flux tree
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-22 17:53:43 +02:00
Stefan Prodan
75a18b4548 Merge pull request #2107 from chanwit/json_schemas
Publish OpenAPI JSON schemas for Visual Studio Code IntelliSense
2021-11-22 14:54:50 +02:00
Chanwit Kaewkasi
716b41e91b publish json schemas as a single URL
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>

This change publishes the auto-generated JSON schemas as a single URL,
so that it is consumable by a tool like VS Code.

The CRD generator creates 2 files, a tar.gz for Kubeval,
and another one is a JSON file. The JSON file is a combination of
all schemas, put under the "oneOf" operator.
2021-11-22 18:32:54 +07:00
Stefan Prodan
e72214e266 Merge pull request #2070 from souleb/bootstrap-stash
bootstrap: add BitBucket Server (previously known as Stash) support
2021-11-22 11:08:34 +02:00
Soule BA
46f9fc194c Add stash provider bootstrap support
The new command set is:
  flux bootstrap bitbucket-server --owner=<project> --username=<user> --repository=<repository name> --hostname=<domain> --token-auth

There is a parity in the capabilities with the other providers.

Signed-off-by: Soule BA <soule@weave.works>
2021-11-18 11:23:44 +01:00
Stefan Prodan
6c5f27be02 Merge pull request #2101 from SomtochiAma/e2e-image-test
Update test files to use ecdsa key
2021-11-17 12:45:21 +02:00
Somtochi Onyekwere
e96652bdaa Update keys to ECDSA format
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-11-17 11:16:36 +01:00
Somtochi Onyekwere
b7007a35d7 update test files to use ecdsa key
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-11-17 10:49:30 +01:00
Stefan Prodan
e4dc56b59d Merge pull request #2096 from fluxcd/e2e-image-automation
Add e2e test for image automation
2021-11-17 11:07:38 +02:00
Stefan Prodan
b05059a9c4 Add e2e test for image automation
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-16 19:24:57 +02:00
Stefan Prodan
121783976a Merge pull request #2091 from vespian/prozlach/bump_alpine
Update Alpine to v3.14
2021-11-16 14:58:56 +02:00
Pawel Rozlach
5a9424d0b1 Update Alpine to v3.14
Signed-off-by: Pawel Rozlach <vespian@users.noreply.github.com>
2021-11-16 13:42:59 +01:00
Stefan Prodan
e2a3800664 Merge pull request #2080 from fluxcd/update-components
Update toolkit components
2021-11-12 17:22:43 +02:00
fluxcdbot
56815a3624 Update toolkit components
- helm-controller to v0.13.0
  https://github.com/fluxcd/helm-controller/blob/v0.13.0/CHANGELOG.md
- kustomize-controller to v0.18.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.18.0/CHANGELOG.md
- source-controller to v0.18.0
  https://github.com/fluxcd/source-controller/blob/v0.18.0/CHANGELOG.md
- image-reflector-controller to v0.13.2
  https://github.com/fluxcd/image-reflector-controller/blob/v0.13.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-11-12 15:06:46 +00:00
Stefan Prodan
ca6e0ff36e Merge pull request #2076 from fluxcd/update-components
Update toolkit components
2021-11-11 18:30:54 +02:00
fluxcdbot
4c60d1657d Update toolkit components
- helm-controller to v0.12.2
  https://github.com/fluxcd/helm-controller/blob/v0.12.2/CHANGELOG.md
- image-reflector-controller to v0.13.1
  https://github.com/fluxcd/image-reflector-controller/blob/v0.13.1/CHANGELOG.md
- image-automation-controller to v0.17.1
  https://github.com/fluxcd/image-automation-controller/blob/v0.17.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-11-11 16:09:12 +00:00
Hidde Beydals
cdd90cfa75 Merge pull request #2075 from jack-evans/missed-trailing-separator 2021-11-11 15:14:04 +01:00
Jack Evans
05b053e2e9 remove trailing --- for install and bootstrap consistency
Signed-off-by: Jack Evans <jack.evans1@ibm.com>
2021-11-11 13:49:50 +00:00
Stefan Prodan
46c75c1af2 Merge pull request #2062 from drazul/main
Edit grafana dashboard to be able to filter by namespace
2021-11-11 13:18:58 +02:00
Daniel AguadoAraujo
80cf5fa729 Add new variable to filter by exported namespace.
Edit definition of namespace variable to use grafana custom promql function `label_values`.
Rename variable namespace to operator_namespace.
Rename variable exported_namespace to namespace

Signed-off-by: Daniel AguadoAraujo <daniel.aguadoaraujo@gfk.com>
2021-11-11 11:20:39 +01:00
Stefan Prodan
789aa322f1 Merge pull request #2071 from fluxcd/flux-tree-exclude-remote-clusters
Skip remote clusters in flux tree cmd
2021-11-10 11:41:16 +02:00
Stefan Prodan
f03c24565f Skip remote clusters in flux tree cmd
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-09 18:52:51 +02:00
Stefan Prodan
b6a95be5d0 Merge pull request #2068 from fluxcd/update-components
Update toolkit components
2021-11-09 18:22:55 +02:00
fluxcdbot
0f9e8ed3f7 Update toolkit components
- kustomize-controller to v0.17.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.17.0/CHANGELOG.md
- image-automation-controller to v0.17.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.17.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-11-09 15:55:28 +00:00
Stefan Prodan
50af0ba93c Merge pull request #2066 from jack-evans/consistent-comments
Make flux bootstrap and install comments consistent
2021-11-09 17:54:48 +02:00
Jack Evans
923a5882de make flux bootstrap and install generation more consistent
Signed-off-by: Jack Evans <jack.evans1@ibm.com>
2021-11-09 15:18:32 +00:00
Stefan Prodan
83dc3e6093 Merge pull request #2064 from fluxcd/updates-deps
Update dependencies
2021-11-08 19:31:47 +02:00
Stefan Prodan
43edb62f87 Update dependencies
- github.com/fluxcd/go-git-providers v0.3.1
- github.com/fluxcd/pkg/ssa v0.3.1
- github.com/manifoldco/promptui v0.9.0
- sigs.k8s.io/controller-runtime v0.10.2

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-08 18:00:29 +02:00
Stefan Prodan
21e5acc0e0 Merge pull request #2038 from fluxcd/makkes/prompt-for-tokens
Prompt for access tokens in 'bootstrap' command
2021-11-08 16:58:35 +02:00
Max Jonas Werner
be1ce74dc5 fix: trim CRLF from password read from stdin
bufio's reader.ReadString includes any CRLF characters and we don't
want these in the resulting token because this leads to errors in the
authentication like this:

```
✗ failed to get Git repository
"https://github.com/kingdon-ci/jenkins-infra": Get
"https://api.github.com/repos/kingdon-ci/jenkins-infra": net/http:
invalid header field value "Bearer gho_NNNNNsecrettokenMMMMM\n" for
key Authorization
```

Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-11-07 15:09:31 +01:00
Max Jonas Werner
31771f3575 fix: improve wording
Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-11-07 15:09:31 +01:00
Max Jonas Werner
ffcd7d8059 feat: prompt for access tokens in 'bootstrap' command
This change adds functionality to both, `bootstrap github` and
`bootstrap gitlab` to prompt the user for the personal access tokens
if those can't be derived from the shell environment. Echoing is
turned off for better privacy.

Instead of having to interactively type the token or manually paste it
from the clipboard, users can also pipe it to Flux which comes in
handy e.g. when executing Flux remotely over an SSH connection:

```
$ echo 'asdf' | flux bootstrap github
```

Otherwise, Flux will prompt the user:

```
$ flux bootstrap github
Please type your GitHub personal access token:
```

closes #2011

Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-11-07 15:09:30 +01:00
Stefan Prodan
4bc4aa1397 Merge pull request #2050 from fluxcd/do-not-edit-warn
Add `DO NOT EDIT` warn to bootstrap sync manifests
2021-11-04 18:47:50 +02:00
Stefan Prodan
04faba95cd Add DO NOT EDIT warn to bootstrap sync manifests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-04 18:03:40 +02:00
Sunny
f712dadab5 Merge pull request #2051 from fluxcd/update-components
Update toolkit components
2021-11-04 21:31:17 +05:30
fluxcdbot
58b3150ce3 Update toolkit components
- source-controller to v0.17.2
  https://github.com/fluxcd/source-controller/blob/v0.17.2/CHANGELOG.md
- image-automation-controller to v0.16.1
  https://github.com/fluxcd/image-automation-controller/blob/v0.16.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-11-04 14:07:27 +00:00
Stefan Prodan
e7225db397 Merge pull request #2046 from vespian/prozlach/support_http_proxy_envs
Use full domain name for notification-controller
2021-11-04 11:43:47 +02:00
Pawel Rozlach
8ec5492d87 fix: use full domain name for notification-controller
Signed-off-by: Pawel Rozlach <vespian@users.noreply.github.com>
2021-11-03 10:37:29 +01:00
Stefan Prodan
c2c64a70c4 Merge pull request #2042 from fluxcd/ecdsa-default
Set ECDSA as the default algorithm for `flux create source git`
2021-11-02 17:42:49 +02:00
Stefan Prodan
4621576f40 Set ECDSA as the default algorithm for flux create source git
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-02 17:21:10 +02:00
Stefan Prodan
3b609e9b03 Merge pull request #2041 from fluxcd/bootstrap-ecdsa-default
bootstrap: Set ECDSA as the default SSH key algorithm
2021-11-02 17:15:57 +02:00
Stefan Prodan
4f2ebd78be Set ECDSA as the default algorithm for flux create secret git
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-02 16:49:17 +02:00
Stefan Prodan
88dacebc94 bootstrap: Set ECDSA as the default SSH key algorithm
Motivation: RSA SHA-1 SSH keys are no longer accepted by GitHub https://github.blog/2021-09-01-improving-git-protocol-security-github/.
Given this we are switching the default from RSA to ECDSA for `git`, `github` and `gitlab` variants of `flux bootstrap`.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-02 16:22:16 +02:00
Stefan Prodan
92e7d1ad1e Merge pull request #2036 from fluxcd/part-of-selector
Switch to `app.kubernetes.io/part-of` label selector
2021-11-01 18:37:03 +02:00
Stefan Prodan
d5d8c340c8 Switch to app.kubernetes.io/part-of label selector
Use `app.kubernetes.io/part-of: flux` label instead of `app.kubernetes.io/instance` to select the in-cluster objects used in flux version, check, logs and uninstall commands.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-01 18:02:49 +02:00
Stefan Prodan
b8a85b809a Merge pull request #2035 from fluxcd/source-fetch-timeout
Add fetch timeout arg to create source commands
2021-11-01 16:06:12 +02:00
Stefan Prodan
61be0775af Add fetch timeout arg to create source commands
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-01 15:37:58 +02:00
Stefan Prodan
404ffa5a91 Merge pull request #2034 from fluxcd/default-namespace-from-env
Set default ns with `FLUX_SYSTEM_NAMESPACE` env var
2021-11-01 14:56:47 +02:00
Stefan Prodan
f2de7e04b8 Set default ns with FLUX_SYSTEM_NAMESPACE env var
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-01 14:21:44 +02:00
Stefan Prodan
8b3e3b1dd7 Merge pull request #2033 from fluxcd/update-issue-template
Add flux version to issue template
2021-11-01 13:07:35 +02:00
Stefan Prodan
81e91ac3f5 Add flux version to issue template
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-01 12:46:52 +02:00
Stefan Prodan
b9bde94d08 Merge pull request #2032 from fluxcd/tree-completion
Enable completion for flux tree cmd
2021-11-01 12:40:36 +02:00
Stefan Prodan
37746023c1 Enable completion for flux tree cmd
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-01 12:19:06 +02:00
Stefan Prodan
d3e529b8a4 Merge pull request #2015 from SomtochiAma/test-export-cmd
Add unit tests for export
2021-11-01 12:18:55 +02:00
Somtochi Onyekwere
eb69083ef5 Add unit tests for export
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-11-01 10:46:07 +01:00
Hidde Beydals
96aac387c9 Merge pull request #2028 from fluxcd/update-components 2021-10-30 15:34:11 +02:00
fluxcdbot
870f18c621 Update toolkit components
- source-controller to v0.17.1
  https://github.com/fluxcd/source-controller/blob/v0.17.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-10-30 13:11:56 +00:00
Hidde Beydals
57b33e29f7 Merge pull request #2024 from kingdonb/fix-error-message-quoting 2021-10-29 18:11:39 +02:00
Kingdon Barrett
94b7917679 Fix quoting around reconciliation error message
While fixing an unrelated issue, I noticed:
    ✗ GitRepository reconciliation failed: ''PGP public keys secret error: expected pointer, but got nil

the single quote should surround the readyCond.Message

Signed-off-by: Kingdon Barrett <yebyen@gmail.com>
2021-10-29 11:21:56 -04:00
Hidde Beydals
98fa0c4271 Merge pull request #2023 from fluxcd/update-components-test 2021-10-28 17:30:10 +02:00
Hidde Beydals
8282907bce Update toolkit components tests
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-28 17:01:24 +02:00
Hidde Beydals
323f4f5e5f Merge pull request #2022 from fluxcd/update-components 2021-10-28 17:00:39 +02:00
fluxcdbot
744b3ebd0a Update toolkit components
- source-controller to v0.17.0
  https://github.com/fluxcd/source-controller/blob/v0.17.0/CHANGELOG.md
- image-automation-controller to v0.16.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.16.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-10-28 14:46:49 +00:00
Stefan Prodan
3fdba35993 Merge pull request #2021 from fluxcd/e2e-retry-gh-get
e2e: Retry the GitHub API calls
2021-10-28 11:23:15 +03:00
Stefan Prodan
ebdf9ed379 e2e: Retry the GitHub API calls
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-28 10:56:52 +03:00
Stefan Prodan
a572274c5c Merge pull request #1932 from SomtochiAma/test-bootstrap
Add test for customizing bootstrap
2021-10-28 09:53:43 +03:00
Somtochi Onyekwere
6a6bba8669 Add test for customizing bootstrap
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-27 15:45:23 +01:00
Stefan Prodan
1d1d4bbf4b Merge pull request #2008 from fluxcd/expand-hr-in-tree-ks
Expand Helm releases in flux tree cmd
2021-10-26 18:04:53 +03:00
Stefan Prodan
d9bb4c631e Add flux tree to e2e tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-26 17:34:01 +03:00
Stefan Prodan
722962c138 Expand Helm releases in flux tree cmd
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-26 15:54:31 +03:00
Stefan Prodan
c98ff6ae87 Merge pull request #1988 from darkowlzz/update-maintainers
Add @darkowlzz to maintainers list
2021-10-25 19:36:16 +03:00
Sunny
cbef6a4cad Add @darkowlzz to maintainers list
Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-25 21:48:59 +05:30
Stefan Prodan
f887a2c029 Merge pull request #1998 from fluxcd/tree-cmd
Add flux tree command
2021-10-25 16:51:01 +03:00
Stefan Prodan
078cfe92c2 Add JSON and YAML output options to flux tree cmd
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-25 13:45:27 +03:00
Stefan Prodan
80ef184b60 Add flux tree command
The `flux tree kustomization` command prints the resources reconciled by the given Kustomization.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-25 13:45:13 +03:00
Hidde Beydals
f2475988bd Merge pull request #2000 from wingkwong/refak/ioutil 2021-10-24 18:53:13 +02:00
WONG, Wing Kam
45526108e0 Remove use of deprecated io/ioutil
Signed-off-by: WONG, Wing Kam <wingkwong.code@gmail.com>
2021-10-24 22:17:20 +08:00
Stefan Prodan
414c0bbbdc Merge pull request #1997 from johngmyers/contrib-slack
Update Slack channel in CONTRIBUTING.md
2021-10-23 11:05:54 +03:00
John Gardiner Myers
6873a710d9 Update Slack channel in CONTRIBUTING.md
Signed-off-by: John Gardiner Myers <jgmyers@proofpoint.com>
2021-10-22 10:59:49 -07:00
Hidde Beydals
8a44006384 Merge pull request #1996 from fluxcd/e2e-azure-update 2021-10-22 16:39:59 +02:00
Hidde Beydals
1b6061066a e2e/azure: update dependencies
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-22 16:07:04 +02:00
Hidde Beydals
3a8a5982c6 Merge pull request #1977 from fluxcd/libgit2-semver-e2e 2021-10-22 16:00:30 +02:00
Stefan Prodan
ccff578492 e2e: Add test for libgit2 tag semver range
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-22 15:40:54 +02:00
Hidde Beydals
e2402e3d84 Merge pull request #1993 from fluxcd/update-components 2021-10-22 15:40:20 +02:00
fluxcdbot
f13b1629cf Update toolkit components
- source-controller to v0.16.1
  https://github.com/fluxcd/source-controller/blob/v0.16.1/CHANGELOG.md
- notification-controller to v0.18.1
  https://github.com/fluxcd/notification-controller/blob/v0.18.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-10-22 13:11:43 +00:00
Stefan Prodan
72a97bb70a Merge pull request #1983 from SomtochiAma/test-create-secret-export
Add unit tests for create secret export
2021-10-22 15:01:10 +03:00
Somtochi Onyekwere
67b393ce09 Add test for create secret
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-22 12:34:36 +01:00
Stefan Prodan
48e89b95bb Merge pull request #1985 from makkes/add-myself-to-maintainers
Add Max Jonas Werner to maintainer list
2021-10-22 12:38:19 +03:00
Max Jonas Werner
2159ed62d0 Add Max Jonas Werner to maintainer list
Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-10-22 10:56:32 +02:00
Stefan Prodan
8bb65719cd Merge pull request #1984 from fluxcd/fix-bootstrap-path-check
Fix bootstrap path check
2021-10-22 11:43:53 +03:00
Stefan Prodan
4352915945 Fix bootstrap path check
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-22 10:55:31 +03:00
Stefan Prodan
ebd145f7f7 Merge pull request #1982 from fluxcd/poll-interval
Add poll interval flag to flux check cmd
2021-10-22 10:44:13 +03:00
Stefan Prodan
cd52a0eef3 Add poll interval flag to flux check cmd
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-22 09:57:54 +03:00
Stefan Prodan
69e4a86fe2 Merge pull request #1978 from darkowlzz/release-docs-improvements
Minor improvements in the release procedure docs
2021-10-21 17:00:29 +03:00
Sunny
52d89a2ee1 Minor improvements in the release procedure docs
Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-21 18:09:52 +05:30
Stefan Prodan
5c60e792d9 Merge pull request #1976 from fluxcd/e2e-run-docs
Install envtest before running the unit tests
2021-10-21 10:32:04 +03:00
Stefan Prodan
77c9611784 Improve the test suite docs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-21 09:57:38 +03:00
Stefan Prodan
66780bbf54 Install envtest before running the unit tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-21 09:56:33 +03:00
Stefan Prodan
a8932e677e Merge pull request #1975 from johngmyers/fix-compile
Fix inadequate quoting of KUBEBUILDER_ASSETS
2021-10-21 08:58:24 +03:00
John Gardiner Myers
e12988a8f9 Fix inadequate quoting of KUBEBUILDER_ASSETS
Signed-off-by: John Gardiner Myers <jgmyers@proofpoint.com>
2021-10-20 15:23:13 -07:00
Philip Laine
6ee4abe79e Merge pull request #1970 from fluxcd/fix/azure-e2e-cleanup
Fix infrastructure clean up on Azure e2e test failure
2021-10-20 17:18:41 +02:00
Philip Laine
948e050d60 Fix infrastructure clean up on test failure
Signed-off-by: Philip Laine <philip.laine@xenit.se>
2021-10-20 16:11:54 +02:00
Stefan Prodan
87feb45751 Merge pull request #1961 from fluxcd/ks-wait
Add wait flag to create kustomization cmd
2021-10-19 16:34:58 +03:00
Stefan Prodan
77aa81a064 Add wait flag to create kustomization cmd
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-19 16:18:09 +03:00
Stefan Prodan
a4a1db0915 Update fluxcd packages
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-19 16:17:38 +03:00
Stefan Prodan
57b9610af7 Merge pull request #1946 from fluxcd/update-components
Update toolkit components
2021-10-19 16:13:33 +03:00
fluxcdbot
c3384c6499 Update toolkit components
- helm-controller to v0.12.1
  https://github.com/fluxcd/helm-controller/blob/v0.12.1/CHANGELOG.md
- kustomize-controller to v0.16.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.16.0/CHANGELOG.md
- notification-controller to v0.18.0
  https://github.com/fluxcd/notification-controller/blob/v0.18.0/CHANGELOG.md
- image-reflector-controller to v0.13.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.13.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-10-19 12:53:27 +00:00
Stefan Prodan
5389859260 Merge pull request #1948 from darkowlzz/fix-install-make-target
Makefile: set install target as phony
2021-10-19 15:08:36 +03:00
Sunny
84c585cf61 Makefile: set install target as phony
`install/` directory results in make install target always up to date.
Mark `install` as phony to be able to run it.

Replace `cmd/flux` with `./cmd/flux` for install to work and add
`CGO_ENABLED=0` like in other build and install targets.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-14 23:37:20 +05:30
Stefan Prodan
ca496d393d Merge pull request #1943 from fluxcd/add-copyright
Add missing copyright headers
2021-10-14 16:36:34 +03:00
Stefan Prodan
3d4ca831dc Add missing copyright headers
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-14 16:14:28 +03:00
Stefan Prodan
7ace8de753 Merge pull request #1942 from fluxcd/part-of-flux-label
Add part-of label to the static manifests
2021-10-14 16:08:02 +03:00
Stefan Prodan
928d3e2185 Add part-of label to the static manifests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-14 15:40:36 +03:00
Stefan Prodan
cbf2b90320 Merge pull request #1938 from fluxcd/fix-rbac-for-irc-ns-access
Allow namespaces readonly access in crd-controller RBAC ClusterRole
2021-10-14 15:16:28 +03:00
Aurel Canciu
69dce73e51 Allow namespaces readonly crd-controller rbac
Readonly access to namespaces is needed by the
image-reflector-controller to support the cross-namespace accessFrom
functionality introduced in image-reflector-controller#162.

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2021-10-13 19:35:31 +02:00
Stefan Prodan
75d4f87dec Merge pull request #1937 from SomtochiAma/resume-docs
Fix description for resume --all
2021-10-13 18:41:43 +03:00
Somtochi Onyekwere
4f7d89e825 Fix description for resume --all
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-13 16:25:15 +01:00
Stefan Prodan
da87e16321 Merge pull request #1935 from fluxcd/update-components
Update toolkit components
2021-10-13 15:04:51 +03:00
Stefan Prodan
f7aa3e7e1b Update github.com/fluxcd/pkg/ssa to v0.1.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-13 14:43:35 +03:00
fluxcdbot
deacfd6c03 Update toolkit components
- kustomize-controller to v0.15.5
  https://github.com/fluxcd/kustomize-controller/blob/v0.15.5/CHANGELOG.md
- notification-controller to v0.17.1
  https://github.com/fluxcd/notification-controller/blob/v0.17.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-10-13 11:16:40 +00:00
Stefan Prodan
3e8d1ae1d5 Merge pull request #1732 from timja/kustomize-substitute-fixes
Avoid substitution issue in kustomize credentials sync
2021-10-13 14:16:03 +03:00
Tim Jacomb
08f5ca39b0 Avoid substitution issue in kustomize credentials sync
Signed-off-by: Tim Jacomb <tim.jacomb@hmcts.net>
2021-10-13 11:50:16 +01:00
Stefan Prodan
31da363495 Merge pull request #1925 from fluxcd/update-components
Update kustomize-controller to v0.15.4
2021-10-12 13:32:09 +03:00
fluxcdbot
2ecd99d317 Update toolkit components
- kustomize-controller to v0.15.4
  https://github.com/fluxcd/kustomize-controller/blob/v0.15.4/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-10-12 10:15:51 +00:00
Stefan Prodan
59c3d84182 Merge pull request #1847 from OakNorthAI/let-user-set-version-to-install
feature: let user specify what version of flux-cli they want to install
2021-10-12 13:15:11 +03:00
Jakub Baron
641d5378f8 Merge branch 'main' into let-user-set-version-to-install 2021-10-11 12:39:37 +01:00
Stefan Prodan
08512e5c43 Merge pull request #1919 from fluxcd/fix-ssa
Fix SSA upstream bugs for Kubernetes < 1.22
2021-10-10 18:43:41 +03:00
Stefan Prodan
8f7f7b23e8 Downgrade e2e tests to Kubernetes v1.19
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-10 16:43:21 +03:00
Stefan Prodan
2eb6ba5a48 Apply SSA fix to flux install and bootstrap
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-10 16:08:16 +03:00
Stefan Prodan
03df386f9e Update kustomize-controller to v0.15.2
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-10 16:07:36 +03:00
Stefan Prodan
5e741da69c Merge pull request #1915 from fluxcd/azure-e2e-fixes
Improve Azure e2e failure tracing
2021-10-09 12:06:39 +03:00
Stefan Prodan
3bea028cc9 Add debug logs to Azure tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-09 11:28:12 +03:00
Hidde Beydals
10475b24c4 Merge pull request #1914 from fluxcd/fix-event-hub-test 2021-10-09 08:57:07 +02:00
Stefan Prodan
a5238e867c Adapt event test for kustomize-controller v0.15
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 22:22:36 +03:00
Stefan Prodan
0e747790f9 Merge pull request #1908 from fluxcd/ssa
Implement server-side apply
2021-10-08 21:33:32 +03:00
Stefan Prodan
2b4d6150d4 Update kustomize-controller to v0.15.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 21:13:59 +03:00
Stefan Prodan
e22ad96164 Update kubectl to v1.22.2 in the multi-arch image
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 21:11:09 +03:00
Stefan Prodan
f54907e66e Remove kubectl dependency from brew and aur pkgs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 21:11:08 +03:00
Stefan Prodan
fb713e9632 Mark the validation arg as deprecated
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 21:11:08 +03:00
Stefan Prodan
0b659e3f09 Update kustomize-controller API to v1beta2
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 21:11:06 +03:00
Stefan Prodan
4c99117c7c Update Kubernetes version minimum requirements
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 21:10:36 +03:00
Stefan Prodan
83c3e8c2fc Replace kubectl with Go server-side apply
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 21:10:31 +03:00
Stefan Prodan
92277225df Merge pull request #1907 from fluxcd/update-components
Update toolkit components
2021-10-08 21:09:17 +03:00
fluxcdbot
622ed88a11 Update toolkit components
- helm-controller to v0.12.0
  https://github.com/fluxcd/helm-controller/blob/v0.12.0/CHANGELOG.md
- kustomize-controller to v0.15.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.15.1/CHANGELOG.md
- source-controller to v0.16.0
  https://github.com/fluxcd/source-controller/blob/v0.16.0/CHANGELOG.md
- notification-controller to v0.17.0
  https://github.com/fluxcd/notification-controller/blob/v0.17.0/CHANGELOG.md
- image-automation-controller to v0.15.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.15.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-10-08 17:54:00 +00:00
Stefan Prodan
d9414f25d5 Merge pull request #1913 from SomtochiAma/gpg-signing
Add check for empty gpg key ring path
2021-10-08 20:53:25 +03:00
Hidde Beydals
5249d17a95 Use proper GPG terminology
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-08 19:35:39 +02:00
Somtochi Onyekwere
25283d357e Add check for empty path and better error messaging
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-08 19:19:21 +02:00
Somtochi Onyekwere
e926321094 Check if path is empty
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-08 19:19:21 +02:00
Stefan Prodan
9c1542c3f3 Merge pull request #1912 from fluxcd/irc-v0.12.0
Update image-reflector-controller to v0.12.0
2021-10-08 20:16:32 +03:00
Stefan Prodan
25d06a53bc Update image-reflector-controller to v0.12.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-10-08 19:26:31 +03:00
Stefan Prodan
4d904e8216 Merge pull request #1854 from SomtochiAma/gpg-signing
Allow users to use gpg signing for bootstrap commits
2021-10-08 19:21:27 +03:00
Somtochi Onyekwere
0beab87f5b Add gpg key path and passphrase as args
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-08 16:59:08 +01:00
Stefan Prodan
b9ceceada4 Merge pull request #1881 from philnichol/add-git-ref-options-to-manifestgen
Add tag, semver and commit args to manifestgen
2021-10-07 13:51:39 +03:00
Phil Nichol
ac7ccf7b94 added tag,semver,commit to manifestgen
Signed-off-by: Phil Nichol <35630607+philnichol@users.noreply.github.com>
2021-10-07 10:06:27 +01:00
Stefan Prodan
5aa9ae511f Merge pull request #1898 from superbrothers/stdout
Fix "get" commands to use stdout instead of stderr
2021-10-06 10:48:33 +03:00
Kazuki Suda
dd81ed896b Fix "get" subcommands to use stdout instead of stderr
Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>
2021-10-06 10:46:37 +09:00
Stefan Prodan
e6bbed162d Merge pull request #1893 from SomtochiAma/flux-version
Add flux version command
2021-10-05 13:02:11 +03:00
Somtochi Onyekwere
3ee8747fdc Add flux version command
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-05 10:29:00 +01:00
Stefan Prodan
0651064999 Merge pull request #1855 from darklore/shell-completion-homebrew
Add shell completion installation to homebrew formula
2021-10-05 12:19:04 +03:00
darklore
4661e4519d Add shell completion installation to homebrew formulae
Signed-off-by: Katsunori Tanaka <zodiac.brave.story@gmail.com>
2021-10-05 03:11:24 +09:00
Stefan Prodan
19caeb178f Merge pull request #1816 from fluxcd/azure/e2e
Add Azure E2E tests
2021-10-04 15:42:56 +03:00
Philip Laine
d8235ea21b Add Azure E2E tests
Signed-off-by: Philip Laine <philip.laine@xenit.se>
2021-10-04 14:15:58 +02:00
Stefan Prodan
5067df179e Merge pull request #1886 from SomtochiAma/fix-flux-logs
Filter pods from each deployment for flux logs
2021-10-03 17:11:08 +03:00
Somtochi Onyekwere
50a1e32da3 Sort pods from each deployment to get first and ready pod
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-03 14:30:31 +01:00
Stefan Prodan
fb85cafcc5 Merge pull request #1874 from SomtochiAma/helm-reconcile
Add better checks for reconciliation in reconcile run command
2021-10-03 10:30:16 +03:00
Somtochi Onyekwere
d06a2936cc Better checks for reconciliation in reconcile run command
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-10-01 08:24:13 +01:00
Stefan Prodan
7c77a9723a Merge pull request #1877 from fluxcd/multi-arch-kubectl
Use multi-arch image for kubectl
2021-09-30 11:19:41 +03:00
Stefan Prodan
8a3e5790f5 Use multi-arch image for kubectl
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-30 11:04:04 +03:00
Hidde Beydals
dd093a775a Merge pull request #1869 from SomtochiAma/team-access-github 2021-09-28 09:42:29 +02:00
Somtochi Onyekwere
a096bd2d71 Allow users to define team roles
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-09-27 21:16:12 +01:00
Hidde Beydals
2eddcde609 Merge pull request #1849 from SomtochiAma/bootstrap-git
Set username only when it isn't default
2021-09-22 16:14:30 +02:00
Somtochi Onyekwere
1849e1768a Set username when it isn't default
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-09-22 09:46:04 +01:00
Hidde Beydals
bbe62d029c Merge pull request #1846 from SomtochiAma/crd-panic-0.17.2 2021-09-21 20:19:43 +02:00
Somtochi Onyekwere
68a89d3cd4 Check for nil pointer before setting createNamespace in helmrelease
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-09-21 14:37:20 +01:00
Jakub Baron
b16f1fc260 feature: let user specify what version of flux-cli they want to install
Signed-off-by: Jakub Baron <jakub.baron@oaknorth.com>
2021-09-21 12:36:47 +01:00
Somtochi Onyekwere
64f39e160b Check if helmRelease.Spec.Install is nil
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-09-21 11:04:21 +01:00
Stefan Prodan
3a76c26822 Merge pull request #1844 from fluxcd/fail-manifests-build-properly
Update Makefile target in release workflow
2021-09-20 18:33:05 +03:00
Michael Bridgen
9d9fff5796 Update Makefile target in release workflow
There's another location which uses the "manifests directory" target
directly, but isn't run when testing a PR: the release workflow.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-09-20 16:06:01 +01:00
Stefan Prodan
0a92c61b09 Merge pull request #1830 from makkes/fix-create-hr
fix: don't set 'Install' field by default in 'create hr'
2021-09-20 17:11:30 +03:00
Max Jonas Werner
546be76f55 fix: don't set 'Install' field by default in 'create hr'
This fixes the case where you create a HelmRelease with `--export` and
the `install: {}` field being there, adding no value to the manifest.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-09-20 14:42:29 +02:00
Stefan Prodan
d770f3f53f Merge pull request #1838 from superbrothers/dynamic-completions
Add dynamic completion suppport
2021-09-20 09:42:54 +03:00
Kazuki Suda
254cc131ae Add dynamic completion suppport
This commit adds dynamic completion support for the following commands
and flags:

- `flux delete ...` command
- `flux export ...` command
- `flux get ...` command
- `flux reconcile ...` command
- `flux resume ...` command
- `flux suspend ...` command
- `--namespace` flag
- `--context` flag

Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>
2021-09-18 17:27:47 +09:00
Stefan Prodan
70509ffcb4 Merge pull request #1833 from superbrothers/fix-971
Fix `flux completion zsh` to work with `source` only
2021-09-18 11:14:44 +03:00
Kazuki Suda
4cc2326c7f Fix flux completion zsh to work with source only
Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>
2021-09-17 17:49:47 +09:00
Michael Bridgen
0133caaec4 Merge pull request #1828 from fluxcd/fail-manifests-build-properly
Use a file to record successful manifests build
2021-09-16 14:33:58 +01:00
Michael Bridgen
7ae4f28920 Use a file to record successful manifests build
Using the directory cmd/flux/manifests as a prerequisite causes a
problem: if the script that creates the files within fails, the next
invocation of make will see the directory and assume it
succeeded. Since the executable expects certain files to be present,
but they are not explicit prerequisites of the recipe for building the
binary, this results in a successful build but a broken `flux`
executable.

Instead, depend on a file that's explicitly updated when the script
has succeeded, and which itself depends on the inputs.

A couple of the CI workflows run

    make cmd/flux/manifests

before doing other things, presumably as a way to avoid running the
whole test suite in a CI pipeline for some purpose other than testing,
so these needed changing as well.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-09-16 14:03:13 +01:00
Stefan Prodan
b1eb0270e9 Merge pull request #1811 from fluxcd/replace-promptui-lgpl
Replace promptui pkg with a fork free of LGPL
2021-09-13 14:47:10 +03:00
Stefan Prodan
03b6de1169 Replace promptui pkg with a fork free of LGPL
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-13 14:27:06 +03:00
Stefan Prodan
9d3f75d111 Merge pull request #1810 from fluxcd/pass-version-to-build
Add version arg to make build
2021-09-13 14:17:27 +03:00
Stefan Prodan
5c41924b2f Add version arg to make build
Allow specifying the version when building the CLI binary with Make. This is useful for projects that distribute their own Flux CLI binary.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-09-13 13:59:52 +03:00
Stefan Prodan
7cf7cf2f1e Merge pull request #1801 from fluxcd/update-components
Update toolkit components
2021-09-09 16:46:43 +03:00
fluxcdbot
2679731bde Update toolkit components
- kustomize-controller to v0.14.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.14.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-09-09 13:14:44 +00:00
Stefan Prodan
ad73370cd7 Merge pull request #1791 from 23technologies/feat/fix-secretRef-bucket-creation
Fix Bucket SecretRef mapping
2021-09-07 14:20:13 +03:00
Fynn Späker
18acae57bd Fix SecretRef
Signed-off-by: Fynn Späker <spaeker@23technologies.cloud>
2021-09-07 12:15:35 +02:00
Hidde Beydals
b427356eca Merge pull request #1782 from makkes/bootstrap-with-custom-ca
feat: enable bootstrap with custom CA locally
2021-09-03 15:54:09 +02:00
Max Jonas Werner
2e6ca16a4a chore: use os.ReadFile instead of deprecated ioutil.ReadFile
Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-09-03 12:20:57 +02:00
Max Jonas Werner
e98f1142a6 feat: enable bootstrap with custom CA locally
When a user provided the `--ca-file` flag to the `bootstrap` command,
the given CA file wasn't taken into account for cloning the repository
locally. It was just passed along to the CR that is created so Flux
can make use of it when cloning the repository in-cluster.

However, users may not want to add a custom CA to their local host's
trust chain and may expect the `--ca-file` flag to be respected also
for cloning the repository locally. This is what this commit
accomplishes.

closes #1775

Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-09-01 15:38:53 +02:00
Hidde Beydals
06fa8f75c9 Merge pull request #1696 from allenporter/flux-cmd-create
Add tests for create source git
2021-08-30 17:43:09 +02:00
Allen Porter
8cbd4e8172 Add test for "flux create source git"
The create source tests are more interesting than the existing tests as they
create objects then wit for the flux source reconciler to complete. The tests
simulate this with a background goroutine that waits for an object to be
created then uses a test specific function to update it.

The tests set a timeout so that if there is a failure they timeout somewhat
quickly rather than hanging for a longer period of time.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-30 07:44:03 -07:00
Stefan Prodan
83c7994266 Merge pull request #1761 from fluxcd/improve-readme
Simplify readme
2021-08-27 16:31:23 +03:00
Stefan Prodan
43843581b6 Simplify readme
- remove install instruction as they get out of sync with the docs website
- make the get started guide the first link under docs

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-27 16:07:25 +03:00
Stefan Prodan
7e03d64e8a Merge pull request #1757 from Schildkroete23/main
Be able to create a git source without human interaction.
2021-08-27 16:06:34 +03:00
Daniel Petró
c6f4d71187 Be able to create a git source without human interaction.
Signed-off-by: Daniel Petró <daniel.petro@icloud.com>
2021-08-27 13:01:35 +02:00
Stefan Prodan
69c3b90fea Merge pull request #1755 from fluxcd/update-components
Update toolkit components
2021-08-26 15:35:01 +03:00
fluxcdbot
75309b4c93 Update toolkit components
- kustomize-controller to v0.14.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.14.0/CHANGELOG.md
- notification-controller to v0.16.0
  https://github.com/fluxcd/notification-controller/blob/v0.16.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-08-26 12:11:29 +00:00
Stefan Prodan
433f13a7ed Merge pull request #1754 from ttulka/logs-since-2
Add `logs` flags `--since` and `--since-time`
2021-08-26 15:10:58 +03:00
Tomas Tulka
8896a1e73e tidy
Signed-off-by: Tomas Tulka <tomas.tulka@gmail.com>
2021-08-26 10:56:25 +02:00
Tomas Tulka
54758b1692 add --since and --since-time
Signed-off-by: Tomas Tulka <tomas.tulka@gmail.com>
2021-08-25 22:10:47 +02:00
Stefan Prodan
375e00c79c Merge pull request #1748 from allenporter/ioutil
Remove use of deprecated io/ioutil
2021-08-25 08:41:50 +03:00
Allen Porter
e2454d91f1 Remove use of deprecated io/ioutil
Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-24 13:06:17 -07:00
Stefan Prodan
6894f6f3bf Merge pull request #1743 from allenporter/flux-envtest
Use shared envTest for unit tests
2021-08-24 11:56:23 +03:00
Allen Porter
d45501a129 Use shared envTest for unit tests
Speed up unit tests by using a shared envTest. This requires each
test to use its own namespace to avoid clobbering objects for
other tests. Tests previously took around 8 seconds each, and now
the initial test takes 2 seconds with follow up tests taking less
than a second each.

Also update existing tests that use a fixed namespace to use a
generated namespace.

Share gold file template function with yaml files.

Remove the testClusterMode, and instead rely on MainTest to do
the appropriate test setup and rootArgs flag setup. Move the
rootArg flag setup out of NewTestEnvKubeManager to avoid
side effects.

A follow up change can be to push the individual setups
from NewTestEnvKubeManager() into their respective TestMain since
the harness share little code.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-24 01:01:14 -07:00
Stefan Prodan
def92e14ee Merge pull request #1740 from allenporter/flux-test-cleanup
Rename trace test golden files
2021-08-23 19:50:28 +03:00
Allen Porter
11708d4189 Rename trace test golden files
Rename trace test golden files to match the convention used by other tests

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-23 09:29:27 -07:00
Stefan Prodan
2bc64bf419 Merge pull request #1739 from allenporter/flux-cmd-test-func
Make test harness more flexible with functions
2021-08-23 19:25:31 +03:00
Allen Porter
3a3bdc62c8 Make test harness more flexible with functions
Replace the 4 arguments to cmdTestCase with a function that
can let tests run arbitrary logic if it is more complex than
what is provided by the test harness. Move the existing logic
into functions that the test can use for common assertions on
golden files and golden values.

These changes were pulled out of PR #1696 to make a smaller review.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-23 08:57:43 -07:00
Stefan Prodan
72294b2a56 Merge pull request #1733 from fluxcd/arm64-e2e
Move arm64 e2e to Go tests
2021-08-19 15:47:52 +03:00
Stefan Prodan
94940a20ef Move arm64 e2e to Go tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-19 15:16:45 +03:00
Stefan Prodan
219ff2ef7d Merge pull request #1729 from timja/patch-1
Avoid substitution issue in kustomize for azure credentials sync
2021-08-19 13:10:54 +03:00
Tim Jacomb
bc2de741b8 Avoid substitution issue in kustomize for azure credentials sync
Signed-off-by: Tim Jacomb <tim.jacomb@hmcts.net>
2021-08-19 07:53:58 +01:00
Stefan Prodan
5eabd4e898 Merge pull request #1726 from allenporter/flux-envtest
Remove fakeclient and use testenv for flux cmd tests
2021-08-19 08:33:16 +03:00
Allen Porter
e8d6d5fe5c Remove fakeclient and use testenv for flux cmd tests
Remove use of the fake client, and replace with a real client connected to the
testEnv.

This required fixes to the yaml files as the testEnv has stricter verifcation
of objects. This also meant it was not possible to test a GitRepository with
a missing artifact since that is not a valid state.

The tests are slower than before, taking around 7-10 seconds each because the
 testEnv is setup and destroyed for every test. These will be sped up in a
 follow up PR.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-18 18:53:53 -07:00
Stefan Prodan
55bd93ff79 Merge pull request #1727 from fluxcd/make-envtest
Wire kubebuilder assets to envtest bin
2021-08-18 17:55:02 +03:00
Stefan Prodan
b34b2d779b Wire kubebuilder assets to envtest bin
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-18 17:35:46 +03:00
Stefan Prodan
103ed2be65 Merge pull request #1719 from chanwit/e2e_check_pre
Add e2e test case fo check --pre
2021-08-18 16:42:53 +03:00
Chanwit Kaewkasi
cc32c1be07 add e2e test for check --pre with templating support
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
2021-08-18 18:28:37 +07:00
Stefan Prodan
a3ba9817a3 Merge pull request #1720 from dholbach/update-calendar
Update links to calendar and resources
2021-08-17 17:10:40 +03:00
Daniel Holbach
6d5f1b17ad update links to calendar and resources
Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-08-17 14:43:04 +02:00
Stefan Prodan
0d5d5fce46 Merge pull request #1721 from fluxcd/test-ref
Refactor e2e tests
2021-08-17 15:31:29 +03:00
Stefan Prodan
375edffd15 Add image scanning e2e tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-17 15:15:42 +03:00
Stefan Prodan
d1982e64b2 Refactor e2e tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-17 13:55:14 +03:00
Stefan Prodan
cec8b5336c Merge pull request #1697 from chanwit/e2e_install
Implement testEnv for e2e tests
2021-08-16 20:39:31 +03:00
Chanwit Kaewkasi
8f78263455 implement testEnv for e2e tests
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
2021-08-17 00:07:09 +07:00
Stefan Prodan
cb96bca6aa Merge pull request #1672 from souleb/main
Adds a watch flag to the get command
2021-08-06 16:16:34 +03:00
Soule BA
c18d0b9217 Adds a watch flag to the get command
The new flag fetch and display the request ressource and then continue
watching the ressource until timeout or cancellation.

A single ressource/ressource type is supported.

Signed-off-by: Soule BA <soule@weave.works>
2021-08-06 13:44:06 +02:00
Hidde Beydals
d1970185b9 Merge pull request #1690 from fluxcd/update-components
Update toolkit components
2021-08-05 19:03:02 +02:00
fluxcdbot
794d3ee2f5 Update toolkit components
- helm-controller to v0.11.2
  https://github.com/fluxcd/helm-controller/blob/v0.11.2/CHANGELOG.md
- kustomize-controller to v0.13.3
  https://github.com/fluxcd/kustomize-controller/blob/v0.13.3/CHANGELOG.md
- source-controller to v0.15.4
  https://github.com/fluxcd/source-controller/blob/v0.15.4/CHANGELOG.md
- notification-controller to v0.15.1
  https://github.com/fluxcd/notification-controller/blob/v0.15.1/CHANGELOG.md
- image-reflector-controller to v0.11.1
  https://github.com/fluxcd/image-reflector-controller/blob/v0.11.1/CHANGELOG.md
- image-automation-controller to v0.14.1
  https://github.com/fluxcd/image-automation-controller/blob/v0.14.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-08-05 16:48:34 +00:00
Hidde Beydals
daeef98dfb Merge pull request #1688 from allenporter/flux-test-main
Replace init() with TestMain()
2021-08-05 18:46:56 +02:00
Allen Porter
4146df1f02 Replace init() with TestMain()
Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-04 08:14:22 -07:00
Hidde Beydals
78f4dfa48d Merge pull request #1687 from allenporter/flux-cmd-ioutil
Remove deprecated io/ioutil usage
2021-08-04 16:58:51 +02:00
Allen Porter
8b68d7d7e2 Remove deprecated io/ioutil usage
Issue #1658

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-04 07:46:25 -07:00
Stefan Prodan
ba1bba17ad Merge pull request #1683 from charles-woshicai/print-success-message
feat: display success message while create secrets via `flux` cli.
2021-08-04 17:40:17 +03:00
Charles Cai
70f2b5028f feat: display success message while create secrets via flux cli.
Signed-off-by: Charles Cai <charles.cai@sap.com>
2021-08-04 21:31:57 +08:00
Hidde Beydals
4f4f0d70a4 Merge pull request #1609 from fluxcd/patch-reconcile-req
Request reconcile using patch instead of update
2021-08-04 13:29:01 +02:00
Hidde Beydals
9607b07e65 Request reconcile using patch instead of update
This should prevent the generation of the object getting bumped, as
observed on a GKE K8s 1.18 cluster using the  logic before this commit.

We only want to generation to increase when there are actual changes to
the `spec` of a resource, as some controllers use the `generation`
value to make assumptions about what they should do during a
reconciliation.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-08-04 13:08:36 +02:00
Stefan Prodan
3570fab0f9 Merge pull request #1682 from fluxcd/refactor-tests
Refactor test helpers
2021-08-04 11:15:33 +03:00
Stefan Prodan
dd0f17d7a5 Refactor test helpers
- move test helpers to main
- add support for inline golden values
- add test for `flux --version`

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-04 10:47:33 +03:00
Stefan Prodan
2290880389 Merge pull request #1671 from allenporter/flux-trace
Add tests for flux trace command
2021-08-04 10:18:54 +03:00
Allen Porter
351d287d88 Add tests for flux trace command
Add tests for flux trace command that fake out the kubernetes client,
load objects from a yaml file and create them in the client, and
assert on the output of the trace command to an expected golden file.

This is a follow up from the suggestions in PR https://github.com/fluxcd/flux2/pull/1626 which suggested that additional
testing would be helpful. This test approach is modeled after the helm command tests.

This required some changes to the kubernetes client setup to make it
possible to use a fake. If we agree this pattern makes sense, it can be
applied to other commands.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-08-03 06:35:13 -07:00
Hidde Beydals
eba6706f15 Merge pull request #1668 from dmitrika/chore/remove-deprecated-ioutil
chore: remove deprecated io/ioutil
2021-07-30 21:11:56 +02:00
Dmitry Rybin
7f425efa6b chore: remove deprecated io/ioutil
Signed-off-by: Dmitry Rybin <ayrowa@yandex.ru>
2021-07-30 20:51:46 +02:00
Stefan Prodan
d40685ab62 Merge pull request #1653 from fluxcd/gh-bug-template
Provide suggestion for some fields in bug report
2021-07-28 18:21:45 +03:00
Hidde Beydals
f795e3eeb8 Provide suggestion for some fields in bug report
This commit adds suggestion for some of the required fields because
there can be a few exceptions in which these values can not be
provided. For example when the `flux` binary can not be installed, or
the set of controllers has been installed with just an `install.yaml`
file.

We use this approach instead of making the fields optional because it
guides people to provide the information whenever they can, which
should result in higher quality bug reports.

As a tiny addition, the reference to "Flux v2" has been renamed to just
"Flux" as we are slowly transitioning "Flux v1" into "Flux Legacy".

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-27 13:25:17 +02:00
Hidde Beydals
d3944c0204 Merge pull request #1651 from fluxcd/gh-bug-template
Transform GitHub issue template to new format
2021-07-26 16:04:40 +02:00
Hidde Beydals
4086ab15fa Transform GitHub issue template to new format
This will help users to provide bug reports of high quality, as the
requested information is now rendered into dedicated fields, while
allowing us to mark fields as "required".

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-26 15:38:38 +02:00
Hidde Beydals
446a367094 Merge pull request #1626 from allenporter/flux-trace 2021-07-23 16:03:44 +02:00
Allen Porter
bd250c9871 Fix template optional field check in trace
Signed-off-by: Allen Porter <allen@thebends.org>
2021-07-22 20:20:21 -07:00
Allen Porter
91b3788362 Fix trace for optional GitRepository.Spec.Reference
Check for existence of GitRepository.Spec.Reference when displaying a trace to
avoid error:

✗ template: tmpl:28:21: executing "tmpl" at <.GitRepository.Spec.Reference.Tag>: nil pointer evaluating *v1beta1.GitRepositoryRef.Tag

Fixes issue #1621
Manually tested using the use cases highlighted in the issue.

Signed-off-by: Allen Porter <allen@thebends.org>
2021-07-22 20:20:21 -07:00
Hidde Beydals
658dbb9ea8 Merge pull request #1628 from darkowlzz/utils-tests
internal/utils: Add unit tests
2021-07-22 12:15:55 +02:00
Sunny
1257b9cbc8 internal/utils: Add unit tests
Add unit tests for various utils functions.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-07-19 02:05:49 +05:30
Stefan Prodan
0ae39d5a0a Merge pull request #1594 from chanwit/status-selector
Add status-selector flag for get commands to filter results based on status conditions
2021-07-08 10:49:58 +03:00
Chanwit Kaewkasi
d8911e0c77 add an example to the status-selector flag's description
Co-authored-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
2021-07-07 14:21:26 +07:00
Chanwit Kaewkasi
1be006a45f implement status selector
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
2021-07-06 22:59:03 +07:00
Stefan Prodan
b95e75ddb4 Merge pull request #1591 from fluxcd/update-components
Update kustomize-controller to v0.13.2
2021-07-06 11:15:14 +03:00
fluxcdbot
15a5f75fe7 Update toolkit components
- kustomize-controller to v0.13.2
  https://github.com/fluxcd/kustomize-controller/blob/v0.13.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-07-06 07:53:43 +00:00
Stefan Prodan
b01e27f50f Merge pull request #1590 from alex-petrov-vt/iss1585
Add no-header flag for get commands to omit printing the header
2021-07-06 10:53:16 +03:00
Alex Petrov
b1a9583262 Add no-header flag for get commands to omit printing the header
Signed-off-by: Alex Petrov <alex.petrov.vt@gmail.com>
2021-07-05 20:04:37 -04:00
Stefan Prodan
dd5e6377f8 Merge pull request #1579 from paulfantom/patch-1
Update podmonitor example
2021-07-02 14:36:12 +03:00
Paweł Krupa
fcb73554c9 Update podmonitor.yaml
`targetPort` is deprecated since prometheus-operator 0.38.0 as per https://github.com/prometheus-operator/prometheus-operator/blob/master/CHANGELOG.md#0380--2020-03-20

Signed-off-by: paulfantom <pawel@krupa.net.pl>
2021-07-01 17:27:54 +02:00
Stefan Prodan
5c4b3d1080 Merge pull request #1575 from dminca/feature/simplify-panel-label
fix Control Plane dashboard legend
2021-06-30 18:27:00 +03:00
Daniel-Andrei Minca
c98cd10621 fix Control Plane dashboard legend
The legend was not showing the Pod name, instead the whole resource in
the dashboard

As a result, use the correct Prometheus label

Resolves:
Related:
Signed-off-by: Daniel-Andrei Minca <mandrei17@gmail.com>
2021-06-30 16:10:53 +02:00
Stefan Prodan
e4af8ddcc8 Merge pull request #1574 from fluxcd/update-components
Update kustomize-controller to v0.13.1
2021-06-30 15:29:30 +03:00
fluxcdbot
b5ce02b8cf Update toolkit components
- kustomize-controller to v0.13.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.13.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-06-30 12:08:03 +00:00
Stefan Prodan
cd42b3fb44 Merge pull request #1569 from fluxcd/update-components
Update source-controller to v0.15.3
2021-06-29 18:17:53 +03:00
fluxcdbot
6dedb767c3 Update toolkit components
- source-controller to v0.15.3
  https://github.com/fluxcd/source-controller/blob/v0.15.3/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-06-29 14:29:00 +00:00
Stefan Prodan
4de3268f3b Merge pull request #1570 from fluxcd/ci-debug
e2e: Update Kubernetes to v1.21.1
2021-06-29 17:28:10 +03:00
Stefan Prodan
a72ff06d79 e2e: Update Kubernetes to v1.21.1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-29 17:15:59 +03:00
Stefan Prodan
cf239deb3d Print pods status on e2e failures
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-29 15:57:09 +03:00
Stefan Prodan
8735229745 Merge pull request #1555 from fluxcd/trace-cmd
Implement flux trace command
2021-06-29 11:22:45 +03:00
Stefan Prodan
3f081ba2d9 Add flux trace to e2e tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-29 11:01:20 +03:00
Stefan Prodan
3f613341cb Extend tracing to owner references
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-29 11:01:01 +03:00
Stefan Prodan
4305b8a77d Implement flux trace command
The trace command allows Flux users to point the CLI to a Kubernetes object in-cluster and get a detailed report about the GitOps pipeline that manages that particular object.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-29 11:01:00 +03:00
Stefan Prodan
fab91d44c3 Merge pull request #1568 from fluxcd/image-v1beta1
Use image API v1beta1
2021-06-29 11:00:26 +03:00
Michael Bridgen
34484734d8 Use image API v1beta1
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 16:20:05 +01:00
Stefan Prodan
10c58bb007 Merge pull request #1567 from fluxcd/update-components
Update toolkit components
2021-06-28 17:58:05 +03:00
fluxcdbot
1c1fd62a91 Update toolkit components
- image-reflector-controller to v0.11.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.11.0/CHANGELOG.md
- image-automation-controller to v0.14.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.14.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-06-28 14:45:58 +00:00
Stefan Prodan
637ac1e3fe Merge pull request #1559 from fluxcd/gh-action-arm
Add ARM and ARM64 support to flux GitHub Action
2021-06-25 15:19:12 +03:00
Stefan Prodan
f52387e849 Add ARM and ARM64 support to flux GitHub Action
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-25 13:32:39 +03:00
Stefan Prodan
9efc4986f9 Merge pull request #1553 from fluxcd/bootstrap-libgit2-test
Add libgit2 test to bootstrap workflow
2021-06-22 18:49:38 +03:00
Stefan Prodan
fdc366ec1c Increase wait time for the helm e2e test
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-22 18:37:04 +03:00
Stefan Prodan
d455db444c Add libgit2 test to bootstrap workflow
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-22 18:24:10 +03:00
Stefan Prodan
17418c9858 Merge pull request #1554 from fluxcd/update-components
Update toolkit components
2021-06-22 18:21:13 +03:00
fluxcdbot
5da7eb7d0d Update toolkit components
- source-controller to v0.15.2
  https://github.com/fluxcd/source-controller/blob/v0.15.2/CHANGELOG.md
- image-automation-controller to v0.13.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.13.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-06-22 14:00:42 +00:00
Stefan Prodan
9da977ee7a Merge pull request #1547 from fluxcd/gh-amr64-runner
Add provisioning script for ARM64 GitHub runners
2021-06-21 09:41:44 +03:00
Stefan Prodan
8e4b2ead9b Add provisioning script for ARM64 GitHub runners
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-19 14:58:57 +03:00
Hidde Beydals
fd364828a1 Merge pull request #1544 from fluxcd/create-target-namespace
Add create target namespace arg to helmrelease cmd
2021-06-18 17:00:05 +02:00
Hidde Beydals
afa58d8c08 Merge pull request #1541 from fluxcd/update-components
Update toolkit components
2021-06-18 16:58:35 +02:00
Stefan Prodan
179062876e Add create target namespace arg to helmrelease cmd
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-18 17:39:31 +03:00
fluxcdbot
a796f3609f Update toolkit components
- helm-controller to v0.11.1
  https://github.com/fluxcd/helm-controller/blob/v0.11.1/CHANGELOG.md
- source-controller to v0.15.1
  https://github.com/fluxcd/source-controller/blob/v0.15.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-06-18 13:44:52 +00:00
Hidde Beydals
b7c6db74d2 Merge pull request #1542 from fluxcd/update-deps
Update source-controller to v0.15.1
2021-06-18 15:21:57 +02:00
Hidde Beydals
4f7b040405 Update source-controller to v0.15.1
This includes an introduction of a `--pass-credentials` flag for the
`flux create source helm` command to allow configuring the new
option introduced.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-18 15:04:48 +02:00
Stefan Prodan
34ca29830e Merge pull request #1540 from fluxcd/e2e-arm64
Run conformance tests on ARM64 Kubernetes clusters
2021-06-18 14:14:39 +03:00
Stefan Prodan
78f1b634fa Run end-to-end tests on Ampere ARM64
GitHub self-hosted runner info:
- Owner: Stefan Prodan
- VM: Oracle Cloud VM.Standard.A1.Flex 4CPU 24GB RAM
- OS: Linux 5.4.0-1045-oracle #49-Ubuntu SMP aarch64
- Packages: docker, kind, kubectl, kustomize

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-18 13:07:58 +03:00
Stefan Prodan
044bc64ad9 Merge pull request #1528 from NissesSenap/bug/arc-sync
Remove resourceNames in integration secrets
2021-06-18 10:25:22 +03:00
Edvin N
091f439498 Merge branch 'main' into bug/arc-sync 2021-06-18 08:47:58 +02:00
Stefan Prodan
a17b0a1ce0 Merge pull request #1535 from fluxcd/update-components
Update source-controller to v0.15.0
2021-06-17 20:29:52 +03:00
fluxcdbot
354cd5e177 Update toolkit components
- source-controller to v0.15.0
  https://github.com/fluxcd/source-controller/blob/v0.15.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-06-17 17:05:08 +00:00
Stefan Prodan
4e8f1221f7 Merge pull request #1534 from fluxcd/skip-deploy-key-prompt
Allow disabling the deploy key prompt for bootstrap git
2021-06-17 16:49:00 +03:00
Stefan Prodan
6b179aa7d9 Allow disabling the deploy key prompt for bootstrap git
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-17 15:20:49 +03:00
Edvin Norling
f748114dfa Remove resourceNames in integration secrets
* Solves #1524
* We remove resourceName due to the following:
  Note: You cannot restrict create or deletecollection requests by resourceName.
  For create, this limitation is because the object name is not known at authorization time.
* Fix typo in azure-registry cronjob
Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
2021-06-16 14:45:30 +02:00
Stefan Prodan
5de83f015a Merge pull request #1519 from fluxcd/kustomize-v4
Update to Kustomize v4
2021-06-15 11:40:49 +03:00
Stefan Prodan
a6620e478a Update to Kustomize v4
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-15 11:25:57 +03:00
Stefan Prodan
c7fcffdd8e Merge pull request #1490 from fluxcd/update-components
Update toolkit components
2021-06-14 18:22:15 +03:00
fluxcdbot
160f59a984 Update toolkit components
- helm-controller to v0.11.0
  https://github.com/fluxcd/helm-controller/blob/v0.11.0/CHANGELOG.md
- kustomize-controller to v0.13.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.13.0/CHANGELOG.md
- source-controller to v0.14.0
  https://github.com/fluxcd/source-controller/blob/v0.14.0/CHANGELOG.md
- notification-controller to v0.15.0
  https://github.com/fluxcd/notification-controller/blob/v0.15.0/CHANGELOG.md
- image-reflector-controller to v0.10.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.10.0/CHANGELOG.md
- image-automation-controller to v0.12.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.12.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-06-14 15:02:31 +00:00
Stefan Prodan
d38d487c2a Merge pull request #1505 from fluxcd/fix-yq-example
Fix yq example for create secret git
2021-06-11 14:00:44 +03:00
Stefan Prodan
db28907543 Fix yq example for create secret git
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-11 12:58:46 +03:00
Stefan Prodan
c4261399b5 Merge pull request #1472 from fluxcd/go-git-v5.4.2
Update go-git to v5.4.2
2021-06-02 20:58:39 +03:00
Stefan Prodan
b4edb46269 Update go-git to v5.4.2
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-02 20:20:02 +03:00
Stefan Prodan
a20ed0e630 Merge pull request #1471 from fluxcd/update-components
Update toolkit components
2021-06-02 20:17:46 +03:00
fluxcdbot
cea869e285 Update toolkit components
- kustomize-controller to v0.12.2
  https://github.com/fluxcd/kustomize-controller/blob/v0.12.2/CHANGELOG.md
- source-controller to v0.13.2
  https://github.com/fluxcd/source-controller/blob/v0.13.2/CHANGELOG.md
- image-automation-controller to v0.11.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.11.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-06-02 16:46:24 +00:00
Stefan Prodan
e12db14d1e Merge pull request #1469 from stealthybox/integrations-fixes
Fix and Refactor integrations
2021-06-02 18:38:47 +03:00
leigh capili
296bf3cc6c Fix eventhub integration config patches
Signed-off-by: leigh capili <leigh@null.net>
2021-06-01 14:42:02 -06:00
leigh capili
1789aa180d Remove unused kustomizeconfigs from integrations
Signed-off-by: leigh capili <leigh@null.net>
2021-06-01 14:42:02 -06:00
leigh capili
bd255800db Template AzureIdentityBinding using $(AZ_IDENTITY_NAME) for integrations
Signed-off-by: leigh capili <leigh@null.net>
2021-06-01 14:42:02 -06:00
leigh capili
1355962b3c Fix GCP integration container image
Signed-off-by: leigh capili <leigh@null.net>
2021-06-01 14:42:01 -06:00
leigh capili
bb0114e379 Remove per-cloud /kbin/kubectl patches
Signed-off-by: leigh capili <leigh@null.net>
2021-06-01 14:42:01 -06:00
leigh capili
f9622a5b9e Add /kbin/kubectl to _base integrations
Signed-off-by: leigh capili <leigh@null.net>
2021-06-01 14:42:01 -06:00
leigh capili
3a74fcd75c Add Makefile to test integrations
Signed-off-by: leigh capili <leigh@null.net>
2021-06-01 14:42:00 -06:00
Stefan Prodan
7265276cc2 Merge pull request #1454 from fluxcd/gofish
Add GoFish as an install option for Flux CLI
2021-05-28 13:08:47 +03:00
Stefan Prodan
b98027b528 Add GoFish as an install option for Flux CLI
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-05-28 12:57:02 +03:00
Stefan Prodan
b6ae7d2cdd Merge pull request #1453 from fluxcd/update-components
Update source-controller to v0.13.1
2021-05-28 12:49:09 +03:00
fluxcdbot
aa887c61c3 Update toolkit components
- source-controller to v0.13.1
  https://github.com/fluxcd/source-controller/blob/v0.13.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-05-28 09:30:21 +00:00
Hidde Beydals
700cef0989 Merge pull request #1349 from fluxcd/fix-throttling
Avoid throttling when some Flux CRDs are not registered
2021-05-26 17:42:22 +02:00
Stefan Prodan
3ed3e553e7 Avoid throttling when some Flux CRDs are not registered
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-05-26 18:29:04 +03:00
Hidde Beydals
d68158ddc9 Merge pull request #1408 from fluxcd/update-components
Update toolkit components
2021-05-26 17:06:31 +02:00
fluxcdbot
9f83a69242 Update toolkit components
- kustomize-controller to v0.12.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.12.1/CHANGELOG.md
- source-controller to v0.13.0
  https://github.com/fluxcd/source-controller/blob/v0.13.0/CHANGELOG.md
- notification-controller to v0.14.1
  https://github.com/fluxcd/notification-controller/blob/v0.14.1/CHANGELOG.md
- image-automation-controller to v0.10.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.10.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-05-26 14:53:26 +00:00
Hidde Beydals
bf69dbd43d Merge pull request #1449 from fluxcd/update-go-git
Update go-git to v5.4.1
2021-05-26 16:15:36 +02:00
Hidde Beydals
465ea5ccfd Update go-git to v5.4.1
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-05-26 15:56:50 +02:00
Stefan Prodan
92ef39e2ad Merge pull request #1411 from NissesSenap/feature/azure-eventhub
Add example manifests for Azure eventhub credentials renewal
2021-05-25 16:35:12 +03:00
Edvin Norling
0404790df9 How to automatically renew Azure eventhub
To use JWT to communicate with Azure eventhub we need to renew the JWT credentials
from time to time. This example yaml helps out with that
* Supports both deployment and cronjob based renewal
  * static service principal
  * aad-pod-identity in azure

Signed-off-by: Edvin Norling <edvin.norling@xenit.se>
2021-05-25 13:43:18 +02:00
Stefan Prodan
f880e93df4 Merge pull request #1415 from allymparker/main
Fix service account name in registry-credentials-sync deployment kustomization
2021-05-14 20:06:59 +03:00
Ally Parker
4697b1101d Fix service account
Signed-off-by: Ally Parker <ally.parker@red-gate.com>
2021-05-14 16:40:30 +01:00
Stefan Prodan
50ff2accd2 Merge pull request #1412 from fluxcd/enable-crd-upgrades
Enable CRDs upgrade for kube-prometheus-stack
2021-05-12 19:06:49 +03:00
Stefan Prodan
c7d876eb8f Enable CRDs upgrade for kube-prometheus-stack
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-05-12 18:40:00 +03:00
Stefan Prodan
eda392dfcd Merge pull request #1399 from SomtochiAma/kube-prometheus
Replace monitoring stack with kube-prometheus-stack
2021-05-12 09:21:34 +03:00
Somtochi Onyekwere
3b91e14f6d Use kube-prometheus-stack for monitoring
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-05-12 06:53:21 +01:00
Hidde Beydals
17e3c57d7e Merge pull request #1405 from fluxcd/update-components
Update toolkit components
2021-05-10 18:10:50 +02:00
fluxcdbot
1c744a0f97 Update toolkit components
- helm-controller to v0.10.1
  https://github.com/fluxcd/helm-controller/blob/v0.10.1/CHANGELOG.md
- source-controller to v0.12.2
  https://github.com/fluxcd/source-controller/blob/v0.12.2/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-05-10 15:58:12 +00:00
Hidde Beydals
99bdb20aeb Merge pull request #1404 from fluxcd/private-key-password 2021-05-10 16:02:06 +02:00
Hidde Beydals
fbe7050cb8 Switch to crypto/ssh for parsing of private keys
This changes the logic for the parsing of private keys, as already
done for the source-controller, so that it is able to recognize and
work with a wider range of key formats instead of returning a vague
error:

```console
$ flux bootstrap git [..]
✗ ssh: this private key is passphrase protected
```

A patch for this was already submitted and merged in `go-git/go-git`,
but is not made available in a release yet:
https://github.com/go-git/go-git/pull/298

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-05-10 15:30:25 +02:00
Hidde Beydals
12ea028aa9 Merge pull request #1379 from tjakobsson/fix-git-bootstrap-hostname
Use proper Host configuration for SSH
2021-05-10 15:23:59 +02:00
Tobias Jakobsson
ea62cb5fc9 Use proper Host configuration for SSH
This removes the usage of Hostname() which does not honor configured SSH
port to be used.

Resolves: #1377
See also: #1101, #1102

Signed-off-by: Tobias Jakobsson <jakobsson.tobias@gmail.com>
2021-05-10 15:04:09 +02:00
Stefan Prodan
d27c2164b2 Merge pull request #1394 from fluxcd/update-components
Update image-automation-controller to v0.9.1
2021-05-06 17:27:23 +03:00
fluxcdbot
ef8f5cb87d Update toolkit components
- image-automation-controller to v0.9.1
  https://github.com/fluxcd/image-automation-controller/blob/v0.9.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-05-06 14:15:14 +00:00
Stefan Prodan
378a2c2a0e Merge pull request #1393 from fluxcd/git-ref-required
Make the Git ref required
2021-05-06 16:30:16 +03:00
Stefan Prodan
2597ad0f73 Make the Git ref required
Remove the default branch value from `flux create source git` and validate that one of the ref options are specified.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-05-06 15:28:55 +03:00
Stefan Prodan
0df34bed59 Merge pull request #1391 from SomtochiAma/grafana-dash
Update Prometheus labels and dashboard
2021-05-06 15:05:49 +03:00
Somtochi Onyekwere
be65cf8052 Change labels in prometheus and grafana dashboard
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-05-06 12:33:41 +01:00
Stefan Prodan
8922753591 Merge pull request #1390 from Callisto13/string-slice-var
Switch StringArrayVar flags to use StringSliceVar
2021-05-06 14:27:51 +03:00
Claudia Beresford
87e11ed653 Switch StringArrayVar flags to use StringSliceVar
StringSliceVar allows for more flexibility when passing vars to list
flags.
Both formats will be supported:
- '--foo=one --foo=two'
- '--foo=one,two'

Signed-off-by: Claudia Beresford <claudiaberesford@gmail.com>
2021-05-06 10:09:36 +01:00
Stefan Prodan
ab34771b3d Merge pull request #1384 from fluxcd/go-git-providers-v0.1.0
Update go-git-providers to v0.1
2021-05-06 11:31:00 +03:00
Stefan Prodan
e733c4f55a Update go-git-providers to v0.1.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-05-06 11:03:52 +03:00
Daniel Holbach
37b60666c4 Merge pull request #1389 from dholbach/fix-1388
Remove ' command' from Flux CLI docs title
2021-05-06 10:00:56 +02:00
Daniel Holbach
734d736bdf Remove ' command' from Flux CLI docs title
Fixes: #1388

Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-05-06 08:52:36 +02:00
Daniel Holbach
8ca65059f7 Merge pull request #1381 from dholbach/toolkit-website-followup
Update more toolkit.fluxcd.io redirects
2021-05-04 22:16:41 +02:00
Daniel Holbach
086f174463 Update more toolkit.fluxcd.io redirects
Following up on #1380 some more docs links which
	now live under fluxcd.io itself.

Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-05-04 17:04:44 +02:00
Daniel Holbach
48fd70fc09 Merge pull request #1380 from fluxcd/fix-links
Migrate the GitOps toolkit links to the new docs website
2021-05-04 16:59:09 +02:00
Stefan Prodan
606266e976 Migrate the GitOps toolkit links to the new docs website
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-05-04 17:46:25 +03:00
Stefan Prodan
f7006a8172 Merge pull request #1369 from fluxcd/update-components
Update toolkit components
2021-04-29 15:05:43 +03:00
fluxcdbot
653dcc8d78 Update toolkit components
- kustomize-controller to v0.12.0
  https://github.com/fluxcd/kustomize-controller/blob/v0.12.0/CHANGELOG.md
- image-reflector-controller to v0.9.1
  https://github.com/fluxcd/image-reflector-controller/blob/v0.9.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-04-29 10:07:39 +00:00
Stefan Prodan
8df140c713 Merge pull request #1365 from dholbach/fix-1221
Remove content which has moved to f/website
2021-04-29 10:24:01 +03:00
Daniel Holbach
089af9cc90 remove docs/index.md as well - it has been pulled into f/website now too
Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-04-28 17:18:00 +02:00
Daniel Holbach
695fb55b13 Remove Flux CLI docs
They are imported into the docs like so:
	https://github.com/fluxcd/website/blob/main/hack/import-flux2-assets.sh#L139

Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-04-28 12:10:48 +02:00
Daniel Holbach
ec21eedd56 remove content which has moved to f/website
Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-04-28 12:07:34 +02:00
Stefan Prodan
5ba3774fd5 Merge pull request #1358 from SomtochiAma/suspend-all
Add suspend/resume  --all cmd
2021-04-28 12:58:46 +03:00
Somtochi Onyekwere
12a2100fcf Adds suspend and resume all cmd
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-04-28 10:44:51 +01:00
Daniel Holbach
68074d3543 Merge pull request #1364 from dholbach/update-install-url
Update install script URL
2021-04-27 16:40:33 +02:00
Daniel Holbach
18849e36c7 Update install script URL
As we don't pass '-L' to curl, the redirect is
	not followed.

Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-04-27 16:26:06 +02:00
Hidde Beydals
671fe274da Merge pull request #1363 from dholbach/explain-docs
Explain where the docs went
2021-04-27 15:28:21 +02:00
Daniel Holbach
af1d9102b9 explain where docs are
keep netlify config for now (disabled in the app), but only make it ship the _redirects file
add rule for 'install.sh'
move _redirects file into docs/ directory
document redirects and Netlify

Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-04-27 15:16:30 +02:00
Daniel Holbach
9dc10ef7d1 Merge pull request #1361 from dholbach/fix-1135
Stop deploy to Github pages
2021-04-27 14:32:57 +02:00
Daniel Holbach
86a3cf20e7 Stop deploying to Github pages
Fixes: #1135

Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-04-27 14:20:28 +02:00
Daniel Holbach
27a42ecd8e Merge pull request #1360 from dholbach/add-redirects
add redirects file
2021-04-27 14:19:17 +02:00
Daniel Holbach
ae7a59fbb4 try out redirects file
Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-04-27 13:55:16 +02:00
Hidde Beydals
598dfc32e8 Merge pull request #1359 from dholbach/add-components-docs-script
Copy docs assets for Netlify build
2021-04-27 11:36:31 +02:00
Daniel Holbach
a40d124e23 add script to copy docs assets for Netlify build
Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-04-27 11:22:55 +02:00
Daniel Holbach
9df3fcab18 Merge pull request #1353 from dholbach/netlify-build
Specify netlify build
2021-04-27 11:09:33 +02:00
Daniel Holbach
b6ce969d1b Specify netlify build
Addresses: #1135

	Follow https://www.starfallprojects.co.uk/posts/deploy-mkdocs-netlify/
	to eventually fix #1135.

	I realise this litters the main directory somewhat, but I hope
	that once the publication fully works and we turn the site into
	redirects, we can remove these files again. So only a temporary
	measure.

Signed-off-by: Daniel Holbach <daniel@weave.works>
2021-04-27 09:16:06 +02:00
Stefan Prodan
6a37649ee6 Merge pull request #1352 from SomtochiAma/handle-error
Remove redundant getCommand for image repository
2021-04-26 17:50:56 +03:00
Somtochi Onyekwere
8926095660 remove redundant getCommand for image repository
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-04-26 15:28:51 +01:00
Hidde Beydals
bd34870334 Merge pull request #1336 from fluxcd/update-components 2021-04-23 12:51:40 +02:00
Hidde Beydals
a56ce1f867 build: tidy after go mod edit
To ensure the `go.sum` is always up-to-date when the following `go mod
edit` is executed.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-23 12:36:09 +02:00
fluxcdbot
dab5bbd393 Update toolkit components
- source-controller to v0.12.1
  https://github.com/fluxcd/source-controller/blob/v0.12.1/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-04-23 12:34:41 +02:00
Stefan Prodan
15ebfd7eb6 Merge pull request #1334 from fluxcd/helm-CRDsPolicy
Add upgrade CRDs policy arg to create helmrelease cmd
2021-04-23 12:29:24 +03:00
Stefan Prodan
5ab8dd2557 Add upgrade CRDs policy to create helmrelease cmd
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-23 10:46:46 +03:00
Stefan Prodan
9164914d16 Merge pull request #1215 from Frederik-Baetens/main
update sortable image tag guide with github.run_number
2021-04-23 09:25:20 +03:00
Frederik Baetens
c9e0bc0807 add github.run number github actions workflow example
Signed-off-by: Frederik Baetens <baetens.fr@gmail.com>
2021-04-22 22:27:46 +02:00
Frederik Baetens
61439adf9b describe github.run number as a reliable increasing build number
Signed-off-by: Frederik Baetens <baetens.fr@gmail.com>
2021-04-22 22:27:46 +02:00
Hidde Beydals
e4d7450643 Merge pull request #1332 from fluxcd/update-guide-v1alpha2
Update image automation guides to v1alpha2
2021-04-22 19:54:25 +02:00
Stefan Prodan
0fbcfded57 Update image automation migration guide to v1alpha2 APIs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-22 20:40:24 +03:00
Stefan Prodan
fb3a434f95 Update image automation guide to v1alpha2 APIs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-22 20:40:17 +03:00
Hidde Beydals
4f66da84d6 Merge pull request #1208 from defenestration/main
fix link to Mozilla SOPS Azure Guide
2021-04-22 19:38:51 +02:00
Alan B
b67e8aafab Fix Mozilla SOPS link in Azure guide
Signed-off-by: Alan B <a.brevick@techsmith.com>
2021-04-22 19:21:26 +02:00
Hidde Beydals
0b4f1d30a6 Merge pull request #1314 from SomtochiAma/ssh-key-with-password
Add password for ssh private key to create secret git
2021-04-22 19:17:33 +02:00
Somtochi Onyekwere
c494e6bf7e Inject password in create secret git if specified
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-04-22 18:33:41 +02:00
Hidde Beydals
b8c57c7901 Merge pull request #1300 from fluxcd/kustomize-bootstrap
Allow pre-bootstrap customisation of Flux components
2021-04-22 17:33:57 +02:00
Hidde Beydals
6aed4631e7 Register v1alpha2 APIs in runtime Scheme
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-22 17:10:42 +02:00
Stefan Prodan
5df9118365 Add pre-bootstrap customisation to install docs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-22 17:10:42 +02:00
Stefan Prodan
4a4af94d6c Allow pre-bootstrap customisation of Flux components
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-22 17:10:42 +02:00
Hidde Beydals
baa54fb84a Merge pull request #1330 from fluxcd/patch-update-workflow
Fix update automation and update CRDs
2021-04-22 16:48:35 +02:00
Hidde Beydals
cb6470f817 Merge pull request #1328 from fluxcd/bootstrap-team-prnt-fix
Change permission grant error print conditons
2021-04-22 16:25:26 +02:00
Hidde Beydals
1a904e138f Fix update automation and update CRDs
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-22 16:24:36 +02:00
Hidde Beydals
3b482529ff Merge pull request #1323 from fluxcd/update-apis
Update the APIs docs
2021-04-22 16:11:16 +02:00
Hidde Beydals
67997437db Change permission grant error print conditons
Based on observations in
https://github.com/fluxcd/flux2/runs/2410633975:

1. Print error correctly by switching from `%w` to `%s`
2. Only print the change messsage if there has not been an error.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-22 16:10:14 +02:00
Hidde Beydals
a5541eddca Merge pull request #1327 from fluxcd/update-components
Update toolkit components
2021-04-22 15:57:00 +02:00
Stefan Prodan
203157e525 Update the APIs docs
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-22 15:56:49 +02:00
fluxcdbot
655c2261ba Update toolkit components
- helm-controller to v0.10.0
  https://github.com/fluxcd/helm-controller/blob/v0.10.0/CHANGELOG.md
- kustomize-controller to v0.11.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.11.1/CHANGELOG.md
- source-controller to v0.12.0
  https://github.com/fluxcd/source-controller/blob/v0.12.0/CHANGELOG.md
- notification-controller to v0.13.0
  https://github.com/fluxcd/notification-controller/blob/v0.13.0/CHANGELOG.md
- image-reflector-controller to v0.9.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.9.0/CHANGELOG.md
- image-automation-controller to v0.9.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.9.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-04-22 15:42:12 +02:00
Hidde Beydals
45e446eb00 Merge pull request #1325 from fluxcd/build/include-crd-update
build: incl CRD version change in component update
2021-04-22 15:34:52 +02:00
Hidde Beydals
68abe37648 Merge pull request #1200 from kingdonb/jsonnet 2021-04-22 15:22:26 +02:00
Hidde Beydals
df6a0a3762 build: incl CRD version change in component update
This includes updating the version in the `manifests/crds` directory
for the component thas has a newer latest version.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-22 15:21:24 +02:00
Kingdon Barrett
c35bae577f Add (vestigial) reference to configMap.yaml
This part of the jsonnet example was missing a reference and needed a
bit more explanation to accompany the missing reference.

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2021-04-22 15:04:07 +02:00
Kingdon Barrett
3567941eda flux recommends real version numbers*
Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2021-04-22 15:04:07 +02:00
Kingdon Barrett
3c95fe6380 change one word
Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2021-04-22 15:04:07 +02:00
Kingdon Barrett
d07f0d003c add word or two
Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2021-04-22 15:04:07 +02:00
Kingdon Barrett
86774309db minor formatting/verbal fixes
Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2021-04-22 15:04:07 +02:00
Kingdon Barrett
427f23e32d add missing link to 04-update-fleet-infra
Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2021-04-22 15:04:07 +02:00
Kingdon Barrett
70cddde16c Jsonnet examples
It is probably not elegant or idiomatic jsonnet. I am learning Jsonnet.

I believe the explanation is correct, but I still have to retry this
example for repeatability and check for completeness.

* Jsonnet example - gutted

* take some personalize things away
* clean up awkward sentence
* for real gitops

Signed-off-by: Kingdon Barrett <kingdon@weave.works>
2021-04-22 15:04:05 +02:00
Hidde Beydals
e86789b643 Merge pull request #1255 from scottrigby/use-cases-helm 2021-04-22 14:52:56 +02:00
Scott Rigby
f52fec66bd Overriding helm values, managing secrets and configmaps with kustomize plus SOPS, semver range policies, and auto uninstalls and rollbacks
Signed-off-by: Scott Rigby <scott@r6by.com>
2021-04-22 14:19:39 +02:00
Scott Rigby
f4926d1e45 Operator->Controller
Signed-off-by: Scott Rigby <scott@r6by.com>

Co-authored-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-22 14:19:39 +02:00
Scott Rigby
2774c1a5cd Add helm use case intro page
Signed-off-by: Scott Rigby <scott@r6by.com>
2021-04-22 14:19:39 +02:00
Hidde Beydals
8274bc0ea3 Merge pull request #1324 from fluxcd/image-update-v1alpha2
Move to `v1alpha2` image update APIs
2021-04-22 14:11:47 +02:00
Stefan Prodan
e9531e4d57 Merge pull request #1296 from arbourd/values-files
Add `ValuesFiles` documentation
2021-04-22 14:52:47 +03:00
Hidde Beydals
3a8aad7e5c Move to v1alpha2 image update APIs
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-22 13:52:03 +02:00
Dylan Arbour
ef079c5b58 Add ValuesFiles documentation
Signed-off-by: Dylan Arbour <arbourd@users.noreply.github.com>
2021-04-22 13:34:19 +02:00
Hidde Beydals
50332aa2ee Merge pull request #1310 from fluxcd/update-components
Update toolkit components
2021-04-22 13:18:08 +02:00
fluxcdbot
b47f3a57dc Update toolkit components
- helm-controller to v0.10.0
  https://github.com/fluxcd/helm-controller/blob/v0.10.0/CHANGELOG.md
- kustomize-controller to v0.11.1
  https://github.com/fluxcd/kustomize-controller/blob/v0.11.1/CHANGELOG.md
- source-controller to v0.12.0
  https://github.com/fluxcd/source-controller/blob/v0.12.0/CHANGELOG.md
- notification-controller to v0.13.0
  https://github.com/fluxcd/notification-controller/blob/v0.13.0/CHANGELOG.md
- image-reflector-controller to v0.9.0
  https://github.com/fluxcd/image-reflector-controller/blob/v0.9.0/CHANGELOG.md
- image-automation-controller to v0.9.0
  https://github.com/fluxcd/image-automation-controller/blob/v0.9.0/CHANGELOG.md

Signed-off-by: GitHub <noreply@github.com>
2021-04-22 09:49:12 +00:00
Stefan Prodan
9a928744cc Merge pull request #1264 from SomtochiAma/ssh-key-with-password
Add support for password protected SSH keys to bootstrap
2021-04-21 19:39:10 +03:00
Somtochi Onyekwere
328d403507 Set password in secret
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-04-21 17:21:07 +01:00
Stefan Prodan
76ffd76bd3 Merge pull request #1287 from SomtochiAma/get-all-cmd
Add get all command
2021-04-21 18:39:47 +03:00
Somtochi Onyekwere
951589e652 Add get all command
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-04-21 15:45:38 +01:00
Hidde Beydals
7bb0704401 Merge pull request #1308 from fluxcd/windows-path-boot-git
Use slash target path in Git bootstrap sync opts
2021-04-21 12:08:52 +02:00
Hidde Beydals
3aa45e72e7 Use slash target path in Git bootstrap sync opts
As otherwise (comparisons to) cluster configuration will fail due to
Separator differences. Was already fixed for provider implementations.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-21 11:48:36 +02:00
Hidde Beydals
67691e92e3 Merge pull request #1307 from fluxcd/boot-drop-org-repo-autoinit
Drop AutoInit from Org repository create
2021-04-21 11:44:17 +02:00
Hidde Beydals
43388ec67b Drop AutoInit from Org repository create
Pushing the first branch is sufficient to set a default, and the
`README.md` (and/or LICENSE) can better be pushed later on so commit
author and templates be configured.

This was already done for User in an earlier patch release.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-21 11:24:59 +02:00
Stefan Prodan
2fe3934491 Merge pull request #1280 from kaizentm/main
Keep network policy order as defined
2021-04-20 10:13:30 +03:00
Eugene
f60ba95b4c Keep policy order as defined
Signed-off-by: Eugene <eugene.fedor@gmail.com>
2021-04-19 13:21:32 -07:00
Hidde Beydals
4ecf541748 Merge pull request #1291 from jlengelsen/bug-install-script-binary-ownership
Fix ownership issue in bash install script
2021-04-19 15:01:25 +02:00
Julian Lengelsen
7994829765 Fix ownership issue in bash install script
When using tar with sudo the extracted files will retain the ownership
of the files in the archive. When using the bash install script the flux
binary is owned by user ID 1001 and group docker after installation.

This commit fixes the ownership by appending the -o option to the tar
command which will extract files with the correct ownership, namely user
root and group root.

Signed-off-by: Julian Lengelsen <julian.lengelsen@th-koeln.de>
2021-04-18 13:30:09 +02:00
Hidde Beydals
ce14951436 Merge pull request #1288 from sa-spag/doc 2021-04-16 16:35:30 +02:00
Alexis Gauthiez
a5ce8221a3 Suggest an alternative gradual migration technique
Signed-off-by: Alexis Gauthiez <alexis.gauthiez@blablacar.com>
2021-04-16 14:45:50 +02:00
Alexis Gauthiez
e6344ef18e Fix documentation typo
Signed-off-by: Alexis Gauthiez <alexis.gauthiez@blablacar.com>
2021-04-16 14:45:50 +02:00
Stefan Prodan
99e60634ad Merge pull request #1285 from SomtochiAma/reconcile-diff-ns
Ensure kustomization/helmrelease is reconciled when source is in a different namespace
2021-04-16 11:25:03 +03:00
Somtochi Onyekwere
6c656b7366 Fix reconcile with source in a different namespace
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-04-16 08:53:30 +01:00
Stefan Prodan
fc3a09b5ad Merge pull request #1278 from alisondy/create-alert-es-ns
Change createAlertCmdRun parsing to include namespace
2021-04-16 08:50:26 +03:00
Alison Dowdney
b1484f2f24 Change createAlertCmdRun parsing to include namespace
Signed-off-by: Alison Dowdney <alison@alisondowdney.com>
2021-04-15 22:52:15 +01:00
Hidde Beydals
7dcf884e38 Merge pull request #1262 from fluxcd/reconcile-opt
Put potentially destructive reconcile behind flag
2021-04-13 17:38:35 +02:00
Hidde Beydals
b6d349da8c Put potentially destructive reconcile behind flag
The behavior introduced during the introduction of go-git-providers
was more strict, and has proven pretty quickly to not be useful to
all users. Therefore, the reconciliation behavior for repository
configuration has been put behind an opt-in flag, so that it does
not overwrite people their configs by accident.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-13 17:19:19 +02:00
Stefan Prodan
40ce3d50c2 Merge pull request #1256 from fluxcd/openapi2jsonschema
Publish OpenAPI schemas for Flux CRDs
2021-04-13 15:17:38 +03:00
Stefan Prodan
68046067c5 Generate OpenAPI schema in CI
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-13 13:17:36 +03:00
Stefan Prodan
e3b12a8a24 Merge pull request #1253 from fluxcd/btstrp-private-flag
Change private flag description
2021-04-13 09:26:29 +03:00
Hidde Beydals
f123b9d3cb Change private flag description
To highlight the fact that it configures the repository as defined,
which was not _really_ clear to some users and has resulted in public
repositories accidentally being changed to private (losing important
goodies like stars and linked forks).

Discussion on this is ongoing and there will likely be other
improvements in the near future to protect users against this.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-04-12 13:19:46 +02:00
675 changed files with 22490 additions and 16726 deletions

View File

@@ -1,46 +0,0 @@
---
name: Bug report
about: Create a report to help us improve Flux v2
title: ''
assignees: ''
---
<!--
Find out more about your support options and getting help at
https://fluxcd.io/support/
-->
### Describe the bug
A clear and concise description of what the bug is.
### To Reproduce
Steps to reproduce the behaviour:
1. Provide Flux install instructions
2. Provide a GitHub repository with Kubernetes manifests
### Expected behavior
A clear and concise description of what you expected to happen.
### Additional context
- Kubernetes version:
- Git provider:
- Container registry provider:
Below please provide the output of the following commands:
```cli
flux --version
flux check
kubectl -n <namespace> get all
kubectl -n <namespace> logs deploy/source-controller
kubectl -n <namespace> logs deploy/kustomize-controller
```

84
.github/ISSUE_TEMPLATE/bug_report.yaml vendored Normal file
View File

@@ -0,0 +1,84 @@
---
name: Bug report
description: Create a report to help us improve Flux
body:
- type: markdown
attributes:
value: |
## Support
Find out more about your support options and getting help at: https://fluxcd.io/support/
- type: textarea
validations:
required: true
attributes:
label: Describe the bug
description: A clear description of what the bug is.
- type: textarea
validations:
required: true
attributes:
label: Steps to reproduce
description: |
Steps to reproduce the problem.
placeholder: |
For example:
1. Install Flux with the additional image automation controllers
2. Run command '...'
3. See error
- type: textarea
validations:
required: true
attributes:
label: Expected behavior
description: A brief description of what you expected to happen.
- type: textarea
attributes:
label: Screenshots and recordings
description: |
If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/
- type: input
validations:
required: true
attributes:
label: OS / Distro
description: The OS / distro you are executing `flux` on. If not applicable, write `N/A`.
placeholder: e.g. Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15...
- type: input
validations:
required: true
attributes:
label: Flux version
description: Run `flux version --client`. If not applicable, write `N/A`.
placeholder: e.g. v0.20.1
- type: textarea
validations:
required: true
attributes:
label: Flux check
description: Run `flux check`. If not applicable, write `N/A`.
placeholder: |
For example:
► checking prerequisites
✔ Kubernetes 1.21.1 >=1.19.0-0
► checking controllers
✔ all checks passed
- type: input
attributes:
label: Git provider
description: If applicable, add the Git provider you are having problems with, e.g. GitHub (Enterprise), GitLab, etc.
- type: input
attributes:
label: Container Registry provider
description: If applicable, add the Container Registry provider you are having problems with, e.g. DockerHub, GitHub Packages, Quay.io, etc.
- type: textarea
attributes:
label: Additional context
description: Add any other context about the problem here. This can be logs (e.g. output from `flux logs`), environment specific caveats, etc.
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/fluxcd/.github/blob/main/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true

View File

@@ -8,10 +8,15 @@ pkgbase = flux-bin
arch = armv7h
arch = aarch64
license = APACHE
optdepends = kubectl
source_x86_64 = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_amd64.tar.gz
source_armv6h = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_arm.tar.gz
source_armv7h = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_arm.tar.gz
source_aarch64 = flux-bin-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v1/flux_${PKGVER}_linux_arm64.tar.gz
optdepends = bash-completion: auto-completion for flux in Bash
optdepends = zsh-completions: auto-completion for flux in ZSH
source_x86_64 = ${PKGNAME}-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${PKGVER}/flux_${PKGVER}_linux_amd64.tar.gz
sha256sums_x86_64 = ${SHA256SUM_AMD64}
source_armv6h = ${PKGNAME}-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${PKGVER}/flux_${PKGVER}_linux_arm.tar.gz
sha256sums_armv6h = ${SHA256SUM_ARM}
source_armv7h = ${PKGNAME}-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${PKGVER}/flux_${PKGVER}_linux_arm.tar.gz
sha256sums_armv7h = ${SHA256SUM_ARM}
source_aarch64 = ${PKGNAME}-${PKGVER}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${PKGVER}/flux_${PKGVER}_linux_arm64.tar.gz
sha256sums_aarch64 = ${SHA256SUM_ARM64}
pkgname = flux-bin

View File

@@ -8,9 +8,8 @@ pkgdesc="Open and extensible continuous delivery solution for Kubernetes"
url="https://fluxcd.io/"
arch=("x86_64" "armv6h" "armv7h" "aarch64")
license=("APACHE")
optdepends=('kubectl: for apply actions on the Kubernetes cluster',
'bash-completion: auto-completion for flux in Bash',
'zsh-completions: auto-completion for flux in ZSH')
optdepends=('bash-completion: auto-completion for flux in Bash'
'zsh-completions: auto-completion for flux in ZSH')
source_x86_64=(
"${pkgname}-${pkgver}.tar.gz::https://github.com/fluxcd/flux2/releases/download/v${pkgver}/flux_${pkgver}_linux_amd64.tar.gz"
)

View File

@@ -10,7 +10,6 @@ pkgbase = flux-go
license = APACHE
makedepends = go
depends = glibc
optdepends = kubectl
provides = flux-bin
conflicts = flux-bin
replaces = flux-cli

View File

@@ -12,9 +12,8 @@ provides=("flux-bin")
conflicts=("flux-bin")
replaces=("flux-cli")
depends=("glibc")
makedepends=('go>=1.16', 'kustomize>=3.0')
optdepends=('kubectl: for apply actions on the Kubernetes cluster',
'bash-completion: auto-completion for flux in Bash',
makedepends=('go>=1.17', 'kustomize>=3.0')
optdepends=('bash-completion: auto-completion for flux in Bash',
'zsh-completions: auto-completion for flux in ZSH')
source=(
"${pkgname}-${pkgver}.tar.gz::https://github.com/fluxcd/flux2/archive/v${pkgver}.tar.gz"
@@ -31,12 +30,20 @@ build() {
export CGO_CXXFLAGS="$CXXFLAGS"
export CGO_CPPFLAGS="$CPPFLAGS"
export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
./manifests/scripts/bundle.sh "${PWD}/manifests" "${PWD}/cmd/flux/manifests"
make cmd/flux/.manifests.done
go build -ldflags "-linkmode=external -X main.VERSION=${pkgver}" -o ${_srcname} ./cmd/flux
}
check() {
cd "flux2-${pkgver}"
case $CARCH in
aarch64)
export ENVTEST_ARCH=arm64
;;
armv6h|armv7h)
export ENVTEST_ARCH=arm
;;
esac
make test
}

View File

@@ -10,7 +10,6 @@ pkgbase = flux-scm
license = APACHE
makedepends = go
depends = glibc
optdepends = kubectl
provides = flux-bin
conflicts = flux-bin
source = git+https://github.com/fluxcd/flux2.git

View File

@@ -11,9 +11,8 @@ license=("APACHE")
provides=("flux-bin")
conflicts=("flux-bin")
depends=("glibc")
makedepends=('go>=1.16', 'kustomize>=3.0')
optdepends=('kubectl: for apply actions on the Kubernetes cluster',
'bash-completion: auto-completion for flux in Bash',
makedepends=('go>=1.17', 'kustomize>=3.0', 'git')
optdepends=('bash-completion: auto-completion for flux in Bash',
'zsh-completions: auto-completion for flux in ZSH')
source=(
"git+https://github.com/fluxcd/flux2.git"
@@ -33,12 +32,20 @@ build() {
export CGO_CXXFLAGS="$CXXFLAGS"
export CGO_CPPFLAGS="$CPPFLAGS"
export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
make cmd/flux/manifests
make cmd/flux/.manifests.done
go build -ldflags "-linkmode=external -X main.VERSION=${pkgver}" -o ${_srcname} ./cmd/flux
}
check() {
cd "flux2"
case $CARCH in
aarch64)
export ENVTEST_ARCH=arm64
;;
armv6h|armv7h)
export ENVTEST_ARCH=arm
;;
esac
make test
}

7
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

72
.github/runners/README.md vendored Normal file
View File

@@ -0,0 +1,72 @@
# Flux ARM64 GitHub runners
The Flux ARM64 end-to-end tests run on Equinix instances provisioned with Docker and GitHub self-hosted runners.
## Current instances
| Runner | Instance | Region |
|---------------|---------------------|--------|
| equinix-arm-1 | flux-equinix-arm-01 | AMS1 |
| equinix-arm-2 | flux-equinix-arm-01 | AMS1 |
| equinix-arm-3 | flux-equinix-arm-01 | AMS1 |
| equinix-arm-4 | flux-equinix-arm-02 | DFW2 |
| equinix-arm-5 | flux-equinix-arm-02 | DFW2 |
| equinix-arm-6 | flux-equinix-arm-02 | DFW2 |
## Instance setup
In order to add a new runner to the GitHub Actions pool,
first create a server on Equinix with the following configuration:
- Type: c2.large.arm
- OS: Ubuntu 20.04
### Install prerequisites
- SSH into a newly created instance
```shell
ssh root@<instance-public-IP>
```
- Create the ubuntu user
```shell
adduser ubuntu
usermod -aG sudo ubuntu
su - ubuntu
```
- Create the prerequisites dir
```shell
mkdir -p prereq && cd prereq
```
- Download the prerequisites script
```shell
curl -sL https://raw.githubusercontent.com/fluxcd/flux2/main/.github/runners/prereq.sh > prereq.sh \
&& chmod +x ./prereq.sh
```
- Install the prerequisites
```shell
sudo ./prereq.sh
```
### Install runners
- Retrieve the GitHub runner token from the repository [settings page](https://github.com/fluxcd/flux2/settings/actions/runners/new?arch=arm64&os=linux)
- Create 3 directories `runner1`, `runner2`, `runner3`
- In each dir run:
```shell
curl -sL https://raw.githubusercontent.com/fluxcd/flux2/main/.github/runners/runner-setup.sh > runner-setup.sh \
&& chmod +x ./runner-setup.sh
./runner-setup.sh equinix-arm-<NUMBER> <TOKEN>
```
- Reboot the instance
```shell
sudo reboot
```
- Navigate to the GitHub repository [runners page](https://github.com/fluxcd/flux2/settings/actions/runners) and check the runner status

68
.github/runners/prereq.sh vendored Executable file
View File

@@ -0,0 +1,68 @@
#!/usr/bin/env bash
# Copyright 2021 The Flux authors. All rights reserved.
#
# 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.
# This script installs the prerequisites for running Flux end-to-end tests with Docker and GitHub self-hosted runners.
set -eu
KIND_VERSION=0.14.0
KUBECTL_VERSION=1.24.0
KUSTOMIZE_VERSION=4.5.4
HELM_VERSION=3.8.2
GITHUB_RUNNER_VERSION=2.291.1
PACKAGES="apt-transport-https ca-certificates software-properties-common build-essential libssl-dev gnupg lsb-release jq pkg-config"
# install prerequisites
apt-get update \
&& apt-get install -y -q ${PACKAGES} \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# install docker
curl -fsSL https://get.docker.com -o get-docker.sh \
&& chmod +x get-docker.sh
./get-docker.sh
systemctl enable docker.service
systemctl enable containerd.service
usermod -aG docker ubuntu
# install kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-linux-arm64
install -o root -g root -m 0755 kind /usr/local/bin/kind
# install kubectl
curl -LO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/arm64/kubectl"
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
# install kustomize
curl -Lo ./kustomize.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_arm64.tar.gz \
&& tar -zxvf kustomize.tar.gz \
&& rm kustomize.tar.gz
install -o root -g root -m 0755 kustomize /usr/local/bin/kustomize
# install helm
curl -Lo ./helm.tar.gz https://get.helm.sh/helm-v${HELM_VERSION}-linux-arm64.tar.gz \
&& tar -zxvf helm.tar.gz \
&& rm helm.tar.gz
install -o root -g root -m 0755 linux-arm64/helm /usr/local/bin/helm
# download runner
curl -o actions-runner-linux-arm64.tar.gz -L https://github.com/actions/runner/releases/download/v${GITHUB_RUNNER_VERSION}/actions-runner-linux-arm64-${GITHUB_RUNNER_VERSION}.tar.gz \
&& tar xzf actions-runner-linux-arm64.tar.gz \
&& rm actions-runner-linux-arm64.tar.gz
# install runner dependencies
./bin/installdependencies.sh

37
.github/runners/runner-setup.sh vendored Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Copyright 2021 The Flux authors. All rights reserved.
#
# 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.
# This script installs a GitHub self-hosted ARM64 runner for running Flux end-to-end tests.
set -eu
RUNNER_NAME=$1
REPOSITORY_TOKEN=$2
REPOSITORY_URL=${3:-https://github.com/fluxcd/flux2}
GITHUB_RUNNER_VERSION=2.285.1
# download runner
curl -o actions-runner-linux-arm64.tar.gz -L https://github.com/actions/runner/releases/download/v${GITHUB_RUNNER_VERSION}/actions-runner-linux-arm64-${GITHUB_RUNNER_VERSION}.tar.gz \
&& tar xzf actions-runner-linux-arm64.tar.gz \
&& rm actions-runner-linux-arm64.tar.gz
# register runner with GitHub
./config.sh --unattended --url ${REPOSITORY_URL} --token ${REPOSITORY_TOKEN} --name ${RUNNER_NAME}
# start runner
sudo ./svc.sh install
sudo ./svc.sh start

50
.github/workflows/README.md vendored Normal file
View File

@@ -0,0 +1,50 @@
# Flux GitHub Workflows
## End-to-end Testing
The e2e workflows run a series of tests to ensure that the Flux CLI and
the GitOps Toolkit controllers work well all together.
The tests are written in Go, Bash, Make and Terraform.
| Workflow | Jobs | Runner | Role |
|--------------------|----------------------|----------------|-----------------------------------------------|
| e2e.yaml | e2e-amd64-kubernetes | GitHub Ubuntu | integration testing with Kubernetes Kind<br/> |
| e2e-arm64.yaml | e2e-arm64-kubernetes | Equinix Ubuntu | integration testing with Kubernetes Kind<br/> |
| e2e-bootstrap.yaml | e2e-boostrap-github | GitHub Ubuntu | integration testing with GitHub API<br/> |
| e2e-azure.yaml | e2e-amd64-aks | GitHub Ubuntu | integration testing with Azure API<br/> |
| scan.yaml | scan-fossa | GitHub Ubuntu | license scanning<br/> |
| scan.yaml | scan-snyk | GitHub Ubuntu | vulnerability scanning<br/> |
| scan.yaml | scan-codeql | GitHub Ubuntu | vulnerability scanning<br/> |
## Components Update
The components update workflow scans the GitOps Toolkit controller repositories for new releases,
amd when it finds a new controller version, the workflow performs the following steps:
- Updates the controller API package version in `go.mod`.
- Patches the controller CRDs version in the `manifests/crds` overlay.
- Patches the controller Deployment version in `manifests/bases` overlay.
- Opens a Pull Request against the `main` branch.
- Triggers the e2e test suite to run for the opened PR.
| Workflow | Jobs | Runner | Role |
|-------------|-------------------|---------------|-----------------------------------------------------|
| update.yaml | update-components | GitHub Ubuntu | update the GitOps Toolkit APIs and controllers<br/> |
## Release
The release workflow is triggered by a semver Git tag and performs the following steps:
- Generates the Flux install manifests (YAML).
- Generates the OpenAPI validation schemas for the GitOps Toolkit CRDs (JSON).
- Generates a Software Bill of Materials (SPDX JSON).
- Builds the Flux CLI binaries and the multi-arch container images.
- Pushes the container images to GitHub Container Registry and DockerHub.
- Signs the sbom, the binaries checksum and the container images with Cosign and GitHub OIDC.
- Uploads the sbom, binaries, checksums and install manifests to GitHub Releases.
- Pushes the install manifests as OCI artifacts to GitHub Container Registry and DockerHub.
- Signs the OCI artifacts with Cosign and GitHub OIDC.
| Workflow | Jobs | Runner | Role |
|--------------|------------------------|---------------|------------------------------------------------------|
| release.yaml | release-flux-cli | GitHub Ubuntu | build, push and sign the CLI release artifacts<br/> |
| release.yaml | release-flux-manifests | GitHub Ubuntu | build, push and sign the Flux install manifests<br/> |

View File

@@ -1,76 +0,0 @@
name: Publish docs via GitHub Pages
on:
push:
branches: [ 'docs*', main ]
jobs:
build:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v1
- name: Copy assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
controller_version() {
sed -n "s/.*$1\/releases\/download\/\(.*\)\/.*/\1/p;n" manifests/bases/$1/kustomization.yaml
}
{
# source-controller CRDs
SOURCE_VER=$(controller_version source-controller)
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/source-controller/$SOURCE_VER/docs/api/source.md" > docs/components/source/api.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/source-controller/$SOURCE_VER/docs/spec/v1beta1/gitrepositories.md" > docs/components/source/gitrepositories.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/source-controller/$SOURCE_VER/docs/spec/v1beta1/helmrepositories.md" > docs/components/source/helmrepositories.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/source-controller/$SOURCE_VER/docs/spec/v1beta1/helmcharts.md" > docs/components/source/helmcharts.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/source-controller/$SOURCE_VER/docs/spec/v1beta1/buckets.md" > docs/components/source/buckets.md
}
{
# kustomize-controller CRDs
KUSTOMIZE_VER=$(controller_version kustomize-controller)
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/kustomize-controller/$KUSTOMIZE_VER/docs/api/kustomize.md" > docs/components/kustomize/api.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/kustomize-controller/$KUSTOMIZE_VER/docs/spec/v1beta1/kustomization.md" > docs/components/kustomize/kustomization.md
}
{
# helm-controller CRDs
HELM_VER=$(controller_version helm-controller)
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/helm-controller/$HELM_VER/docs/api/helmrelease.md" > docs/components/helm/api.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/helm-controller/$HELM_VER/docs/spec/v2beta1/helmreleases.md" > docs/components/helm/helmreleases.md
}
{
# notification-controller CRDs
NOTIFICATION_VER=$(controller_version notification-controller)
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/notification-controller/$NOTIFICATION_VER/docs/api/notification.md" > docs/components/notification/api.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/notification-controller/$NOTIFICATION_VER/docs/spec/v1beta1/event.md" > docs/components/notification/event.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/notification-controller/$NOTIFICATION_VER/docs/spec/v1beta1/alert.md" > docs/components/notification/alert.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/notification-controller/$NOTIFICATION_VER/docs/spec/v1beta1/provider.md" > docs/components/notification/provider.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/notification-controller/$NOTIFICATION_VER/docs/spec/v1beta1/receiver.md" > docs/components/notification/receiver.md
}
{
# image-*-controller CRDs; these use the same API group
IMG_REFL_VER=$(controller_version image-reflector-controller)
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/image-reflector-controller/$IMG_REFL_VER/docs/api/image-reflector.md" > docs/components/image/reflector-api.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/image-reflector-controller/$IMG_REFL_VER/docs/spec/v1alpha1/imagerepositories.md" > docs/components/image/imagerepositories.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/image-reflector-controller/$IMG_REFL_VER/docs/spec/v1alpha1/imagepolicies.md" > docs/components/image/imagepolicies.md
IMG_AUTO_VER=$(controller_version image-automation-controller)
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/image-automation-controller/$IMG_AUTO_VER/docs/api/image-automation.md" > docs/components/image/automation-api.md
curl -# -Lf "https://raw.githubusercontent.com/fluxcd/image-automation-controller/$IMG_AUTO_VER/docs/spec/v1alpha1/imageupdateautomations.md" > docs/components/image/imageupdateautomations.md
}
{
# install script
cp install/flux.sh docs/install.sh
}
- name: Deploy docs
uses: mhausenblas/mkdocs-deploy-gh-pages@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_DOMAIN: toolkit.fluxcd.io

40
.github/workflows/e2e-arm64.yaml vendored Normal file
View File

@@ -0,0 +1,40 @@
name: e2e-arm64
on:
workflow_dispatch:
push:
branches: [ main, update-components ]
permissions:
contents: read
jobs:
e2e-arm64-kubernetes:
# Hosted on Equinix
# Docs: https://github.com/fluxcd/flux2/tree/main/.github/runners
runs-on: [self-hosted, Linux, ARM64, equinix]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
- name: Prepare
id: prep
run: |
echo ::set-output name=CLUSTER::arm64-${GITHUB_SHA:0:7}-$(date +%s)
echo ::set-output name=CONTEXT::kind-arm64-${GITHUB_SHA:0:7}-$(date +%s)
- name: Build
run: |
make build
- name: Setup Kubernetes Kind
run: |
kind create cluster --name ${{ steps.prep.outputs.CLUSTER }} --kubeconfig=/tmp/${{ steps.prep.outputs.CLUSTER }}
- name: Run e2e tests
run: TEST_KUBECONFIG=/tmp/${{ steps.prep.outputs.CLUSTER }} make e2e
- name: Cleanup
if: always()
run: |
kind delete cluster --name ${{ steps.prep.outputs.CLUSTER }}
rm /tmp/${{ steps.prep.outputs.CLUSTER }}

66
.github/workflows/e2e-azure.yaml vendored Normal file
View File

@@ -0,0 +1,66 @@
name: e2e-azure
on:
workflow_dispatch:
schedule:
- cron: '0 6 * * *'
push:
branches: [ azure* ]
permissions:
contents: read
jobs:
e2e-amd64-aks:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Restore Go cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go1.18-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go1.18-
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
- name: Install libgit2
run: |
echo "deb http://archive.ubuntu.com/ubuntu/ kinetic universe" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install -y -t kinetic libgit2-dev=1.3.0+dfsg.1-3ubuntu1
- name: Setup Flux CLI
run: |
make build
mkdir -p $HOME/.local/bin
mv ./bin/flux $HOME/.local/bin
- name: Setup SOPS
run: |
wget https://github.com/mozilla/sops/releases/download/v3.7.1/sops-v3.7.1.linux
chmod +x sops-v3.7.1.linux
mkdir -p $HOME/.local/bin
mv sops-v3.7.1.linux $HOME/.local/bin/sops
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.2
with:
terraform_version: 1.2.8
terraform_wrapper: false
- name: Setup Azure CLI
run: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- name: Run Azure e2e tests
env:
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
run: |
echo $HOME
echo $PATH
ls $HOME/.local/bin
az login --service-principal -u ${ARM_CLIENT_ID} -p ${ARM_CLIENT_SECRET} -t ${ARM_TENANT_ID}
cd ./tests/azure
go test -v -coverprofile cover.out -timeout 60m .

View File

@@ -1,36 +1,43 @@
name: bootstrap
name: e2e-bootstrap
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
github:
e2e-boostrap-github:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]'
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Restore Go cache
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go1.16-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-go1.18-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go1.16-
${{ runner.os }}-go1.18-
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16.x
go-version: 1.19.x
- name: Setup Kubernetes
uses: engineerd/setup-kind@v0.5.0
with:
version: v0.16.0
image: kindest/node:v1.25.2@sha256:9be91e9e9cdf116809841fc77ebdb8845443c4c72fe5218f3ae9eb57fdb4bace
- name: Setup Kustomize
uses: fluxcd/pkg//actions/kustomize@main
- name: Build
run: |
make cmd/flux/manifests
make cmd/flux/.manifests.done
go build -o /tmp/flux ./cmd/flux
- name: Set outputs
id: vars
@@ -61,21 +68,65 @@ jobs:
--team=team-z
env:
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
- name: uninstall
run: |
/tmp/flux uninstall -s --keep-namespace
kubectl delete ns flux-system --timeout=10m --wait=true
- name: bootstrap reinstall
- name: bootstrap customize
run: |
make setup-bootstrap-patch
/tmp/flux bootstrap github --manifests ./manifests/install/ \
--owner=fluxcd-testing \
--repository=${{ steps.vars.outputs.test_repo_name }} \
--branch=main \
--path=test-cluster \
--team=team-z
if [ $(kubectl get deployments.apps source-controller -o jsonpath='{.spec.template.spec.securityContext.runAsUser}') != "10000" ]; then
echo "Bootstrap not customized as controller is not running as user 10000" && exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
GITHUB_REPO_NAME: ${{ steps.vars.outputs.test_repo_name }}
GITHUB_ORG_NAME: fluxcd-testing
- name: libgit2
run: |
/tmp/flux create source git test-libgit2 \
--url=ssh://git@github.com/fluxcd-testing/${{ steps.vars.outputs.test_repo_name }} \
--git-implementation=libgit2 \
--secret-ref=flux-system \
--branch=main
- name: uninstall
run: |
/tmp/flux uninstall -s --keep-namespace
kubectl delete ns flux-system --timeout=10m --wait=true
- name: test image automation
run: |
make setup-image-automation
/tmp/flux bootstrap github --manifests ./manifests/install/ \
--owner=fluxcd-testing \
--repository=${{ steps.vars.outputs.test_repo_name }} \
--branch=main \
--path=test-cluster \
--read-write-key
/tmp/flux reconcile image repository podinfo
/tmp/flux reconcile image update flux-system
/tmp/flux get images all
retries=10
count=0
ok=false
until ${ok}; do
/tmp/flux get image update flux-system | grep 'commit' && ok=true || ok=false
count=$(($count + 1))
if [[ ${count} -eq ${retries} ]]; then
echo "No more retries left"
exit 1
fi
sleep 6
/tmp/flux reconcile image update flux-system
done
env:
GITHUB_TOKEN: ${{ secrets.GITPROVIDER_BOT_TOKEN }}
GITHUB_REPO_NAME: ${{ steps.vars.outputs.test_repo_name }}
GITHUB_ORG_NAME: fluxcd-testing
- name: delete repository
if: ${{ always() }}
run: |
curl \
-X DELETE \

View File

@@ -1,42 +1,53 @@
name: e2e
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches: [ main, oci ]
permissions:
contents: read
jobs:
kind:
e2e-amd64-kubernetes:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Restore Go cache
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go1.16-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-go1.18-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go1.16-
${{ runner.os }}-go1.18-
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16.x
go-version: 1.19.x
- name: Setup Kubernetes
uses: engineerd/setup-kind@v0.5.0
with:
version: "v0.10.0"
image: kindest/node:v1.20.2@sha256:8f7ea6e7642c0da54f04a7ee10431549c0257315b3a634f6ef2fecaaedb19bab
version: v0.11.1
image: kindest/node:v1.20.7
config: .github/kind/config.yaml # disable KIND-net
- name: Setup Calico for network policy
run: |
kubectl apply -f https://docs.projectcalico.org/v3.16/manifests/calico.yaml
kubectl apply -f https://docs.projectcalico.org/v3.20/manifests/calico.yaml
kubectl -n kube-system set env daemonset/calico-node FELIX_IGNORELOOSERPF=true
- name: Setup Kustomize
uses: fluxcd/pkg//actions/kustomize@main
- name: Run test
- name: Run tests
run: make test
- name: Run e2e tests
run: TEST_KUBECONFIG=$HOME/.kube/config make e2e
- name: Check if working tree is dirty
run: |
if [[ $(git diff --stat) != '' ]]; then
@@ -74,6 +85,13 @@ jobs:
--tag-semver=">=3.2.3" \
--export | kubectl apply -f -
/tmp/flux delete source git podinfo-export --silent
- name: flux create source git libgit2 semver
run: |
/tmp/flux create source git podinfo-libgit2 \
--url https://github.com/stefanprodan/podinfo \
--tag-semver=">=3.2.3" \
--git-implementation=libgit2
/tmp/flux delete source git podinfo-libgit2 --silent
- name: flux get sources git
run: |
/tmp/flux get sources git
@@ -87,10 +105,15 @@ jobs:
--path="./deploy/overlays/dev" \
--prune=true \
--interval=5m \
--validation=client \
--health-check="Deployment/frontend.dev" \
--health-check="Deployment/backend.dev" \
--health-check-timeout=3m
- name: flux trace
run: |
/tmp/flux trace frontend \
--kind=deployment \
--api-version=apps/v1 \
--namespace=dev
- name: flux reconcile kustomization --with-source
run: |
/tmp/flux reconcile kustomization podinfo --with-source
@@ -154,6 +177,36 @@ jobs:
- name: flux delete source git
run: |
/tmp/flux delete source git podinfo --silent
- name: flux oci artifacts
run: |
/tmp/flux push artifact oci://localhost:5000/fluxcd/flux:${{ github.sha }} \
--path="./manifests" \
--source="${{ github.repositoryUrl }}" \
--revision="${{ github.ref }}/${{ github.sha }}"
/tmp/flux tag artifact oci://localhost:5000/fluxcd/flux:${{ github.sha }} \
--tag latest
/tmp/flux list artifacts oci://localhost:5000/fluxcd/flux
- name: flux oci repositories
run: |
/tmp/flux create source oci podinfo-oci \
--url oci://ghcr.io/stefanprodan/manifests/podinfo \
--tag-semver 6.1.x \
--interval 10m
/tmp/flux create kustomization podinfo-oci \
--source=OCIRepository/podinfo-oci \
--path="./kustomize" \
--prune=true \
--interval=5m \
--target-namespace=default \
--wait=true \
--health-check-timeout=3m
/tmp/flux reconcile source oci podinfo-oci
/tmp/flux suspend source oci podinfo-oci
/tmp/flux get sources oci
/tmp/flux resume source oci podinfo-oci
/tmp/flux export source oci podinfo-oci
/tmp/flux delete ks podinfo-oci --silent
/tmp/flux delete source oci podinfo-oci --silent
- name: flux create tenant
run: |
/tmp/flux create tenant dev-team --with-namespace=apps
@@ -164,26 +217,6 @@ jobs:
--chart=podinfo \
--chart-version="5.0.x" \
--service-account=dev-team
- name: flux create image repository
run: |
/tmp/flux create image repository podinfo \
--image=ghcr.io/stefanprodan/podinfo \
--interval=1m
- name: flux create image policy
run: |
/tmp/flux create image policy podinfo \
--image-ref=podinfo \
--interval=1m \
--select-semver=5.0.x
- name: flux create image policy podinfo-select-alpha
run: |
/tmp/flux create image policy podinfo-alpha \
--image-ref=podinfo \
--interval=1m \
--select-alpha=desc
- name: flux get image policy
run: |
/tmp/flux get image policy podinfo | grep '5.0.3'
- name: flux2-kustomize-helm-example
run: |
/tmp/flux create source git flux-system \
@@ -193,7 +226,14 @@ jobs:
/tmp/flux create kustomization flux-system \
--source=flux-system \
--path=./clusters/staging
kubectl -n flux-system wait kustomization/apps --for=condition=ready --timeout=2m
kubectl -n flux-system wait kustomization/infrastructure --for=condition=ready --timeout=5m
kubectl -n flux-system wait kustomization/apps --for=condition=ready --timeout=5m
kubectl -n nginx wait helmrelease/nginx --for=condition=ready --timeout=5m
kubectl -n redis wait helmrelease/redis --for=condition=ready --timeout=5m
kubectl -n podinfo wait helmrelease/podinfo --for=condition=ready --timeout=5m
- name: flux tree
run: |
/tmp/flux tree kustomization flux-system | grep Service/podinfo
- name: flux check
run: |
/tmp/flux check
@@ -205,6 +245,7 @@ jobs:
run: |
kubectl version --client --short
kubectl -n flux-system get all
kubectl -n flux-system describe pods
kubectl -n flux-system get kustomizations -oyaml
kubectl -n flux-system logs deploy/source-controller
kubectl -n flux-system logs deploy/kustomize-controller

View File

@@ -1,21 +0,0 @@
name: rebase
on:
pull_request:
types: [ opened ]
issue_comment:
types: [ created ]
jobs:
rebase:
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') && (github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.3.1
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}

View File

@@ -4,61 +4,148 @@ on:
push:
tags: [ 'v*' ]
permissions:
contents: read
jobs:
goreleaser:
release-flux-cli:
runs-on: ubuntu-latest
permissions:
contents: write # needed to write releases
id-token: write # needed for keyless signing
packages: write # needed for ghcr access
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16.x
go-version: 1.19.x
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
buildkitd-flags: "--debug"
uses: docker/setup-buildx-action@v2
- name: Setup Syft
uses: anchore/sbom-action/download-syft@v0
- name: Setup Cosign
uses: sigstore/cosign-installer@main
- name: Setup Kustomize
uses: fluxcd/pkg//actions/kustomize@main
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: fluxcdbot
password: ${{ secrets.GHCR_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: fluxcdbot
password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
- name: Generate manifests
run: |
make cmd/flux/.manifests.done
./manifests/scripts/bundle.sh "" ./output manifests.tar.gz
kustomize build ./manifests/install > ./output/install.yaml
- name: Build CRDs
run: |
kustomize build manifests/crds > all-crds.yaml
# Pinned to commit before https://github.com/fluxcd/pkg/pull/189 due to
# introduction faulty behavior.
- name: Generate OpenAPI JSON schemas from CRDs
uses: fluxcd/pkg//actions/crdjsonschema@49e26aa2ee9e734c3233c560253fd9542afe18ae
with:
crd: all-crds.yaml
output: schemas
- name: Archive the OpenAPI JSON schemas
run: |
tar -czvf ./output/crd-schemas.tar.gz -C schemas .
- name: Download release notes utility
env:
GH_REL_URL: https://github.com/buchanae/github-release-notes/releases/download/0.2.0/github-release-notes-linux-amd64-0.2.0.tar.gz
run: cd /tmp && curl -sSL ${GH_REL_URL} | tar xz && sudo mv github-release-notes /usr/local/bin/
- name: Generate release notes
run: |
echo 'CHANGELOG' > /tmp/release.txt
github-release-notes -org fluxcd -repo toolkit -since-latest-release -include-author >> /tmp/release.txt
NOTES="./output/notes.md"
echo '## CLI Changelog' > ${NOTES}
github-release-notes -org fluxcd -repo flux2 -since-latest-release -include-author >> ${NOTES}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Kustomize
uses: fluxcd/pkg//actions/kustomize@main
- name: Generate manifests
run: |
make cmd/flux/manifests
./manifests/scripts/bundle.sh "" ./output manifests.tar.gz
kustomize build ./manifests/install > ./output/install.yaml
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --release-notes=/tmp/release.txt --skip-validate
args: release --release-notes=output/notes.md --skip-validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
AUR_BOT_SSH_PRIVATE_KEY: ${{ secrets.AUR_BOT_SSH_PRIVATE_KEY }}
release-flux-manifests:
runs-on: ubuntu-latest
needs: release-flux-cli
permissions:
id-token: write
packages: write
steps:
- uses: actions/checkout@v3
- name: Setup Kustomize
uses: fluxcd/pkg/actions/kustomize@main
- name: Setup Flux CLI
uses: ./action/
- name: Prepare
id: prep
run: |
VERSION=$(flux version --client | awk '{ print $NF }')
echo ::set-output name=VERSION::${VERSION}
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: fluxcdbot
password: ${{ secrets.GHCR_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: fluxcdbot
password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
- name: Push manifests to GHCR
run: |
mkdir -p ./ghcr.io/flux-system
flux install --registry=ghcr.io/fluxcd \
--components-extra=image-reflector-controller,image-automation-controller \
--export > ./ghcr.io/flux-system/gotk-components.yaml
cd ./ghcr.io && flux push artifact \
oci://ghcr.io/fluxcd/flux-manifests:${{ steps.prep.outputs.VERSION }} \
--path="./flux-system" \
--source=${{ github.repositoryUrl }} \
--revision="${{ github.ref_name }}/${{ github.sha }}"
- name: Push manifests to DockerHub
run: |
mkdir -p ./docker.io/flux-system
flux install --registry=docker.io/fluxcd \
--components-extra=image-reflector-controller,image-automation-controller \
--export > ./docker.io/flux-system/gotk-components.yaml
cd ./docker.io && flux push artifact \
oci://docker.io/fluxcd/flux-manifests:${{ steps.prep.outputs.VERSION }} \
--path="./flux-system" \
--source=${{ github.repositoryUrl }} \
--revision="${{ github.ref_name }}/${{ github.sha }}"
- uses: sigstore/cosign-installer@main
- name: Sign manifests
env:
COSIGN_EXPERIMENTAL: 1
run: |
cosign sign ghcr.io/fluxcd/flux-manifests:${{ steps.prep.outputs.VERSION }}
cosign sign docker.io/fluxcd/flux-manifests:${{ steps.prep.outputs.VERSION }}
- name: Tag manifests
run: |
flux tag artifact oci://ghcr.io/fluxcd/flux-manifests:${{ steps.prep.outputs.VERSION }} \
--tag latest
flux tag artifact oci://docker.io/fluxcd/flux-manifests:${{ steps.prep.outputs.VERSION }} \
--tag latest

View File

@@ -1,6 +1,7 @@
name: Scan
name: scan
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
@@ -8,12 +9,15 @@ on:
schedule:
- cron: '18 10 * * 3'
permissions:
contents: read
jobs:
fossa:
name: FOSSA
scan-fossa:
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Run FOSSA scan and upload build data
uses: fossa-contrib/fossa-action@v1
with:
@@ -21,17 +25,18 @@ jobs:
fossa-api-key: 5ee8bf422db1471e0bcf2bcb289185de
github-token: ${{ github.token }}
snyk:
name: Snyk
scan-snyk:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
permissions:
security-events: write
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Kustomize
uses: fluxcd/pkg//actions/kustomize@main
- name: Build manifests
run: |
make cmd/flux/manifests
make cmd/flux/.manifests.done
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/golang@master
continue-on-error: true
@@ -40,21 +45,27 @@ jobs:
with:
args: --sarif-file-output=snyk.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v1
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: snyk.sarif
codeql:
name: CodeQL
scan-codeql:
runs-on: ubuntu-latest
permissions:
security-events: write
if: github.actor != 'dependabot[bot]'
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: go
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

View File

@@ -1,4 +1,4 @@
name: Update Components
name: update
on:
workflow_dispatch:
@@ -7,36 +7,53 @@ on:
push:
branches: [main]
permissions:
contents: read
jobs:
update-components:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16.x
go-version: 1.19.x
- name: Update component versions
id: update
run: |
PR_BODY=""
bump_version() {
local RELEASE_VERSION=$(curl -s https://api.github.com/repos/fluxcd/$1/releases | jq -r 'sort_by(.published_at) | .[-1] | .tag_name')
local CURRENT_VERSION=$(sed -n "s/.*$1\/releases\/download\/\(.*\)\/.*/\1/p;n" manifests/bases/$1/kustomization.yaml)
local LATEST_VERSION=$(curl -s https://api.github.com/repos/fluxcd/$1/releases | jq -r 'sort_by(.published_at) | .[-1] | .tag_name')
local CTRL_VERSION=$(sed -n "s/.*$1\/releases\/download\/\(.*\)\/.*/\1/p;n" manifests/bases/$1/kustomization.yaml)
local CRD_VERSION=$(sed -n "s/.*$1\/releases\/download\/\(.*\)\/.*/\1/p" manifests/crds/kustomization.yaml)
local MOD_VERSION=$(go list -m -f '{{ .Version }}' "github.com/fluxcd/$1/api")
if [[ "${RELEASE_VERSION}" != "${CURRENT_VERSION}" ]]; then
# bump kustomize
sed -i "s/\($1\/releases\/download\/\)v.*\(\/.*\)/\1${RELEASE_VERSION}\2/g" "manifests/bases/$1/kustomization.yaml"
local changed=false
if [[ ! -z $(grep "github.com/fluxcd/$1/api" go.mod | awk '{print $2}') ]]; then
# bump go mod
go mod edit -require="github.com/fluxcd/$1/api@${RELEASE_VERSION}"
fi
if [[ "${CTRL_VERSION}" != "${LATEST_VERSION}" ]]; then
sed -i "s/\($1\/releases\/download\/\)v.*\(\/.*\)/\1${LATEST_VERSION}\2/g" "manifests/bases/$1/kustomization.yaml"
changed=true
fi
# NB: special URL encoded formatting required for newlines
PR_BODY="$PR_BODY- $1 to ${RELEASE_VERSION}%0A https://github.com/fluxcd/$1/blob/${RELEASE_VERSION}/CHANGELOG.md%0A"
if [[ "${CRD_VERSION}" != "${LATEST_VERSION}" ]]; then
sed -i "s/\($1\/releases\/download\/\)v.*\(\/.*\)/\1${LATEST_VERSION}\2/g" "manifests/crds/kustomization.yaml"
changed=true
fi
if [[ "${MOD_VERSION}" != "${LATEST_VERSION}" ]]; then
go mod edit -require="github.com/fluxcd/$1/api@${LATEST_VERSION}"
make tidy
changed=true
fi
if [[ "$changed" == true ]]; then
PR_BODY="$PR_BODY- $1 to ${LATEST_VERSION}%0A https://github.com/fluxcd/$1/blob/${LATEST_VERSION}/CHANGELOG.md%0A"
fi
}
@@ -49,9 +66,6 @@ jobs:
bump_version image-reflector-controller
bump_version image-automation-controller
# add missing and remove unused modules
go mod tidy
# diff change
git diff
@@ -61,23 +75,23 @@ jobs:
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
commit-message: |
Update toolkit components
token: ${{ secrets.BOT_GITHUB_TOKEN }}
commit-message: |
Update toolkit components
${{ steps.update.outputs.pr_body }}
committer: GitHub <noreply@github.com>
author: fluxcdbot <fluxcdbot@users.noreply.github.com>
signoff: true
branch: update-components
title: Update toolkit components
body: |
${{ steps.update.outputs.pr_body }}
labels: |
area/build
reviewers: ${{ secrets.ASSIGNEES }}
${{ steps.update.outputs.pr_body }}
committer: GitHub <noreply@github.com>
author: fluxcdbot <fluxcdbot@users.noreply.github.com>
signoff: true
branch: update-components
title: Update toolkit components
body: |
${{ steps.update.outputs.pr_body }}
labels: |
area/build
reviewers: ${{ secrets.ASSIGNEES }}
- name: Check output
run: |

5
.gitignore vendored
View File

@@ -19,3 +19,8 @@ dist/
bin/
output/
cmd/flux/manifests/
cmd/flux/.manifests.done
testbin/
# Docs
site/

View File

@@ -40,6 +40,36 @@ archives:
format: zip
files:
- none*
source:
enabled: true
name_template: '{{ .ProjectName }}_{{ .Version }}_source_code'
sboms:
- id: source
artifacts: source
documents:
- "{{ .ProjectName }}_{{ .Version }}_sbom.spdx.json"
release:
extra_files:
- glob: output/crd-schemas.tar.gz
- glob: output/manifests.tar.gz
- glob: output/install.yaml
checksum:
extra_files:
- glob: output/crd-schemas.tar.gz
- glob: output/manifests.tar.gz
- glob: output/install.yaml
signs:
- cmd: cosign
env:
- COSIGN_EXPERIMENTAL=1
certificate: '${artifact}.pem'
args:
- sign-blob
- '--output-certificate=${certificate}'
- '--output-signature=${signature}'
- '${artifact}'
artifacts: checksum
output: true
brews:
- name: flux
tap:
@@ -47,11 +77,19 @@ brews:
name: homebrew-tap
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
folder: Formula
homepage: "https://toolkit.fluxcd.io/"
homepage: "https://fluxcd.io/"
description: "Flux CLI"
dependencies:
- name: kubectl
type: optional
install: |
bin.install "flux"
bash_output = Utils.safe_popen_read(bin/"flux", "completion", "bash")
(bash_completion/"flux").write bash_output
zsh_output = Utils.safe_popen_read(bin/"flux", "completion", "zsh")
(zsh_completion/"_flux").write zsh_output
fish_output = Utils.safe_popen_read(bin/"flux", "completion", "fish")
(fish_completion/"flux.fish").write fish_output
test: |
system "#{bin}/flux --version"
publishers:
@@ -70,16 +108,12 @@ publishers:
- AUR_BOT_SSH_PRIVATE_KEY={{ .Env.AUR_BOT_SSH_PRIVATE_KEY }}
cmd: |
.github/aur/flux-go/publish.sh {{ .Version }}
release:
extra_files:
- glob: ./output/manifests.tar.gz
- glob: ./output/install.yaml
dockers:
- image_templates:
- 'fluxcd/flux-cli:{{ .Tag }}-amd64'
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-amd64'
dockerfile: Dockerfile
use_buildx: true
use: buildx
goos: linux
goarch: amd64
build_flag_templates:
@@ -95,7 +129,7 @@ dockers:
- 'fluxcd/flux-cli:{{ .Tag }}-arm64'
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm64'
dockerfile: Dockerfile
use_buildx: true
use: buildx
goos: linux
goarch: arm64
build_flag_templates:
@@ -111,7 +145,7 @@ dockers:
- 'fluxcd/flux-cli:{{ .Tag }}-arm'
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm'
dockerfile: Dockerfile
use_buildx: true
use: buildx
goos: linux
goarch: arm
goarm: 7
@@ -135,3 +169,12 @@ docker_manifests:
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-amd64'
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm64'
- 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm'
docker_signs:
- cmd: cosign
env:
- COSIGN_EXPERIMENTAL=1
args:
- sign
- '${artifact}'
artifacts: all
output: true

View File

@@ -30,7 +30,7 @@ you can sign your commit automatically with `git commit -s`.
For realtime communications we use Slack: To join the conversation, simply
join the [CNCF](https://slack.cncf.io/) Slack workspace and use the
[#flux-dev](https://cloud-native.slack.com/messages/flux-dev/) channel.
[#flux-contributors](https://cloud-native.slack.com/messages/flux-contributors/) channel.
To discuss ideas and specifications we use [Github
Discussions](https://github.com/fluxcd/flux2/discussions).
@@ -59,24 +59,69 @@ This project is composed of:
### Understanding the code
To get started with developing controllers, you might want to review
[our guide](https://toolkit.fluxcd.io/dev-guides/source-watcher/) which
[our guide](https://fluxcd.io/flux/gitops-toolkit/source-watcher/) which
walks you through writing a short and concise controller that watches out
for source changes.
### How to run the test suite
## How to run the test suite
Prerequisites:
* go >= 1.16
* kubectl >= 1.18
* kustomize >= 3.1
* go >= 1.19
* kubectl >= 1.20
* kustomize >= 4.4
* coreutils (on Mac OS)
You can run the unit tests by simply doing
Install the [controller-runtime/envtest](https://github.com/kubernetes-sigs/controller-runtime/tree/master/tools/setup-envtest) binaries with:
```bash
make install-envtest
```
Then you can run the unit tests with:
```bash
make test
```
After [installing Kubernetes kind](https://kind.sigs.k8s.io/docs/user/quick-start#installation) on your machine,
create a cluster for testing with:
```bash
make setup-kind
```
Then you can run the end-to-end tests with:
```bash
make e2e
```
When the output of the Flux CLI changes, to automatically update the golden
files used in the test, pass `-update` flag to the test as:
```bash
make e2e TEST_ARGS="-update"
```
Since not all packages use golden files for testing, `-update` argument must be
passed only for the packages that use golden files. Use the variables
`TEST_PKG_PATH` for unit tests and `E2E_TEST_PKG_PATH` for e2e tests, to set the
path of the target test package:
```bash
# Unit test
make test TEST_PKG_PATH="./cmd/flux" TEST_ARGS="-update"
# e2e test
make e2e E2E_TEST_PKG_PATH="./cmd/flux" TEST_ARGS="-update"
```
Teardown the e2e environment with:
```bash
make cleanup-kind
```
## Acceptance policy
These things will make a PR more likely to be accepted:

View File

@@ -1,15 +1,15 @@
FROM alpine:3.13 as builder
FROM alpine:3.16 as builder
RUN apk add --no-cache ca-certificates curl
ARG ARCH=linux/amd64
ARG KUBECTL_VER=1.20.4
ARG KUBECTL_VER=1.25.3
RUN curl -sL https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VER}/bin/${ARCH}/kubectl \
-o /usr/local/bin/kubectl && chmod +x /usr/local/bin/kubectl && \
kubectl version --client=true
FROM alpine:3.13 as flux-cli
FROM alpine:3.16 as flux-cli
# Create minimal nsswitch.conf file to prioritize the usage of /etc/hosts over DNS queries.
# https://github.com/gliderlabs/docker-alpine/issues/367#issuecomment-354316460
@@ -20,4 +20,5 @@ RUN apk add --no-cache ca-certificates
COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/
COPY --chmod=755 flux /usr/local/bin/
USER 65534:65534
ENTRYPOINT [ "flux" ]

View File

@@ -2,17 +2,7 @@ The maintainers are generally available in Slack at
https://cloud-native.slack.com in #flux (https://cloud-native.slack.com/messages/CLAJ40HV3)
(obtain an invitation at https://slack.cncf.io/).
These maintainers are shared with other Flux v2-related git
repositories under https://github.com/fluxcd, as noted in their
respective MAINTAINERS files.
The Flux2 maintainers team is identical with the core maintainers of the project
as listed in
For convenience, they are reflected in the GitHub team
@fluxcd/flux2-maintainers -- if the list here changes, that team also
should.
In alphabetical order:
Aurel Canciu, Sortlist <aurel@sortlist.com> (github: @relu, slack: relu)
Hidde Beydals, Weaveworks <hidde@weave.works> (github: @hiddeco, slack: hidde)
Philip Laine, Xenit <philip.laine@xenit.se> (github: @phillebaba, slack: phillebaba)
Stefan Prodan, Weaveworks <stefan@weave.works> (github: @stefanprodan, slack: stefanprodan)
https://github.com/fluxcd/community/blob/main/CORE-MAINTAINERS

View File

@@ -1,12 +1,24 @@
VERSION?=$(shell grep 'VERSION' cmd/flux/main.go | awk '{ print $$4 }' | tr -d '"')
EMBEDDED_MANIFESTS_TARGET=cmd/flux/manifests
VERSION?=$(shell grep 'VERSION' cmd/flux/main.go | awk '{ print $$4 }' | head -n 1 | tr -d '"')
DEV_VERSION?=0.0.0-$(shell git rev-parse --abbrev-ref HEAD)-$(shell git rev-parse --short HEAD)-$(shell date +%s)
EMBEDDED_MANIFESTS_TARGET=cmd/flux/.manifests.done
TEST_KUBECONFIG?=/tmp/flux-e2e-test-kubeconfig
# Architecture to use envtest with
ENVTEST_ARCH ?= amd64
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
rwildcard=$(foreach d,$(wildcard $(addsuffix *,$(1))),$(call rwildcard,$(d)/,$(2)) $(filter $(subst *,%,$(2)),$(d)))
all: test build
tidy:
go mod tidy
go mod tidy -compat=1.19
cd tests/azure && go mod tidy -compat=1.19
fmt:
go fmt ./...
@@ -14,22 +26,73 @@ fmt:
vet:
go vet ./...
test: $(EMBEDDED_MANIFESTS_TARGET) tidy fmt vet docs
go test ./... -coverprofile cover.out
setup-kind:
kind create cluster --name=flux-e2e-test --kubeconfig=$(TEST_KUBECONFIG) --config=.github/kind/config.yaml
kubectl --kubeconfig=$(TEST_KUBECONFIG) apply -f https://docs.projectcalico.org/v3.16/manifests/calico.yaml
kubectl --kubeconfig=$(TEST_KUBECONFIG) -n kube-system set env daemonset/calico-node FELIX_IGNORELOOSERPF=true
cleanup-kind:
kind delete cluster --name=flux-e2e-test
rm $(TEST_KUBECONFIG)
KUBEBUILDER_ASSETS?="$(shell $(ENVTEST) --arch=$(ENVTEST_ARCH) use -i $(ENVTEST_KUBERNETES_VERSION) --bin-dir=$(ENVTEST_ASSETS_DIR) -p path)"
TEST_PKG_PATH="./..."
test: $(EMBEDDED_MANIFESTS_TARGET) tidy fmt vet install-envtest
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test $(TEST_PKG_PATH) -coverprofile cover.out --tags=unit $(TEST_ARGS)
E2E_TEST_PKG_PATH="./cmd/flux/..."
e2e: $(EMBEDDED_MANIFESTS_TARGET) tidy fmt vet
TEST_KUBECONFIG=$(TEST_KUBECONFIG) go test $(E2E_TEST_PKG_PATH) -coverprofile e2e.cover.out --tags=e2e -v -failfast $(TEST_ARGS)
test-with-kind: install-envtest
make setup-kind
make e2e
make cleanup-kind
$(EMBEDDED_MANIFESTS_TARGET): $(call rwildcard,manifests/,*.yaml *.json)
./manifests/scripts/bundle.sh
touch $@
build: $(EMBEDDED_MANIFESTS_TARGET)
CGO_ENABLED=0 go build -o ./bin/flux ./cmd/flux
CGO_ENABLED=0 go build -ldflags="-s -w -X main.VERSION=$(VERSION)" -o ./bin/flux ./cmd/flux
build-dev: $(EMBEDDED_MANIFESTS_TARGET)
CGO_ENABLED=0 go build -ldflags="-s -w -X main.VERSION=$(DEV_VERSION)" -o ./bin/flux ./cmd/flux
.PHONY: install
install:
go install cmd/flux
.PHONY: docs
docs:
rm -rf docs/cmd/*
mkdir -p ./docs/cmd && go run ./cmd/flux/ docgen
CGO_ENABLED=0 go install ./cmd/flux
install-dev:
CGO_ENABLED=0 go build -o /usr/local/bin ./cmd/flux
setup-bootstrap-patch:
go run ./tests/bootstrap/main.go
setup-image-automation:
cd tests/image-automation && go run main.go
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
ENVTEST_KUBERNETES_VERSION?=latest
install-envtest: setup-envtest
mkdir -p ${ENVTEST_ASSETS_DIR}
$(ENVTEST) use $(ENVTEST_KUBERNETES_VERSION) --arch=$(ENVTEST_ARCH) --bin-dir=$(ENVTEST_ASSETS_DIR)
ENVTEST = $(shell pwd)/bin/setup-envtest
.PHONY: envtest
setup-envtest: ## Download envtest-setup locally if necessary.
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
# go-install-tool will 'go install' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-install-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef

124
README.md
View File

@@ -1,14 +1,13 @@
# Flux version 2
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4782/badge)](https://bestpractices.coreinfrastructure.org/projects/4782)
[![e2e](https://github.com/fluxcd/flux2/workflows/e2e/badge.svg)](https://github.com/fluxcd/flux2/actions)
[![report](https://goreportcard.com/badge/github.com/fluxcd/flux2)](https://goreportcard.com/report/github.com/fluxcd/flux2)
[![license](https://img.shields.io/github/license/fluxcd/flux2.svg)](https://github.com/fluxcd/flux2/blob/main/LICENSE)
[![release](https://img.shields.io/github/release/fluxcd/flux2/all.svg)](https://github.com/fluxcd/flux2/releases)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4782/badge)](https://bestpractices.coreinfrastructure.org/projects/4782)
[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B162%2Fgithub.com%2Ffluxcd%2Fflux2.svg?type=shield)](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Ffluxcd%2Fflux2?ref=badge_shield)
[![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/flux2)](https://artifacthub.io/packages/helm/fluxcd-community/flux2)
Flux is a tool for keeping Kubernetes clusters in sync with sources of
configuration (like Git repositories), and automating updates to
configuration when there is new code to deploy.
configuration (like Git repositories and OCI artifacts),
and automating updates to configuration when there is new code to deploy.
Flux version 2 ("v2") is built from the ground up to use Kubernetes'
API extension system, and to integrate with Prometheus and other core
@@ -20,56 +19,19 @@ Flux v2 is constructed with the [GitOps Toolkit](#gitops-toolkit), a
set of composable APIs and specialized tools for building Continuous
Delivery on top of Kubernetes.
## Flux installation
Flux is a Cloud Native Computing Foundation ([CNCF](https://www.cncf.io/)) project, used in
production by various [organisations](https://fluxcd.io/adopters) and [cloud providers](https://fluxcd.io/ecosystem).
With Homebrew:
## Quickstart and documentation
```sh
brew install fluxcd/tap/flux
```
To get started check out this [guide](https://fluxcd.io/flux/get-started/)
on how to bootstrap Flux on Kubernetes and deploy a sample application in a GitOps manner.
With Bash:
```sh
curl -s https://toolkit.fluxcd.io/install.sh | sudo bash
# enable completions in ~/.bash_profile
. <(flux completion bash)
```
Arch Linux (AUR) packages:
- [flux-bin](https://aur.archlinux.org/packages/flux-bin): install the latest
stable version using a pre-build binary (recommended)
- [flux-go](https://aur.archlinux.org/packages/flux-go): build the latest
stable version from source code
- [flux-scm](https://aur.archlinux.org/packages/flux-scm): build the latest
(unstable) version from source code from our git `main` branch
Binaries for macOS, Windows and Linux AMD64/ARM are available to download on the
[release page](https://github.com/fluxcd/flux2/releases).
A container image with `kubectl` and `flux` is available on Docker Hub and GitHub:
* `docker.io/fluxcd/flux-cli:<version>`
* `ghcr.io/fluxcd/flux-cli:<version>`
Verify that your cluster satisfies the prerequisites with:
```sh
flux check --pre
```
## Get started
To get started with Flux, start [browsing the
documentation](https://toolkit.fluxcd.io) or get started with one of
the following guides:
- [Get started with Flux](https://toolkit.fluxcd.io/get-started/)
- [Manage Helm Releases](https://toolkit.fluxcd.io/guides/helmreleases/)
- [Automate image updates to Git](https://toolkit.fluxcd.io/guides/image-update/)
- [Manage Kubernetes secrets with Mozilla SOPS](https://toolkit.fluxcd.io/guides/mozilla-sops/)
For more comprehensive documentation, see the following guides:
- [Ways of structuring your repositories](https://fluxcd.io/flux/guides/repository-structure/)
- [Manage Helm Releases](https://fluxcd.io/flux/guides/helmreleases/)
- [Automate image updates to Git](https://fluxcd.io/flux/guides/image-update/)
- [Manage Kubernetes secrets with Mozilla SOPS](https://fluxcd.io/flux/guides/mozilla-sops/)
If you need help, please refer to our **[Support page](https://fluxcd.io/support/)**.
@@ -84,27 +46,28 @@ automation tooling.
You can use the toolkit to extend Flux, or to build your own systems
for continuous delivery -- see [the developer
guides](https://toolkit.fluxcd.io/dev-guides/source-watcher/).
guides](https://fluxcd.io/flux/gitops-toolkit/source-watcher/).
### Components
- [Source Controller](https://toolkit.fluxcd.io/components/source/controller/)
- [GitRepository CRD](https://toolkit.fluxcd.io/components/source/gitrepositories/)
- [HelmRepository CRD](https://toolkit.fluxcd.io/components/source/helmrepositories/)
- [HelmChart CRD](https://toolkit.fluxcd.io/components/source/helmcharts/)
- [Bucket CRD](https://toolkit.fluxcd.io/components/source/buckets/)
- [Kustomize Controller](https://toolkit.fluxcd.io/components/kustomize/controller/)
- [Kustomization CRD](https://toolkit.fluxcd.io/components/kustomize/kustomization/)
- [Helm Controller](https://toolkit.fluxcd.io/components/helm/controller/)
- [HelmRelease CRD](https://toolkit.fluxcd.io/components/helm/helmreleases/)
- [Notification Controller](https://toolkit.fluxcd.io/components/notification/controller/)
- [Provider CRD](https://toolkit.fluxcd.io/components/notification/provider/)
- [Alert CRD](https://toolkit.fluxcd.io/components/notification/alert/)
- [Receiver CRD](https://toolkit.fluxcd.io/components/notification/receiver/)
- [Image Automation Controllers](https://toolkit.fluxcd.io/components/image/controller/)
- [ImageRepository CRD](https://toolkit.fluxcd.io/components/image/imagerepositories/)
- [ImagePolicy CRD](https://toolkit.fluxcd.io/components/image/imagepolicies/)
- [ImageUpdateAutomation CRD](https://toolkit.fluxcd.io/components/image/imageupdateautomations/)
- [Source Controller](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/)
- [Kustomize Controller](https://fluxcd.io/flux/components/kustomize/)
- [Kustomization CRD](https://fluxcd.io/flux/components/kustomize/kustomization/)
- [Helm Controller](https://fluxcd.io/flux/components/helm/)
- [HelmRelease CRD](https://fluxcd.io/flux/components/helm/helmreleases/)
- [Notification Controller](https://fluxcd.io/flux/components/notification/)
- [Provider CRD](https://fluxcd.io/flux/components/notification/provider/)
- [Alert CRD](https://fluxcd.io/flux/components/notification/alert/)
- [Receiver CRD](https://fluxcd.io/flux/components/notification/receiver/)
- [Image Automation Controllers](https://fluxcd.io/flux/components/image/)
- [ImageRepository CRD](https://fluxcd.io/flux/components/image/imagerepositories/)
- [ImagePolicy CRD](https://fluxcd.io/flux/components/image/imagepolicies/)
- [ImageUpdateAutomation CRD](https://fluxcd.io/flux/components/image/imageupdateautomations/)
## Community
@@ -112,22 +75,25 @@ Need help or want to contribute? Please see the links below. The Flux project is
new contributors and there are a multitude of ways to get involved.
- Getting Started?
- Look at our [Get Started guide](https://toolkit.fluxcd.io/get-started/) and give us feedback
- Look at our [Get Started guide](https://fluxcd.io/flux/get-started/) and give us feedback
- Need help?
- First: Ask questions on our [GH Discussions page](https://github.com/fluxcd/flux2/discussions)
- Second: Talk to us in the #flux channel on [CNCF Slack](https://slack.cncf.io/)
- First: Ask questions on our [GH Discussions page](https://github.com/fluxcd/flux2/discussions).
- Second: Talk to us in the #flux channel on [CNCF Slack](https://slack.cncf.io/).
- Please follow our [Support Guidelines](https://fluxcd.io/support/)
(in short: be nice, be respectful of volunteers' time, understand that maintainers and
contributors cannot respond to all DMs, and keep discussions in the public #flux channel as much as possible).
- Have feature proposals or want to contribute?
- Propose features on our [GH Discussions page](https://github.com/fluxcd/flux2/discussions)
- Join our upcoming dev meetings ([meeting access and agenda](https://docs.google.com/document/d/1l_M0om0qUEN_NNiGgpqJ2tvsF2iioHkaARDeh6b70B0/view))
- Propose features on our [GitHub Discussions page](https://github.com/fluxcd/flux2/discussions).
- Join our upcoming dev meetings ([meeting access and agenda](https://docs.google.com/document/d/1l_M0om0qUEN_NNiGgpqJ2tvsF2iioHkaARDeh6b70B0/view)).
- [Join the flux-dev mailing list](https://lists.cncf.io/g/cncf-flux-dev).
- Check out [how to contribute](CONTRIBUTING.md) to the project
- Check out [how to contribute](CONTRIBUTING.md) to the project.
- Check out the [project roadmap](https://fluxcd.io/roadmap/).
### Events
Check out our **[events calendar](https://fluxcd.io/community/#talks)**,
both with upcoming talks you can attend or past events videos you can watch.
Check out our **[events calendar](https://fluxcd.io/#calendar)**,
both with upcoming talks, events and meetings you can attend.
Or view the **[resources section](https://fluxcd.io/resources)**
with past events videos you can watch.
We look forward to seeing you with us!

View File

@@ -10,11 +10,21 @@ Usage:
run: flux -v
```
Note that this action can only be used on GitHub **Linux AMD64** runners.
The latest stable version of the `flux` binary is downloaded from
GitHub [releases](https://github.com/fluxcd/flux2/releases)
and placed at `/usr/local/bin/flux`.
Note that this action can only be used on GitHub **Linux** runners.
You can change the arch (defaults to `amd64`) with:
```yaml
steps:
- name: Setup Flux CLI
uses: fluxcd/flux2/action@main
with:
arch: arm64 # can be amd64, arm64 or arm
```
You can download a specific version with:
```yaml
@@ -22,7 +32,7 @@ You can download a specific version with:
- name: Setup Flux CLI
uses: fluxcd/flux2/action@main
with:
version: 0.8.0
version: 0.32.0
```
### Automate Flux updates
@@ -64,6 +74,92 @@ jobs:
${{ steps.update.outputs.flux_version }}
```
### Push Kubernetes manifests to container registries
Example workflow for publishing Kubernetes manifests bundled as OCI artifacts to GitHub Container Registry:
```yaml
name: push-artifact-staging
on:
push:
branches:
- 'main'
permissions:
packages: write # needed for ghcr.io access
env:
OCI_REPO: "oci://ghcr.io/my-org/manifests/${{ github.event.repository.name }}"
jobs:
kubernetes:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Flux CLI
uses: fluxcd/flux2/action@main
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate manifests
run: |
kustomize build ./manifests/staging > ./deploy/app.yaml
- name: Push manifests
run: |
flux push artifact $OCI_REPO:$(git rev-parse --short HEAD) \
--path="./deploy" \
--source="$(git config --get remote.origin.url)" \
--revision="$(git branch --show-current)/$(git rev-parse HEAD)"
- name: Deploy manifests to staging
run: |
flux tag artifact $OCI_REPO:$(git rev-parse --short HEAD) --tag staging
```
Example workflow for publishing Kubernetes manifests bundled as OCI artifacts to Docker Hub:
```yaml
name: push-artifact-production
on:
push:
tags:
- '*'
env:
OCI_REPO: "oci://docker.io/my-org/app-config"
jobs:
kubernetes:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Flux CLI
uses: fluxcd/flux2/action@main
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Generate manifests
run: |
kustomize build ./manifests/production > ./deploy/app.yaml
- name: Push manifests
run: |
flux push artifact $OCI_REPO:$(git tag --points-at HEAD) \
--path="./deploy" \
--source="$(git config --get remote.origin.url)" \
--revision="$(git tag --points-at HEAD)/$(git rev-parse HEAD)"
- name: Deploy manifests to production
run: |
flux tag artifact $OCI_REPO:$(git tag --points-at HEAD) --tag production
```
### End-to-end testing
Example workflow for running Flux in Kubernetes Kind:

View File

@@ -8,26 +8,40 @@ inputs:
version:
description: "Flux version e.g. 0.8.0 (defaults to latest stable release)"
required: false
arch:
description: "arch can be amd64, arm64 or arm"
required: true
default: "amd64"
bindir:
description: "Optional location of the Flux binary. Will not use sudo if set. Updates System Path."
required: false
runs:
using: composite
steps:
- name: "Download flux binary to tmp"
shell: bash
run: |
ARCH=${{ inputs.arch }}
VERSION=${{ inputs.version }}
if [ -z $VERSION ]; then
VERSION=$(curl https://api.github.com/repos/fluxcd/flux2/releases/latest -sL | grep tag_name | sed -E 's/.*"([^"]+)".*/\1/' | cut -c 2-)
fi
BIN_URL="https://github.com/fluxcd/flux2/releases/download/v${VERSION}/flux_${VERSION}_linux_amd64.tar.gz"
BIN_URL="https://github.com/fluxcd/flux2/releases/download/v${VERSION}/flux_${VERSION}_linux_${ARCH}.tar.gz"
curl -sL ${BIN_URL} -o /tmp/flux.tar.gz
mkdir -p /tmp/flux
tar -C /tmp/flux/ -zxvf /tmp/flux.tar.gz
- name: "Add flux binary to /usr/local/bin"
- name: "Copy Flux binary to execute location"
shell: bash
run: |
sudo cp /tmp/flux/flux /usr/local/bin
BINDIR=${{ inputs.bindir }}
if [ -z $BINDIR ]; then
sudo cp /tmp/flux/flux /usr/local/bin
else
cp /tmp/flux/flux "${BINDIR}"
echo "${BINDIR}" >> $GITHUB_PATH
fi
- name: "Cleanup tmp"
shell: bash
run: |

View File

@@ -25,8 +25,9 @@ import (
// notificationv1.Alert
var alertType = apiType{
kind: notificationv1.AlertKind,
humanKind: "alert",
kind: notificationv1.AlertKind,
humanKind: "alert",
groupVersion: notificationv1.GroupVersion,
}
type alertAdapter struct {
@@ -37,6 +38,10 @@ func (a alertAdapter) asClientObject() client.Object {
return a.Alert
}
func (a alertAdapter) deepCopyClientObject() client.Object {
return a.Alert.DeepCopy()
}
// notificationv1.Alert
type alertListAdapter struct {

View File

@@ -25,8 +25,9 @@ import (
// notificationv1.Provider
var alertProviderType = apiType{
kind: notificationv1.ProviderKind,
humanKind: "alert provider",
kind: notificationv1.ProviderKind,
humanKind: "alert provider",
groupVersion: notificationv1.GroupVersion,
}
type alertProviderAdapter struct {
@@ -37,6 +38,10 @@ func (a alertProviderAdapter) asClientObject() client.Object {
return a.Provider
}
func (a alertProviderAdapter) deepCopyClientObject() client.Object {
return a.Provider.DeepCopy()
}
// notificationv1.Provider
type alertProviderListAdapter struct {

View File

@@ -19,12 +19,13 @@ package main
import (
"crypto/elliptic"
"fmt"
"io/ioutil"
"strings"
"github.com/spf13/cobra"
"github.com/fluxcd/flux2/internal/flags"
"github.com/fluxcd/flux2/internal/utils"
"github.com/fluxcd/flux2/pkg/manifestgen"
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
)
@@ -67,6 +68,10 @@ type bootstrapFlags struct {
authorName string
authorEmail string
gpgKeyRingPath string
gpgPassphrase string
gpgKeyID string
commitMessageAppendix string
}
@@ -83,7 +88,7 @@ func init() {
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapArgs.defaultComponents, "components", rootArgs.defaults.Components,
"list of components, accepts comma-separated values")
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapArgs.extraComponents, "components-extra", nil,
"list of components in addition to those supplied or defaulted, accepts comma-separated values")
"list of components in addition to those supplied or defaulted, accepts values such as 'image-reflector-controller,image-automation-controller'")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.registry, "registry", "ghcr.io/fluxcd",
"container registry where the toolkit images are published")
@@ -118,6 +123,10 @@ func init() {
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.authorName, "author-name", "Flux", "author name for Git commits")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.authorEmail, "author-email", "", "author email for Git commits")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.gpgKeyRingPath, "gpg-key-ring", "", "path to GPG key ring for signing commits")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.gpgPassphrase, "gpg-passphrase", "", "passphrase for decrypting GPG private key")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.gpgKeyID, "gpg-key-id", "", "key id for selecting a particular key")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.commitMessageAppendix, "commit-message-appendix", "", "string to add to the commit messages, e.g. '[ci skip]'")
bootstrapCmd.PersistentFlags().Var(&bootstrapArgs.arch, "arch", bootstrapArgs.arch.Description())
@@ -131,7 +140,7 @@ func NewBootstrapFlags() bootstrapFlags {
return bootstrapFlags{
logLevel: flags.LogLevel(rootArgs.defaults.LogLevel),
requiredComponents: []string{"source-controller", "kustomize-controller"},
keyAlgorithm: flags.PublicKeyAlgorithm(sourcesecret.RSAPrivateKeyAlgorithm),
keyAlgorithm: flags.PublicKeyAlgorithm(sourcesecret.ECDSAPrivateKeyAlgorithm),
keyRSABits: 2048,
keyECDSACurve: flags.ECDSACurve{Curve: elliptic.P384()},
}
@@ -145,7 +154,7 @@ func buildEmbeddedManifestBase() (string, error) {
if !isEmbeddedVersion(bootstrapArgs.version) {
return "", nil
}
tmpBaseDir, err := ioutil.TempDir("", "flux-manifests-")
tmpBaseDir, err := manifestgen.MkdirTempAbs("", "flux-manifests-")
if err != nil {
return "", err
}
@@ -174,6 +183,10 @@ func mapTeamSlice(s []string, defaultPermission string) map[string]string {
m := make(map[string]string, len(s))
for _, v := range s {
m[v] = defaultPermission
if s := strings.Split(v, ":"); len(s) == 2 {
m[s[0]] = s[1]
}
}
return m
}

View File

@@ -0,0 +1,281 @@
/*
Copyright 2021 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 (
"context"
"fmt"
"os"
"time"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/spf13/cobra"
"github.com/fluxcd/flux2/internal/flags"
"github.com/fluxcd/flux2/internal/utils"
"github.com/fluxcd/flux2/pkg/bootstrap"
"github.com/fluxcd/flux2/pkg/bootstrap/git/gogit"
"github.com/fluxcd/flux2/pkg/bootstrap/provider"
"github.com/fluxcd/flux2/pkg/manifestgen"
"github.com/fluxcd/flux2/pkg/manifestgen/install"
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
"github.com/fluxcd/flux2/pkg/manifestgen/sync"
)
var bootstrapBServerCmd = &cobra.Command{
Use: "bitbucket-server",
Short: "Bootstrap toolkit components in a Bitbucket Server repository",
Long: `The bootstrap bitbucket-server command creates the Bitbucket Server repository if it doesn't exists and
commits the toolkit components manifests to the master branch.
Then it configures the target cluster to synchronize with the repository.
If the toolkit components are present on the cluster,
the bootstrap command will perform an upgrade if needed.`,
Example: ` # Create a Bitbucket Server API token and export it as an env var
export BITBUCKET_TOKEN=<my-token>
# Run bootstrap for a private repository using HTTPS token authentication
flux bootstrap bitbucket-server --owner=<project> --username=<user> --repository=<repository name> --hostname=<domain> --token-auth
# Run bootstrap for a private repository using SSH authentication
flux bootstrap bitbucket-server --owner=<project> --username=<user> --repository=<repository name> --hostname=<domain>
# Run bootstrap for a repository path
flux bootstrap bitbucket-server --owner=<project> --username=<user> --repository=<repository name> --path=dev-cluster --hostname=<domain>
# Run bootstrap for a public repository on a personal account
flux bootstrap bitbucket-server --owner=<user> --repository=<repository name> --private=false --personal --hostname=<domain> --token-auth
# Run bootstrap for a an existing repository with a branch named main
flux bootstrap bitbucket-server --owner=<project> --username=<user> --repository=<repository name> --branch=main --hostname=<domain> --token-auth`,
RunE: bootstrapBServerCmdRun,
}
const (
bServerDefaultPermission = "push"
bServerTokenEnvVar = "BITBUCKET_TOKEN"
)
type bServerFlags struct {
owner string
repository string
interval time.Duration
personal bool
username string
private bool
hostname string
path flags.SafeRelativePath
teams []string
readWriteKey bool
reconcile bool
}
var bServerArgs bServerFlags
func init() {
bootstrapBServerCmd.Flags().StringVar(&bServerArgs.owner, "owner", "", "Bitbucket Server user or project name")
bootstrapBServerCmd.Flags().StringVar(&bServerArgs.repository, "repository", "", "Bitbucket Server repository name")
bootstrapBServerCmd.Flags().StringSliceVar(&bServerArgs.teams, "group", []string{}, "Bitbucket Server groups to be given write access (also accepts comma-separated values)")
bootstrapBServerCmd.Flags().BoolVar(&bServerArgs.personal, "personal", false, "if true, the owner is assumed to be a Bitbucket Server user; otherwise a group")
bootstrapBServerCmd.Flags().StringVarP(&bServerArgs.username, "username", "u", "git", "authentication username")
bootstrapBServerCmd.Flags().BoolVar(&bServerArgs.private, "private", true, "if true, the repository is setup or configured as private")
bootstrapBServerCmd.Flags().DurationVar(&bServerArgs.interval, "interval", time.Minute, "sync interval")
bootstrapBServerCmd.Flags().StringVar(&bServerArgs.hostname, "hostname", "", "Bitbucket Server hostname")
bootstrapBServerCmd.Flags().Var(&bServerArgs.path, "path", "path relative to the repository root, when specified the cluster sync will be scoped to this path")
bootstrapBServerCmd.Flags().BoolVar(&bServerArgs.readWriteKey, "read-write-key", false, "if true, the deploy key is configured with read/write permissions")
bootstrapBServerCmd.Flags().BoolVar(&bServerArgs.reconcile, "reconcile", false, "if true, the configured options are also reconciled if the repository already exists")
bootstrapCmd.AddCommand(bootstrapBServerCmd)
}
func bootstrapBServerCmdRun(cmd *cobra.Command, args []string) error {
bitbucketToken := os.Getenv(bServerTokenEnvVar)
if bitbucketToken == "" {
var err error
bitbucketToken, err = readPasswordFromStdin("Please enter your Bitbucket personal access token (PAT): ")
if err != nil {
return fmt.Errorf("could not read token: %w", err)
}
}
if bServerArgs.hostname == "" {
return fmt.Errorf("invalid hostname %q", bServerArgs.hostname)
}
if err := bootstrapValidate(); err != nil {
return err
}
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
// Manifest base
if ver, err := getVersion(bootstrapArgs.version); err == nil {
bootstrapArgs.version = ver
}
manifestsBase, err := buildEmbeddedManifestBase()
if err != nil {
return err
}
defer os.RemoveAll(manifestsBase)
user := bServerArgs.username
if bServerArgs.personal {
user = bServerArgs.owner
}
var caBundle []byte
if bootstrapArgs.caFile != "" {
var err error
caBundle, err = os.ReadFile(bootstrapArgs.caFile)
if err != nil {
return fmt.Errorf("unable to read TLS CA file: %w", err)
}
}
// Build Bitbucket Server provider
providerCfg := provider.Config{
Provider: provider.GitProviderStash,
Hostname: bServerArgs.hostname,
Username: user,
Token: bitbucketToken,
CaBundle: caBundle,
}
providerClient, err := provider.BuildGitProvider(providerCfg)
if err != nil {
return err
}
// Lazy go-git repository
tmpDir, err := manifestgen.MkdirTempAbs("", "flux-bootstrap-")
if err != nil {
return fmt.Errorf("failed to create temporary working dir: %w", err)
}
defer os.RemoveAll(tmpDir)
gitClient := gogit.New(tmpDir, &http.BasicAuth{
Username: user,
Password: bitbucketToken,
})
// Install manifest config
installOptions := install.Options{
BaseURL: rootArgs.defaults.BaseURL,
Version: bootstrapArgs.version,
Namespace: *kubeconfigArgs.Namespace,
Components: bootstrapComponents(),
Registry: bootstrapArgs.registry,
ImagePullSecret: bootstrapArgs.imagePullSecret,
WatchAllNamespaces: bootstrapArgs.watchAllNamespaces,
NetworkPolicy: bootstrapArgs.networkPolicy,
LogLevel: bootstrapArgs.logLevel.String(),
NotificationController: rootArgs.defaults.NotificationController,
ManifestFile: rootArgs.defaults.ManifestFile,
Timeout: rootArgs.timeout,
TargetPath: bServerArgs.path.ToSlash(),
ClusterDomain: bootstrapArgs.clusterDomain,
TolerationKeys: bootstrapArgs.tolerationKeys,
}
if customBaseURL := bootstrapArgs.manifestsPath; customBaseURL != "" {
installOptions.BaseURL = customBaseURL
}
// Source generation and secret config
secretOpts := sourcesecret.Options{
Name: bootstrapArgs.secretName,
Namespace: *kubeconfigArgs.Namespace,
TargetPath: bServerArgs.path.String(),
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
}
if bootstrapArgs.tokenAuth {
if bServerArgs.personal {
secretOpts.Username = bServerArgs.owner
} else {
secretOpts.Username = bServerArgs.username
}
secretOpts.Password = bitbucketToken
if bootstrapArgs.caFile != "" {
secretOpts.CAFilePath = bootstrapArgs.caFile
}
} else {
secretOpts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(bootstrapArgs.keyAlgorithm)
secretOpts.RSAKeyBits = int(bootstrapArgs.keyRSABits)
secretOpts.ECDSACurve = bootstrapArgs.keyECDSACurve.Curve
secretOpts.SSHHostname = bServerArgs.hostname
if bootstrapArgs.privateKeyFile != "" {
secretOpts.PrivateKeyPath = bootstrapArgs.privateKeyFile
}
if bootstrapArgs.sshHostname != "" {
secretOpts.SSHHostname = bootstrapArgs.sshHostname
}
}
// Sync manifest config
syncOpts := sync.Options{
Interval: bServerArgs.interval,
Name: *kubeconfigArgs.Namespace,
Namespace: *kubeconfigArgs.Namespace,
Branch: bootstrapArgs.branch,
Secret: bootstrapArgs.secretName,
TargetPath: bServerArgs.path.ToSlash(),
ManifestFile: sync.MakeDefaultOptions().ManifestFile,
GitImplementation: sourceGitArgs.gitImplementation.String(),
RecurseSubmodules: bootstrapArgs.recurseSubmodules,
}
// Bootstrap config
bootstrapOpts := []bootstrap.GitProviderOption{
bootstrap.WithProviderRepository(bServerArgs.owner, bServerArgs.repository, bServerArgs.personal),
bootstrap.WithBranch(bootstrapArgs.branch),
bootstrap.WithBootstrapTransportType("https"),
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
bootstrap.WithProviderTeamPermissions(mapTeamSlice(bServerArgs.teams, bServerDefaultPermission)),
bootstrap.WithReadWriteKeyPermissions(bServerArgs.readWriteKey),
bootstrap.WithKubeconfig(kubeconfigArgs, kubeclientOptions),
bootstrap.WithLogger(logger),
bootstrap.WithCABundle(caBundle),
bootstrap.WithGitCommitSigning(bootstrapArgs.gpgKeyRingPath, bootstrapArgs.gpgPassphrase, bootstrapArgs.gpgKeyID),
}
if bootstrapArgs.sshHostname != "" {
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSSHHostname(bootstrapArgs.sshHostname))
}
if bootstrapArgs.tokenAuth {
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSyncTransportType("https"))
}
if !bServerArgs.private {
bootstrapOpts = append(bootstrapOpts, bootstrap.WithProviderRepositoryConfig("", "", "public"))
}
if bServerArgs.reconcile {
bootstrapOpts = append(bootstrapOpts, bootstrap.WithReconcile())
}
// Setup bootstrapper with constructed configs
b, err := bootstrap.NewGitProviderBootstrapper(gitClient, providerClient, kubeClient, bootstrapOpts...)
if err != nil {
return err
}
// Run
return bootstrap.Run(ctx, b, manifestsBase, installOptions, secretOpts, syncOpts, rootArgs.pollInterval, rootArgs.timeout)
}

View File

@@ -19,7 +19,6 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"net/url"
"os"
"strings"
@@ -32,10 +31,11 @@ import (
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
"github.com/fluxcd/flux2/internal/bootstrap"
"github.com/fluxcd/flux2/internal/bootstrap/git/gogit"
"github.com/fluxcd/flux2/internal/flags"
"github.com/fluxcd/flux2/internal/utils"
"github.com/fluxcd/flux2/pkg/bootstrap"
"github.com/fluxcd/flux2/pkg/bootstrap/git/gogit"
"github.com/fluxcd/flux2/pkg/manifestgen"
"github.com/fluxcd/flux2/pkg/manifestgen/install"
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
"github.com/fluxcd/flux2/pkg/manifestgen/sync"
@@ -54,20 +54,32 @@ command will perform an upgrade if needed.`,
# Run bootstrap for a Git repository and authenticate using a password
flux bootstrap git --url=https://example.com/repository.git --password=<password>
# Run bootstrap for a Git repository and authenticate using a password from environment variable
GIT_PASSWORD=<password> && flux bootstrap git --url=https://example.com/repository.git
# Run bootstrap for a Git repository with a passwordless private key
flux bootstrap git --url=ssh://git@example.com/repository.git --private-key-file=<path/to/private.key>
# Run bootstrap for a Git repository with a private key and password
flux bootstrap git --url=ssh://git@example.com/repository.git --private-key-file=<path/to/private.key> --password=<password>
`,
RunE: bootstrapGitCmdRun,
}
type gitFlags struct {
url string
interval time.Duration
path flags.SafeRelativePath
username string
password string
url string
interval time.Duration
path flags.SafeRelativePath
username string
password string
silent bool
insecureHttpAllowed bool
}
const (
gitPasswordEnvVar = "GIT_PASSWORD"
)
var gitArgs gitFlags
func init() {
@@ -76,11 +88,26 @@ func init() {
bootstrapGitCmd.Flags().Var(&gitArgs.path, "path", "path relative to the repository root, when specified the cluster sync will be scoped to this path")
bootstrapGitCmd.Flags().StringVarP(&gitArgs.username, "username", "u", "git", "basic authentication username")
bootstrapGitCmd.Flags().StringVarP(&gitArgs.password, "password", "p", "", "basic authentication password")
bootstrapGitCmd.Flags().BoolVarP(&gitArgs.silent, "silent", "s", false, "assumes the deploy key is already setup, skips confirmation")
bootstrapGitCmd.Flags().BoolVar(&gitArgs.insecureHttpAllowed, "allow-insecure-http", false, "allows http git url connections")
bootstrapCmd.AddCommand(bootstrapGitCmd)
}
func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
gitPassword := os.Getenv(gitPasswordEnvVar)
if gitPassword != "" && gitArgs.password == "" {
gitArgs.password = gitPassword
}
if bootstrapArgs.tokenAuth && gitArgs.password == "" {
var err error
gitPassword, err = readPasswordFromStdin("Please enter your Git repository password: ")
if err != nil {
return fmt.Errorf("could not read token: %w", err)
}
gitArgs.password = gitPassword
}
if err := bootstrapValidate(); err != nil {
return err
}
@@ -97,7 +124,7 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
@@ -113,7 +140,7 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
defer os.RemoveAll(manifestsBase)
// Lazy go-git repository
tmpDir, err := ioutil.TempDir("", "flux-bootstrap-")
tmpDir, err := manifestgen.MkdirTempAbs("", "flux-bootstrap-")
if err != nil {
return fmt.Errorf("failed to create temporary working dir: %w", err)
}
@@ -124,7 +151,7 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
installOptions := install.Options{
BaseURL: rootArgs.defaults.BaseURL,
Version: bootstrapArgs.version,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Components: bootstrapComponents(),
Registry: bootstrapArgs.registry,
ImagePullSecret: bootstrapArgs.imagePullSecret,
@@ -145,7 +172,7 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
// Source generation and secret config
secretOpts := sourcesecret.Options{
Name: bootstrapArgs.secretName,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
TargetPath: gitArgs.path.String(),
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
}
@@ -157,19 +184,32 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
secretOpts.CAFilePath = bootstrapArgs.caFile
}
// Remove port of the given host when not syncing over HTTP/S to not assume port for protocol
// This _might_ be overwritten later on by e.g. --ssh-hostname
if repositoryURL.Scheme != "https" && repositoryURL.Scheme != "http" {
repositoryURL.Host = repositoryURL.Hostname()
}
// Configure repository URL to match auth config for sync.
repositoryURL.User = nil
repositoryURL.Scheme = "https"
repositoryURL.Host = repositoryURL.Hostname()
if !gitArgs.insecureHttpAllowed {
repositoryURL.Scheme = "https"
}
} else {
secretOpts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(bootstrapArgs.keyAlgorithm)
secretOpts.Password = gitArgs.password
secretOpts.RSAKeyBits = int(bootstrapArgs.keyRSABits)
secretOpts.ECDSACurve = bootstrapArgs.keyECDSACurve.Curve
// Configure repository URL to match auth config for sync.
repositoryURL.User = url.User(gitArgs.username)
// Configure repository URL to match auth config for sync
// Override existing user when user is not already set
// or when a username was passed in
if repositoryURL.User == nil || gitArgs.username != "git" {
repositoryURL.User = url.User(gitArgs.username)
}
repositoryURL.Scheme = "ssh"
repositoryURL.Host = repositoryURL.Hostname()
if bootstrapArgs.sshHostname != "" {
repositoryURL.Host = bootstrapArgs.sshHostname
}
@@ -184,26 +224,37 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
// Sync manifest config
syncOpts := sync.Options{
Interval: gitArgs.interval,
Name: rootArgs.namespace,
Namespace: rootArgs.namespace,
Name: *kubeconfigArgs.Namespace,
Namespace: *kubeconfigArgs.Namespace,
URL: repositoryURL.String(),
Branch: bootstrapArgs.branch,
Secret: bootstrapArgs.secretName,
TargetPath: gitArgs.path.String(),
TargetPath: gitArgs.path.ToSlash(),
ManifestFile: sync.MakeDefaultOptions().ManifestFile,
GitImplementation: sourceGitArgs.gitImplementation.String(),
RecurseSubmodules: bootstrapArgs.recurseSubmodules,
}
var caBundle []byte
if bootstrapArgs.caFile != "" {
var err error
caBundle, err = os.ReadFile(bootstrapArgs.caFile)
if err != nil {
return fmt.Errorf("unable to read TLS CA file: %w", err)
}
}
// Bootstrap config
bootstrapOpts := []bootstrap.GitOption{
bootstrap.WithRepositoryURL(gitArgs.url),
bootstrap.WithBranch(bootstrapArgs.branch),
bootstrap.WithAuthor(bootstrapArgs.authorName, bootstrapArgs.authorEmail),
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
bootstrap.WithKubeconfig(kubeconfigArgs, kubeclientOptions),
bootstrap.WithPostGenerateSecretFunc(promptPublicKey),
bootstrap.WithLogger(logger),
bootstrap.WithCABundle(caBundle),
bootstrap.WithGitCommitSigning(bootstrapArgs.gpgKeyRingPath, bootstrapArgs.gpgPassphrase, bootstrapArgs.gpgKeyID),
}
// Setup bootstrapper with constructed configs
@@ -222,6 +273,14 @@ func bootstrapGitCmdRun(cmd *cobra.Command, args []string) error {
// SSH-agent is attempted.
func transportForURL(u *url.URL) (transport.AuthMethod, error) {
switch u.Scheme {
case "http":
if !gitArgs.insecureHttpAllowed {
return nil, fmt.Errorf("scheme http is insecure, pass --allow-insecure-http=true to allow it")
}
return &http.BasicAuth{
Username: gitArgs.username,
Password: gitArgs.password,
}, nil
case "https":
return &http.BasicAuth{
Username: gitArgs.username,
@@ -229,7 +288,7 @@ func transportForURL(u *url.URL) (transport.AuthMethod, error) {
}, nil
case "ssh":
if bootstrapArgs.privateKeyFile != "" {
return ssh.NewPublicKeysFromFile(u.User.Username(), bootstrapArgs.privateKeyFile, "")
return ssh.NewPublicKeysFromFile(u.User.Username(), bootstrapArgs.privateKeyFile, gitArgs.password)
}
return nil, nil
default:
@@ -244,13 +303,16 @@ func promptPublicKey(ctx context.Context, secret corev1.Secret, _ sourcesecret.O
}
logger.Successf("public key: %s", strings.TrimSpace(ppk))
prompt := promptui.Prompt{
Label: "Please give the key access to your repository",
IsConfirm: true,
}
_, err := prompt.Run()
if err != nil {
return fmt.Errorf("aborting")
if !gitArgs.silent {
prompt := promptui.Prompt{
Label: "Please give the key access to your repository",
IsConfirm: true,
}
_, err := prompt.Run()
if err != nil {
return fmt.Errorf("aborting")
}
}
return nil
}

View File

@@ -19,18 +19,18 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"os"
"time"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/spf13/cobra"
"github.com/fluxcd/flux2/internal/bootstrap"
"github.com/fluxcd/flux2/internal/bootstrap/git/gogit"
"github.com/fluxcd/flux2/internal/bootstrap/provider"
"github.com/fluxcd/flux2/internal/flags"
"github.com/fluxcd/flux2/internal/utils"
"github.com/fluxcd/flux2/pkg/bootstrap"
"github.com/fluxcd/flux2/pkg/bootstrap/git/gogit"
"github.com/fluxcd/flux2/pkg/bootstrap/provider"
"github.com/fluxcd/flux2/pkg/manifestgen"
"github.com/fluxcd/flux2/pkg/manifestgen/install"
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
"github.com/fluxcd/flux2/pkg/manifestgen/sync"
@@ -53,6 +53,9 @@ the bootstrap command will perform an upgrade if needed.`,
# Run bootstrap for a private repository and assign organization teams to it
flux bootstrap github --owner=<organization> --repository=<repository name> --team=<team1 slug> --team=<team2 slug>
# Run bootstrap for a private repository and assign organization teams with their access level(e.g maintain, admin) to it
flux bootstrap github --owner=<organization> --repository=<repository name> --team=<team1 slug>:<access-level>
# Run bootstrap for a repository path
flux bootstrap github --owner=<organization> --repository=<repository name> --path=dev-cluster
@@ -80,6 +83,7 @@ type githubFlags struct {
path flags.SafeRelativePath
teams []string
readWriteKey bool
reconcile bool
}
const (
@@ -93,13 +97,14 @@ var githubArgs githubFlags
func init() {
bootstrapGitHubCmd.Flags().StringVar(&githubArgs.owner, "owner", "", "GitHub user or organization name")
bootstrapGitHubCmd.Flags().StringVar(&githubArgs.repository, "repository", "", "GitHub repository name")
bootstrapGitHubCmd.Flags().StringArrayVar(&githubArgs.teams, "team", []string{}, "GitHub team to be given maintainer access")
bootstrapGitHubCmd.Flags().StringSliceVar(&githubArgs.teams, "team", []string{}, "GitHub team and the access to be given to it(team:maintain). Defaults to maintainer access if no access level is specified (also accepts comma-separated values)")
bootstrapGitHubCmd.Flags().BoolVar(&githubArgs.personal, "personal", false, "if true, the owner is assumed to be a GitHub user; otherwise an org")
bootstrapGitHubCmd.Flags().BoolVar(&githubArgs.private, "private", true, "if true, the repository is assumed to be private")
bootstrapGitHubCmd.Flags().BoolVar(&githubArgs.private, "private", true, "if true, the repository is setup or configured as private")
bootstrapGitHubCmd.Flags().DurationVar(&githubArgs.interval, "interval", time.Minute, "sync interval")
bootstrapGitHubCmd.Flags().StringVar(&githubArgs.hostname, "hostname", ghDefaultDomain, "GitHub hostname")
bootstrapGitHubCmd.Flags().Var(&githubArgs.path, "path", "path relative to the repository root, when specified the cluster sync will be scoped to this path")
bootstrapGitHubCmd.Flags().BoolVar(&githubArgs.readWriteKey, "read-write-key", false, "if true, the deploy key is configured with read/write permissions")
bootstrapGitHubCmd.Flags().BoolVar(&githubArgs.reconcile, "reconcile", false, "if true, the configured options are also reconciled if the repository already exists")
bootstrapCmd.AddCommand(bootstrapGitHubCmd)
}
@@ -107,7 +112,11 @@ func init() {
func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
ghToken := os.Getenv(ghTokenEnvVar)
if ghToken == "" {
return fmt.Errorf("%s environment variable not found", ghTokenEnvVar)
var err error
ghToken, err = readPasswordFromStdin("Please enter your GitHub personal access token (PAT): ")
if err != nil {
return fmt.Errorf("could not read token: %w", err)
}
}
if err := bootstrapValidate(); err != nil {
@@ -117,7 +126,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
@@ -132,11 +141,20 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
}
defer os.RemoveAll(manifestsBase)
var caBundle []byte
if bootstrapArgs.caFile != "" {
var err error
caBundle, err = os.ReadFile(bootstrapArgs.caFile)
if err != nil {
return fmt.Errorf("unable to read TLS CA file: %w", err)
}
}
// Build GitHub provider
providerCfg := provider.Config{
Provider: provider.GitProviderGitHub,
Hostname: githubArgs.hostname,
Token: ghToken,
CaBundle: caBundle,
}
providerClient, err := provider.BuildGitProvider(providerCfg)
if err != nil {
@@ -144,7 +162,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
}
// Lazy go-git repository
tmpDir, err := ioutil.TempDir("", "flux-bootstrap-")
tmpDir, err := manifestgen.MkdirTempAbs("", "flux-bootstrap-")
if err != nil {
return fmt.Errorf("failed to create temporary working dir: %w", err)
}
@@ -158,7 +176,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
installOptions := install.Options{
BaseURL: rootArgs.defaults.BaseURL,
Version: bootstrapArgs.version,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Components: bootstrapComponents(),
Registry: bootstrapArgs.registry,
ImagePullSecret: bootstrapArgs.imagePullSecret,
@@ -179,7 +197,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
// Source generation and secret config
secretOpts := sourcesecret.Options{
Name: bootstrapArgs.secretName,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
TargetPath: githubArgs.path.ToSlash(),
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
}
@@ -204,8 +222,8 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
// Sync manifest config
syncOpts := sync.Options{
Interval: githubArgs.interval,
Name: rootArgs.namespace,
Namespace: rootArgs.namespace,
Name: *kubeconfigArgs.Namespace,
Namespace: *kubeconfigArgs.Namespace,
Branch: bootstrapArgs.branch,
Secret: bootstrapArgs.secretName,
TargetPath: githubArgs.path.ToSlash(),
@@ -223,8 +241,10 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
bootstrap.WithProviderTeamPermissions(mapTeamSlice(githubArgs.teams, ghDefaultPermission)),
bootstrap.WithReadWriteKeyPermissions(githubArgs.readWriteKey),
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
bootstrap.WithKubeconfig(kubeconfigArgs, kubeclientOptions),
bootstrap.WithLogger(logger),
bootstrap.WithCABundle(caBundle),
bootstrap.WithGitCommitSigning(bootstrapArgs.gpgKeyRingPath, bootstrapArgs.gpgPassphrase, bootstrapArgs.gpgKeyID),
}
if bootstrapArgs.sshHostname != "" {
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSSHHostname(bootstrapArgs.sshHostname))
@@ -235,6 +255,9 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
if !githubArgs.private {
bootstrapOpts = append(bootstrapOpts, bootstrap.WithProviderRepositoryConfig("", "", "public"))
}
if githubArgs.reconcile {
bootstrapOpts = append(bootstrapOpts, bootstrap.WithReconcile())
}
// Setup bootstrapper with constructed configs
b, err := bootstrap.NewGitProviderBootstrapper(gitClient, providerClient, kubeClient, bootstrapOpts...)

View File

@@ -19,7 +19,6 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"os"
"regexp"
"strings"
@@ -28,11 +27,12 @@ import (
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/spf13/cobra"
"github.com/fluxcd/flux2/internal/bootstrap"
"github.com/fluxcd/flux2/internal/bootstrap/git/gogit"
"github.com/fluxcd/flux2/internal/bootstrap/provider"
"github.com/fluxcd/flux2/internal/flags"
"github.com/fluxcd/flux2/internal/utils"
"github.com/fluxcd/flux2/pkg/bootstrap"
"github.com/fluxcd/flux2/pkg/bootstrap/git/gogit"
"github.com/fluxcd/flux2/pkg/bootstrap/provider"
"github.com/fluxcd/flux2/pkg/manifestgen"
"github.com/fluxcd/flux2/pkg/manifestgen/install"
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
"github.com/fluxcd/flux2/pkg/manifestgen/sync"
@@ -86,6 +86,7 @@ type gitlabFlags struct {
path flags.SafeRelativePath
teams []string
readWriteKey bool
reconcile bool
}
var gitlabArgs gitlabFlags
@@ -93,13 +94,14 @@ var gitlabArgs gitlabFlags
func init() {
bootstrapGitLabCmd.Flags().StringVar(&gitlabArgs.owner, "owner", "", "GitLab user or group name")
bootstrapGitLabCmd.Flags().StringVar(&gitlabArgs.repository, "repository", "", "GitLab repository name")
bootstrapGitLabCmd.Flags().StringArrayVar(&gitlabArgs.teams, "team", []string{}, "GitLab teams to be given maintainer access")
bootstrapGitLabCmd.Flags().StringSliceVar(&gitlabArgs.teams, "team", []string{}, "GitLab teams to be given maintainer access (also accepts comma-separated values)")
bootstrapGitLabCmd.Flags().BoolVar(&gitlabArgs.personal, "personal", false, "if true, the owner is assumed to be a GitLab user; otherwise a group")
bootstrapGitLabCmd.Flags().BoolVar(&gitlabArgs.private, "private", true, "if true, the repository is assumed to be private")
bootstrapGitLabCmd.Flags().BoolVar(&gitlabArgs.private, "private", true, "if true, the repository is setup or configured as private")
bootstrapGitLabCmd.Flags().DurationVar(&gitlabArgs.interval, "interval", time.Minute, "sync interval")
bootstrapGitLabCmd.Flags().StringVar(&gitlabArgs.hostname, "hostname", glDefaultDomain, "GitLab hostname")
bootstrapGitLabCmd.Flags().Var(&gitlabArgs.path, "path", "path relative to the repository root, when specified the cluster sync will be scoped to this path")
bootstrapGitLabCmd.Flags().BoolVar(&gitlabArgs.readWriteKey, "read-write-key", false, "if true, the deploy key is configured with read/write permissions")
bootstrapGitLabCmd.Flags().BoolVar(&gitlabArgs.reconcile, "reconcile", false, "if true, the configured options are also reconciled if the repository already exists")
bootstrapCmd.AddCommand(bootstrapGitLabCmd)
}
@@ -107,7 +109,11 @@ func init() {
func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
glToken := os.Getenv(glTokenEnvVar)
if glToken == "" {
return fmt.Errorf("%s environment variable not found", glTokenEnvVar)
var err error
glToken, err = readPasswordFromStdin("Please enter your GitLab personal access token (PAT): ")
if err != nil {
return fmt.Errorf("could not read token: %w", err)
}
}
if projectNameIsValid, err := regexp.MatchString(gitlabProjectRegex, gitlabArgs.repository); err != nil || !projectNameIsValid {
@@ -124,7 +130,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
@@ -139,11 +145,21 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
}
defer os.RemoveAll(manifestsBase)
var caBundle []byte
if bootstrapArgs.caFile != "" {
var err error
caBundle, err = os.ReadFile(bootstrapArgs.caFile)
if err != nil {
return fmt.Errorf("unable to read TLS CA file: %w", err)
}
}
// Build GitLab provider
providerCfg := provider.Config{
Provider: provider.GitProviderGitLab,
Hostname: gitlabArgs.hostname,
Token: glToken,
CaBundle: caBundle,
}
// Workaround for: https://github.com/fluxcd/go-git-providers/issues/55
if hostname := providerCfg.Hostname; hostname != glDefaultDomain &&
@@ -157,7 +173,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
}
// Lazy go-git repository
tmpDir, err := ioutil.TempDir("", "flux-bootstrap-")
tmpDir, err := manifestgen.MkdirTempAbs("", "flux-bootstrap-")
if err != nil {
return fmt.Errorf("failed to create temporary working dir: %w", err)
}
@@ -171,7 +187,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
installOptions := install.Options{
BaseURL: rootArgs.defaults.BaseURL,
Version: bootstrapArgs.version,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Components: bootstrapComponents(),
Registry: bootstrapArgs.registry,
ImagePullSecret: bootstrapArgs.imagePullSecret,
@@ -192,7 +208,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
// Source generation and secret config
secretOpts := sourcesecret.Options{
Name: bootstrapArgs.secretName,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
TargetPath: gitlabArgs.path.String(),
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
}
@@ -220,8 +236,8 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
// Sync manifest config
syncOpts := sync.Options{
Interval: gitlabArgs.interval,
Name: rootArgs.namespace,
Namespace: rootArgs.namespace,
Name: *kubeconfigArgs.Namespace,
Namespace: *kubeconfigArgs.Namespace,
Branch: bootstrapArgs.branch,
Secret: bootstrapArgs.secretName,
TargetPath: gitlabArgs.path.ToSlash(),
@@ -239,8 +255,10 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
bootstrap.WithCommitMessageAppendix(bootstrapArgs.commitMessageAppendix),
bootstrap.WithProviderTeamPermissions(mapTeamSlice(gitlabArgs.teams, glDefaultPermission)),
bootstrap.WithReadWriteKeyPermissions(gitlabArgs.readWriteKey),
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
bootstrap.WithKubeconfig(kubeconfigArgs, kubeclientOptions),
bootstrap.WithLogger(logger),
bootstrap.WithCABundle(caBundle),
bootstrap.WithGitCommitSigning(bootstrapArgs.gpgKeyRingPath, bootstrapArgs.gpgPassphrase, bootstrapArgs.gpgKeyID),
}
if bootstrapArgs.sshHostname != "" {
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSSHHostname(bootstrapArgs.sshHostname))
@@ -251,6 +269,9 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
if !gitlabArgs.private {
bootstrapOpts = append(bootstrapOpts, bootstrap.WithProviderRepositoryConfig("", "", "public"))
}
if gitlabArgs.reconcile {
bootstrapOpts = append(bootstrapOpts, bootstrap.WithReconcile())
}
// Setup bootstrapper with constructed configs
b, err := bootstrap.NewGitProviderBootstrapper(gitClient, providerClient, kubeClient, bootstrapOpts...)

31
cmd/flux/build.go Normal file
View File

@@ -0,0 +1,31 @@
/*
Copyright 2021 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"
)
var buildCmd = &cobra.Command{
Use: "build",
Short: "Build a flux resource",
Long: "The build command is used to build flux resources.",
}
func init() {
rootCmd.AddCommand(buildCmd)
}

View File

@@ -0,0 +1,83 @@
/*
Copyright 2022 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"
"os"
"strings"
"github.com/spf13/cobra"
oci "github.com/fluxcd/pkg/oci/client"
"github.com/fluxcd/pkg/sourceignore"
)
var buildArtifactCmd = &cobra.Command{
Use: "artifact",
Short: "Build artifact",
Long: `The build artifact command creates a tgz file with the manifests from the given directory or a single manifest file.`,
Example: ` # Build the given manifests directory into an artifact
flux build artifact --path ./path/to/local/manifests --output ./path/to/artifact.tgz
# Build the given single manifest file into an artifact
flux build artifact --path ./path/to/local/manifest.yaml --output ./path/to/artifact.tgz
# List the files bundled in the artifact
tar -ztvf ./path/to/artifact.tgz
`,
RunE: buildArtifactCmdRun,
}
type buildArtifactFlags struct {
output string
path string
ignorePaths []string
}
var excludeOCI = append(strings.Split(sourceignore.ExcludeVCS, ","), strings.Split(sourceignore.ExcludeExt, ",")...)
var buildArtifactArgs buildArtifactFlags
func init() {
buildArtifactCmd.Flags().StringVar(&buildArtifactArgs.path, "path", "", "Path to the directory where the Kubernetes manifests are located.")
buildArtifactCmd.Flags().StringVarP(&buildArtifactArgs.output, "output", "o", "artifact.tgz", "Path to where the artifact tgz file should be written.")
buildArtifactCmd.Flags().StringSliceVar(&buildArtifactArgs.ignorePaths, "ignore-paths", excludeOCI, "set paths to ignore in .gitignore format")
buildCmd.AddCommand(buildArtifactCmd)
}
func buildArtifactCmdRun(cmd *cobra.Command, args []string) error {
if buildArtifactArgs.path == "" {
return fmt.Errorf("invalid path %q", buildArtifactArgs.path)
}
if _, err := os.Stat(buildArtifactArgs.path); err != nil {
return fmt.Errorf("invalid path '%s', must point to an existing directory or file", buildArtifactArgs.path)
}
logger.Actionf("building artifact from %s", buildArtifactArgs.path)
ociClient := oci.NewLocalClient()
if err := ociClient.Build(buildArtifactArgs.output, buildArtifactArgs.path, buildArtifactArgs.ignorePaths); err != nil {
return fmt.Errorf("bulding artifact failed, error: %w", err)
}
logger.Successf("artifact created at %s", buildArtifactArgs.output)
return nil
}

View File

@@ -0,0 +1,113 @@
/*
Copyright 2021 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"
"os"
"os/signal"
"github.com/spf13/cobra"
"github.com/fluxcd/flux2/internal/build"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
)
var buildKsCmd = &cobra.Command{
Use: "kustomization",
Aliases: []string{"ks"},
Short: "Build Kustomization",
Long: `The build command queries the Kubernetes API and fetches the specified Flux Kustomization.
It then uses the fetched in cluster flux kustomization to perform needed transformation on the local kustomization.yaml
pointed at by --path. The local kustomization.yaml is generated if it does not exist. Finally it builds the overlays using the local kustomization.yaml, and write the resulting multi-doc YAML to stdout.
It is possible to specify a Flux kustomization file using --kustomization-file.`,
Example: `# Build the local manifests as they were built on the cluster
flux build kustomization my-app --path ./path/to/local/manifests
# Build using a local flux kustomization file
flux build kustomization my-app --path ./path/to/local/manifests --kustomization-file ./path/to/local/my-app.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
RunE: buildKsCmdRun,
}
type buildKsFlags struct {
kustomizationFile string
path string
}
var buildKsArgs buildKsFlags
func init() {
buildKsCmd.Flags().StringVar(&buildKsArgs.path, "path", "", "Path to the manifests location.")
buildKsCmd.Flags().StringVar(&buildKsArgs.kustomizationFile, "kustomization-file", "", "Path to the Flux Kustomization YAML file.")
buildCmd.AddCommand(buildKsCmd)
}
func buildKsCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("%s name is required", kustomizationType.humanKind)
}
name := args[0]
if buildKsArgs.path == "" {
return fmt.Errorf("invalid resource path %q", buildKsArgs.path)
}
if fs, err := os.Stat(buildKsArgs.path); err != nil || !fs.IsDir() {
return fmt.Errorf("invalid resource path %q", buildKsArgs.path)
}
if buildKsArgs.kustomizationFile != "" {
if fs, err := os.Stat(buildKsArgs.kustomizationFile); os.IsNotExist(err) || fs.IsDir() {
return fmt.Errorf("invalid kustomization file %q", buildKsArgs.kustomizationFile)
}
}
builder, err := build.NewBuilder(kubeconfigArgs, kubeclientOptions, name, buildKsArgs.path, build.WithTimeout(rootArgs.timeout), build.WithKustomizationFile(buildKsArgs.kustomizationFile))
if err != nil {
return err
}
// create a signal channel
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, os.Interrupt)
errChan := make(chan error)
go func() {
manifests, err := builder.Build()
if err != nil {
errChan <- err
}
cmd.Print(string(manifests))
errChan <- nil
}()
select {
case <-sigc:
fmt.Println("Build cancelled... exiting.")
return builder.Cancel()
case err := <-errChan:
if err != nil {
return err
}
}
return nil
}

View File

@@ -0,0 +1,190 @@
//go:build unit
// +build unit
/*
Copyright 2021 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 (
"bytes"
"os"
"testing"
"text/template"
)
func setup(t *testing.T, tmpl map[string]string) {
t.Helper()
testEnv.CreateObjectFile("./testdata/build-kustomization/podinfo-source.yaml", tmpl, t)
testEnv.CreateObjectFile("./testdata/build-kustomization/podinfo-kustomization.yaml", tmpl, t)
}
func TestBuildKustomization(t *testing.T) {
tests := []struct {
name string
args string
resultFile string
assertFunc string
}{
{
name: "no args",
args: "build kustomization podinfo",
resultFile: "invalid resource path \"\"",
assertFunc: "assertError",
},
{
name: "build podinfo",
args: "build kustomization podinfo --path ./testdata/build-kustomization/podinfo",
resultFile: "./testdata/build-kustomization/podinfo-result.yaml",
assertFunc: "assertGoldenTemplateFile",
},
{
name: "build podinfo without service",
args: "build kustomization podinfo --path ./testdata/build-kustomization/delete-service",
resultFile: "./testdata/build-kustomization/podinfo-without-service-result.yaml",
assertFunc: "assertGoldenTemplateFile",
},
{
name: "build deployment and configmap with var substitution",
args: "build kustomization podinfo --path ./testdata/build-kustomization/var-substitution",
resultFile: "./testdata/build-kustomization/podinfo-with-var-substitution-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)
})
}
}
func TestBuildLocalKustomization(t *testing.T) {
podinfo := `apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
name: podinfo
namespace: {{ .fluxns }}
spec:
interval: 5m0s
path: ./kustomize
force: true
prune: true
sourceRef:
kind: GitRepository
name: podinfo
targetNamespace: default
postBuild:
substitute:
cluster_env: "prod"
cluster_region: "eu-central-1"
`
tests := []struct {
name string
args string
resultFile string
assertFunc string
}{
{
name: "no args",
args: "build kustomization podinfo --kustomization-file ./wrongfile/ --path ./testdata/build-kustomization/podinfo",
resultFile: "invalid kustomization file \"./wrongfile/\"",
assertFunc: "assertError",
},
{
name: "build podinfo",
args: "build kustomization podinfo --kustomization-file ./testdata/build-kustomization/podinfo.yaml --path ./testdata/build-kustomization/podinfo",
resultFile: "./testdata/build-kustomization/podinfo-result.yaml",
assertFunc: "assertGoldenTemplateFile",
},
{
name: "build podinfo without service",
args: "build kustomization podinfo --kustomization-file ./testdata/build-kustomization/podinfo.yaml --path ./testdata/build-kustomization/delete-service",
resultFile: "./testdata/build-kustomization/podinfo-without-service-result.yaml",
assertFunc: "assertGoldenTemplateFile",
},
{
name: "build deployment and configmap with var substitution",
args: "build kustomization podinfo --kustomization-file ./testdata/build-kustomization/podinfo.yaml --path ./testdata/build-kustomization/var-substitution",
resultFile: "./testdata/build-kustomization/podinfo-with-var-substitution-result.yaml",
assertFunc: "assertGoldenTemplateFile",
},
}
tmpl := map[string]string{
"fluxns": allocateNamespace("flux-system"),
}
testEnv.CreateObjectFile("./testdata/build-kustomization/podinfo-source.yaml", tmpl, t)
temp, err := template.New("podinfo").Parse(podinfo)
if err != nil {
t.Fatal(err)
}
var b bytes.Buffer
err = temp.Execute(&b, tmpl)
if err != nil {
t.Fatal(err)
}
err = os.WriteFile("./testdata/build-kustomization/podinfo.yaml", b.Bytes(), 0666)
if err != nil {
t.Fatal(err)
}
defer os.Remove("./testdata/build-kustomization/podinfo.yaml")
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)
})
}
}

View File

@@ -18,21 +18,20 @@ package main
import (
"context"
"encoding/json"
"os"
"os/exec"
"time"
"github.com/Masterminds/semver/v3"
"github.com/spf13/cobra"
v1 "k8s.io/api/apps/v1"
apimachineryversion "k8s.io/apimachinery/pkg/version"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/client-go/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/fluxcd/pkg/version"
"github.com/fluxcd/flux2/internal/utils"
"github.com/fluxcd/flux2/pkg/manifestgen"
"github.com/fluxcd/flux2/pkg/manifestgen/install"
"github.com/fluxcd/flux2/pkg/status"
)
@@ -54,10 +53,11 @@ type checkFlags struct {
pre bool
components []string
extraComponents []string
pollInterval time.Duration
}
type kubectlVersion struct {
ClientVersion *apimachineryversion.Info `json:"clientVersion"`
var kubernetesConstraints = []string{
">=1.20.6-0",
}
var checkArgs checkFlags
@@ -69,23 +69,18 @@ func init() {
"list of components, accepts comma-separated values")
checkCmd.Flags().StringSliceVar(&checkArgs.extraComponents, "components-extra", nil,
"list of components in addition to those supplied or defaulted, accepts comma-separated values")
checkCmd.Flags().DurationVar(&checkArgs.pollInterval, "poll-interval", 5*time.Second,
"how often the health checker should poll the cluster for the latest state of the resources.")
rootCmd.AddCommand(checkCmd)
}
func runCheckCmd(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
logger.Actionf("checking prerequisites")
checkFailed := false
fluxCheck()
if !kubectlCheck(ctx, ">=1.18.0-0") {
checkFailed = true
}
if !kubernetesCheck(">=1.16.0-0") {
if !kubernetesCheck(kubernetesConstraints) {
checkFailed = true
}
@@ -101,9 +96,17 @@ func runCheckCmd(cmd *cobra.Command, args []string) error {
if !componentsCheck() {
checkFailed = true
}
logger.Actionf("checking crds")
if !crdsCheck() {
checkFailed = true
}
if checkFailed {
logger.Failuref("check failed")
os.Exit(1)
}
logger.Successf("all checks passed")
return nil
}
@@ -130,44 +133,8 @@ func fluxCheck() {
}
}
func kubectlCheck(ctx context.Context, constraint string) bool {
_, err := exec.LookPath("kubectl")
if err != nil {
logger.Failuref("kubectl not found")
return false
}
kubectlArgs := []string{"version", "--client", "--output", "json"}
output, err := utils.ExecKubectlCommand(ctx, utils.ModeCapture, rootArgs.kubeconfig, rootArgs.kubecontext, kubectlArgs...)
if err != nil {
logger.Failuref("kubectl version can't be determined")
return false
}
kv := &kubectlVersion{}
if err = json.Unmarshal([]byte(output), kv); err != nil {
logger.Failuref("kubectl version output can't be unmarshalled")
return false
}
v, err := version.ParseVersion(kv.ClientVersion.GitVersion)
if err != nil {
logger.Failuref("kubectl version can't be parsed")
return false
}
c, _ := semver.NewConstraint(constraint)
if !c.Check(v) {
logger.Failuref("kubectl version %s < %s", v.Original(), constraint)
return false
}
logger.Successf("kubectl %s %s", v.String(), constraint)
return true
}
func kubernetesCheck(constraint string) bool {
cfg, err := utils.KubeConfig(rootArgs.kubeconfig, rootArgs.kubecontext)
func kubernetesCheck(constraints []string) bool {
cfg, err := utils.KubeConfig(kubeconfigArgs, kubeclientOptions)
if err != nil {
logger.Failuref("Kubernetes client initialization failed: %s", err.Error())
return false
@@ -191,13 +158,23 @@ func kubernetesCheck(constraint string) bool {
return false
}
c, _ := semver.NewConstraint(constraint)
if !c.Check(v) {
logger.Failuref("Kubernetes version %s < %s", v.Original(), constraint)
var valid bool
var vrange string
for _, constraint := range constraints {
c, _ := semver.NewConstraint(constraint)
if c.Check(v) {
valid = true
vrange = constraint
break
}
}
if !valid {
logger.Failuref("Kubernetes version %s does not match %s", v.Original(), constraints[0])
return false
}
logger.Successf("Kubernetes %s %s", v.String(), constraint)
logger.Successf("Kubernetes %s %s", v.String(), vrange)
return true
}
@@ -205,25 +182,32 @@ func componentsCheck() bool {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeConfig, err := utils.KubeConfig(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeConfig, err := utils.KubeConfig(kubeconfigArgs, kubeclientOptions)
if err != nil {
return false
}
statusChecker, err := status.NewStatusChecker(kubeConfig, time.Second, rootArgs.timeout, logger)
statusChecker, err := status.NewStatusChecker(kubeConfig, checkArgs.pollInterval, rootArgs.timeout, logger)
if err != nil {
return false
}
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return false
}
ok := true
selector := client.MatchingLabels{"app.kubernetes.io/instance": rootArgs.namespace}
selector := client.MatchingLabels{manifestgen.PartOfLabelKey: manifestgen.PartOfLabelValue}
var list v1.DeploymentList
if err := kubeClient.List(ctx, &list, client.InNamespace(rootArgs.namespace), selector); err == nil {
ns := *kubeconfigArgs.Namespace
if err := kubeClient.List(ctx, &list, client.InNamespace(ns), selector); err == nil {
if len(list.Items) == 0 {
logger.Failuref("no controllers found in the '%s' namespace with the label selector '%s=%s'",
ns, manifestgen.PartOfLabelKey, manifestgen.PartOfLabelValue)
return false
}
for _, d := range list.Items {
if ref, err := buildComponentObjectRefs(d.Name); err == nil {
if err := statusChecker.Assess(ref...); err != nil {
@@ -237,3 +221,34 @@ func componentsCheck() bool {
}
return ok
}
func crdsCheck() bool {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return false
}
ok := true
selector := client.MatchingLabels{manifestgen.PartOfLabelKey: manifestgen.PartOfLabelValue}
var list apiextensionsv1.CustomResourceDefinitionList
if err := kubeClient.List(ctx, &list, client.InNamespace(*kubeconfigArgs.Namespace), selector); err == nil {
if len(list.Items) == 0 {
logger.Failuref("no crds found with the label selector '%s=%s'",
manifestgen.PartOfLabelKey, manifestgen.PartOfLabelValue)
return false
}
for _, crd := range list.Items {
if len(crd.Status.StoredVersions) > 0 {
logger.Successf(crd.Name + "/" + crd.Status.StoredVersions[0])
} else {
ok = false
logger.Failuref("no stored versions for %s", crd.Name)
}
}
}
return ok
}

53
cmd/flux/check_test.go Normal file
View File

@@ -0,0 +1,53 @@
//go:build e2e
// +build e2e
/*
Copyright 2021 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 (
"context"
"encoding/json"
"strings"
"testing"
"github.com/fluxcd/flux2/internal/utils"
)
func TestCheckPre(t *testing.T) {
jsonOutput, err := utils.ExecKubectlCommand(context.TODO(), utils.ModeCapture, *kubeconfigArgs.KubeConfig, *kubeconfigArgs.Context, "version", "--output", "json")
if err != nil {
t.Fatalf("Error running utils.ExecKubectlCommand: %v", err.Error())
}
var versions map[string]interface{}
if err := json.Unmarshal([]byte(jsonOutput), &versions); err != nil {
t.Fatalf("Error unmarshalling '%s': %v", jsonOutput, err.Error())
}
serverGitVersion := strings.TrimPrefix(
versions["serverVersion"].(map[string]interface{})["gitVersion"].(string),
"v")
cmd := cmdTestCase{
args: "check --pre",
assert: assertGoldenTemplateFile("testdata/check/check_pre.golden", map[string]string{
"serverVersion": serverGitVersion,
}),
}
cmd.runTestCmd(t)
}

View File

@@ -17,7 +17,15 @@ limitations under the License.
package main
import (
"context"
"strings"
"github.com/fluxcd/flux2/internal/utils"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
)
var completionCmd = &cobra.Command{
@@ -29,3 +37,76 @@ var completionCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(completionCmd)
}
func contextsCompletionFunc(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
rawConfig, err := kubeconfigArgs.ToRawKubeConfigLoader().RawConfig()
if err != nil {
return completionError(err)
}
var comps []string
for name := range rawConfig.Contexts {
if strings.HasPrefix(name, toComplete) {
comps = append(comps, name)
}
}
return comps, cobra.ShellCompDirectiveNoFileComp
}
func resourceNamesCompletionFunc(gvk schema.GroupVersionKind) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
cfg, err := utils.KubeConfig(kubeconfigArgs, kubeclientOptions)
if err != nil {
return completionError(err)
}
mapper, err := kubeconfigArgs.ToRESTMapper()
if err != nil {
return completionError(err)
}
mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version)
if err != nil {
return completionError(err)
}
client, err := dynamic.NewForConfig(cfg)
if err != nil {
return completionError(err)
}
var dr dynamic.ResourceInterface
if mapping.Scope.Name() == meta.RESTScopeNameNamespace {
dr = client.Resource(mapping.Resource).Namespace(*kubeconfigArgs.Namespace)
} else {
dr = client.Resource(mapping.Resource)
}
list, err := dr.List(ctx, metav1.ListOptions{})
if err != nil {
return completionError(err)
}
var comps []string
for _, item := range list.Items {
name := item.GetName()
if strings.HasPrefix(name, toComplete) {
comps = append(comps, name)
}
}
return comps, cobra.ShellCompDirectiveNoFileComp
}
}
func completionError(err error) ([]string, cobra.ShellCompDirective) {
cobra.CompError(err.Error())
return nil, cobra.ShellCompDirectiveError
}

View File

@@ -17,6 +17,7 @@ limitations under the License.
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
@@ -27,12 +28,12 @@ var completionZshCmd = &cobra.Command{
Short: "Generates zsh completion scripts",
Example: `To load completion run
. <(flux completion zsh) && compdef _flux flux
. <(flux completion zsh)
To configure your zsh shell to load completions for each session add to your zshrc
# ~/.zshrc or ~/.profile
command -v flux >/dev/null && . <(flux completion zsh) && compdef _flux flux
command -v flux >/dev/null && . <(flux completion zsh)
or write a cached file in one of the completion directories in your ${fpath}:
@@ -43,6 +44,8 @@ mv _flux ~/.oh-my-zsh/completions # oh-my-zsh
mv _flux ~/.zprezto/modules/completion/external/src/ # zprezto`,
Run: func(cmd *cobra.Command, args []string) {
rootCmd.GenZshCompletion(os.Stdout)
// Cobra doesn't source zsh completion file, explicitly doing it here
fmt.Println("compdef _flux flux")
},
}

View File

@@ -19,6 +19,7 @@ package main
import (
"context"
"fmt"
"regexp"
"strings"
"time"
@@ -51,6 +52,18 @@ func init() {
createCmd.PersistentFlags().BoolVar(&createArgs.export, "export", false, "export in YAML format to stdout")
createCmd.PersistentFlags().StringSliceVar(&createArgs.labels, "label", nil,
"set labels on the resource (can specify multiple labels with commas: label1=value1,label2=value2)")
createCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("name is required")
}
name := args[0]
if !validateObjectName(name) {
return fmt.Errorf("name '%s' is invalid, it should adhere to standard defined in RFC 1123, the name can only contain alphanumeric characters or '-'", name)
}
return nil
}
rootCmd.AddCommand(createCmd)
}
@@ -66,12 +79,12 @@ type upsertable interface {
// want to update. The mutate function is nullary -- you mutate a
// value in the closure, e.g., by doing this:
//
// var existing Value
// existing.Name = name
// existing.Namespace = ns
// upsert(ctx, client, valueAdapter{&value}, func() error {
// value.Spec = onePreparedEarlier
// })
// var existing Value
// existing.Name = name
// existing.Namespace = ns
// upsert(ctx, client, valueAdapter{&value}, func() error {
// value.Spec = onePreparedEarlier
// })
func (names apiType) upsert(ctx context.Context, kubeClient client.Client, object upsertable, mutate func() error) (types.NamespacedName, error) {
nsname := types.NamespacedName{
Namespace: object.GetNamespace(),
@@ -104,7 +117,7 @@ func (names apiType) upsertAndWait(object upsertWaitable, mutate func() error) e
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext) // NB globals
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions) // NB globals
if err != nil {
return err
}
@@ -150,3 +163,8 @@ func parseLabels() (map[string]string, error) {
return result, nil
}
func validateObjectName(name string) bool {
r := regexp.MustCompile("^[a-z0-9]([a-z0-9\\-]){0,61}[a-z0-9]$")
return r.MatchString(name)
}

View File

@@ -58,14 +58,11 @@ var alertArgs alertFlags
func init() {
createAlertCmd.Flags().StringVar(&alertArgs.providerRef, "provider-ref", "", "reference to provider")
createAlertCmd.Flags().StringVar(&alertArgs.eventSeverity, "event-severity", "", "severity of events to send alerts for")
createAlertCmd.Flags().StringArrayVar(&alertArgs.eventSources, "event-source", []string{}, "sources that should generate alerts (<kind>/<name>)")
createAlertCmd.Flags().StringSliceVar(&alertArgs.eventSources, "event-source", []string{}, "sources that should generate alerts (<kind>/<name>), also accepts comma-separated values")
createCmd.AddCommand(createAlertCmd)
}
func createAlertCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("Alert name is required")
}
name := args[0]
if alertArgs.providerRef == "" {
@@ -74,14 +71,15 @@ func createAlertCmdRun(cmd *cobra.Command, args []string) error {
eventSources := []notificationv1.CrossNamespaceObjectReference{}
for _, eventSource := range alertArgs.eventSources {
kind, name := utils.ParseObjectKindName(eventSource)
kind, name, namespace := utils.ParseObjectKindNameNamespace(eventSource)
if kind == "" {
return fmt.Errorf("invalid event source '%s', must be in format <kind>/<name>", eventSource)
}
eventSources = append(eventSources, notificationv1.CrossNamespaceObjectReference{
Kind: kind,
Name: name,
Kind: kind,
Name: name,
Namespace: namespace,
})
}
@@ -101,7 +99,7 @@ func createAlertCmdRun(cmd *cobra.Command, args []string) error {
alert := notificationv1.Alert{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
Spec: notificationv1.AlertSpec{
@@ -121,7 +119,7 @@ func createAlertCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}

View File

@@ -73,9 +73,6 @@ func init() {
}
func createAlertProviderCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("Provider name is required")
}
name := args[0]
if alertProviderArgs.alertType == "" {
@@ -94,7 +91,7 @@ func createAlertProviderCmdRun(cmd *cobra.Command, args []string) error {
provider := notificationv1.Provider{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
Spec: notificationv1.ProviderSpec{
@@ -118,7 +115,7 @@ func createAlertProviderCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}

View File

@@ -20,7 +20,9 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"
"time"
"github.com/fluxcd/flux2/internal/flags"
"github.com/fluxcd/flux2/internal/utils"
@@ -87,7 +89,8 @@ var createHelmReleaseCmd = &cobra.Command{
# Create a HelmRelease targeting another namespace than the resource
flux create hr podinfo \
--target-namespace=default \
--target-namespace=test \
--create-target-namespace=true \
--source=HelmRepository/podinfo \
--chart=podinfo
@@ -107,36 +110,45 @@ var createHelmReleaseCmd = &cobra.Command{
}
type helmReleaseFlags struct {
name string
source flags.HelmChartSource
dependsOn []string
chart string
chartVersion string
targetNamespace string
valuesFile []string
valuesFrom flags.HelmReleaseValuesFrom
saName string
name string
source flags.HelmChartSource
dependsOn []string
chart string
chartVersion string
targetNamespace string
createNamespace bool
valuesFiles []string
valuesFrom []string
saName string
crds flags.CRDsPolicy
reconcileStrategy string
chartInterval time.Duration
kubeConfigSecretRef string
}
var helmReleaseArgs helmReleaseFlags
var supportedHelmReleaseValuesFromKinds = []string{"Secret", "ConfigMap"}
func init() {
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.name, "release-name", "", "name used for the Helm release, defaults to a composition of '[<target-namespace>-]<HelmRelease-name>'")
createHelmReleaseCmd.Flags().Var(&helmReleaseArgs.source, "source", helmReleaseArgs.source.Description())
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.chart, "chart", "", "Helm chart name or path")
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.chartVersion, "chart-version", "", "Helm chart version, accepts a semver range (ignored for charts from GitRepository sources)")
createHelmReleaseCmd.Flags().StringArrayVar(&helmReleaseArgs.dependsOn, "depends-on", nil, "HelmReleases that must be ready before this release can be installed, supported formats '<name>' and '<namespace>/<name>'")
createHelmReleaseCmd.Flags().StringSliceVar(&helmReleaseArgs.dependsOn, "depends-on", nil, "HelmReleases that must be ready before this release can be installed, supported formats '<name>' and '<namespace>/<name>'")
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.targetNamespace, "target-namespace", "", "namespace to install this release, defaults to the HelmRelease namespace")
createHelmReleaseCmd.Flags().BoolVar(&helmReleaseArgs.createNamespace, "create-target-namespace", false, "create the target namespace if it does not exist")
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.saName, "service-account", "", "the name of the service account to impersonate when reconciling this HelmRelease")
createHelmReleaseCmd.Flags().StringArrayVar(&helmReleaseArgs.valuesFile, "values", nil, "local path to values.yaml files")
createHelmReleaseCmd.Flags().Var(&helmReleaseArgs.valuesFrom, "values-from", helmReleaseArgs.valuesFrom.Description())
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.reconcileStrategy, "reconcile-strategy", "ChartVersion", "the reconcile strategy for helm chart created by the helm release(accepted values: Revision and ChartRevision)")
createHelmReleaseCmd.Flags().DurationVarP(&helmReleaseArgs.chartInterval, "chart-interval", "", 0, "the interval of which to check for new chart versions")
createHelmReleaseCmd.Flags().StringSliceVar(&helmReleaseArgs.valuesFiles, "values", nil, "local path to values.yaml files, also accepts comma-separated values")
createHelmReleaseCmd.Flags().StringSliceVar(&helmReleaseArgs.valuesFrom, "values-from", nil, "a Kubernetes object reference that contains the values.yaml data key in the format '<kind>/<name>', where kind must be one of: (Secret,ConfigMap)")
createHelmReleaseCmd.Flags().Var(&helmReleaseArgs.crds, "crds", helmReleaseArgs.crds.Description())
createHelmReleaseCmd.Flags().StringVar(&helmReleaseArgs.kubeConfigSecretRef, "kubeconfig-secret-ref", "", "the name of the Kubernetes Secret that contains a key with the kubeconfig file for connecting to a remote cluster")
createCmd.AddCommand(createHelmReleaseCmd)
}
func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("HelmRelease name is required")
}
name := args[0]
if helmReleaseArgs.chart == "" {
@@ -152,10 +164,15 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
logger.Generatef("generating HelmRelease")
}
if !validateStrategy(helmReleaseArgs.reconcileStrategy) {
return fmt.Errorf("'%s' is an invalid reconcile strategy(valid: Revision, ChartVersion)",
helmReleaseArgs.reconcileStrategy)
}
helmRelease := helmv2.HelmRelease{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
Spec: helmv2.HelmReleaseSpec{
@@ -165,6 +182,7 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
Duration: createArgs.interval,
},
TargetNamespace: helmReleaseArgs.targetNamespace,
Chart: helmv2.HelmChartTemplate{
Spec: helmv2.HelmChartTemplateSpec{
Chart: helmReleaseArgs.chart,
@@ -174,20 +192,52 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
Name: helmReleaseArgs.source.Name,
Namespace: helmReleaseArgs.source.Namespace,
},
ReconcileStrategy: helmReleaseArgs.reconcileStrategy,
},
},
Suspend: false,
},
}
if helmReleaseArgs.kubeConfigSecretRef != "" {
helmRelease.Spec.KubeConfig = &helmv2.KubeConfig{
SecretRef: meta.SecretKeyReference{
Name: helmReleaseArgs.kubeConfigSecretRef,
},
}
}
if helmReleaseArgs.chartInterval != 0 {
helmRelease.Spec.Chart.Spec.Interval = &metav1.Duration{
Duration: helmReleaseArgs.chartInterval,
}
}
if helmReleaseArgs.createNamespace {
if helmRelease.Spec.Install == nil {
helmRelease.Spec.Install = &helmv2.Install{}
}
helmRelease.Spec.Install.CreateNamespace = helmReleaseArgs.createNamespace
}
if helmReleaseArgs.saName != "" {
helmRelease.Spec.ServiceAccountName = helmReleaseArgs.saName
}
if len(helmReleaseArgs.valuesFile) > 0 {
var valuesMap map[string]interface{}
for _, v := range helmReleaseArgs.valuesFile {
data, err := ioutil.ReadFile(v)
if helmReleaseArgs.crds != "" {
if helmRelease.Spec.Install == nil {
helmRelease.Spec.Install = &helmv2.Install{}
}
helmRelease.Spec.Install.CRDs = helmv2.Create
helmRelease.Spec.Upgrade = &helmv2.Upgrade{CRDs: helmv2.CRDsPolicy(helmReleaseArgs.crds.String())}
}
if len(helmReleaseArgs.valuesFiles) > 0 {
valuesMap := make(map[string]interface{})
for _, v := range helmReleaseArgs.valuesFiles {
data, err := os.ReadFile(v)
if err != nil {
return fmt.Errorf("reading values from %s failed: %w", v, err)
}
@@ -202,11 +252,7 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("unmarshaling values from %s failed: %w", v, err)
}
if valuesMap == nil {
valuesMap = jsonMap
} else {
valuesMap = transform.MergeMaps(valuesMap, jsonMap)
}
valuesMap = transform.MergeMaps(valuesMap, jsonMap)
}
jsonRaw, err := json.Marshal(valuesMap)
@@ -217,11 +263,25 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
helmRelease.Spec.Values = &apiextensionsv1.JSON{Raw: jsonRaw}
}
if helmReleaseArgs.valuesFrom.String() != "" {
helmRelease.Spec.ValuesFrom = []helmv2.ValuesReference{{
Kind: helmReleaseArgs.valuesFrom.Kind,
Name: helmReleaseArgs.valuesFrom.Name,
}}
if len(helmReleaseArgs.valuesFrom) != 0 {
values := []helmv2.ValuesReference{}
for _, value := range helmReleaseArgs.valuesFrom {
sourceKind, sourceName := utils.ParseObjectKindName(value)
if sourceKind == "" {
return fmt.Errorf("invalid Kubernetes object reference '%s', must be in format <kind>/<name>", value)
}
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedHelmReleaseValuesFromKinds, sourceKind)
if !ok {
return fmt.Errorf("reference kind '%s' is not supported, must be one of: %s",
sourceKind, strings.Join(supportedHelmReleaseValuesFromKinds, ", "))
}
values = append(values, helmv2.ValuesReference{
Name: sourceName,
Kind: cleanSourceKind,
})
}
helmRelease.Spec.ValuesFrom = values
}
if createArgs.export {
@@ -231,7 +291,7 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
@@ -300,3 +360,15 @@ func isHelmReleaseReady(ctx context.Context, kubeClient client.Client,
return apimeta.IsStatusConditionTrue(helmRelease.Status.Conditions, meta.ReadyCondition), nil
}
}
func validateStrategy(input string) bool {
allowedStrategy := []string{"Revision", "ChartVersion"}
for _, strategy := range allowedStrategy {
if strategy == input {
return true
}
}
return false
}

View File

@@ -28,7 +28,7 @@ import (
"github.com/fluxcd/pkg/apis/meta"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta1"
)
var createImagePolicyCmd = &cobra.Command{
@@ -84,9 +84,6 @@ func (obj imagePolicyAdapter) getObservedGeneration() int64 {
}
func createImagePolicyRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("ImagePolicy name is required")
}
objectName := args[0]
if imagePolicyArgs.imageRef == "" {
@@ -101,11 +98,11 @@ func createImagePolicyRun(cmd *cobra.Command, args []string) error {
var policy = imagev1.ImagePolicy{
ObjectMeta: metav1.ObjectMeta{
Name: objectName,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: labels,
},
Spec: imagev1.ImagePolicySpec{
ImageRepositoryRef: meta.LocalObjectReference{
ImageRepositoryRef: meta.NamespacedObjectReference{
Name: imagePolicyArgs.imageRef,
},
},

View File

@@ -26,7 +26,7 @@ import (
"github.com/fluxcd/pkg/apis/meta"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta1"
)
var createImageRepositoryCmd = &cobra.Command{
@@ -83,9 +83,6 @@ func init() {
}
func createImageRepositoryRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("ImageRepository name is required")
}
objectName := args[0]
if imageRepoArgs.image == "" {
@@ -104,7 +101,7 @@ func createImageRepositoryRun(cmd *cobra.Command, args []string) error {
var repo = imagev1.ImageRepository{
ObjectMeta: metav1.ObjectMeta{
Name: objectName,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: labels,
},
Spec: imagev1.ImageRepositorySpec{

View File

@@ -22,9 +22,8 @@ import (
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/fluxcd/pkg/apis/meta"
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
autov1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
)
var createImageUpdateCmd = &cobra.Command{
@@ -50,25 +49,40 @@ mentioned in YAMLs in a git repository.`,
--push-branch=image-updates \
--author-name=flux \
--author-email=flux@example.com \
--commit-template="{{range .Updated.Images}}{{println .}}{{end}}"`,
--commit-template="{{range .Updated.Images}}{{println .}}{{end}}"
# Configure image updates for a Git repository in a different namespace
flux create image update apps \
--namespace=apps \
--git-repo-ref=flux-system \
--git-repo-namespace=flux-system \
--git-repo-path="./clusters/my-cluster" \
--checkout-branch=main \
--push-branch=image-updates \
--author-name=flux \
--author-email=flux@example.com \
--commit-template="{{range .Updated.Images}}{{println .}}{{end}}"
`,
RunE: createImageUpdateRun,
}
type imageUpdateFlags struct {
gitRepoRef string
gitRepoPath string
checkoutBranch string
pushBranch string
commitTemplate string
authorName string
authorEmail string
gitRepoName string
gitRepoNamespace string
gitRepoPath string
checkoutBranch string
pushBranch string
commitTemplate string
authorName string
authorEmail string
}
var imageUpdateArgs = imageUpdateFlags{}
func init() {
flags := createImageUpdateCmd.Flags()
flags.StringVar(&imageUpdateArgs.gitRepoRef, "git-repo-ref", "", "the name of a GitRepository resource with details of the upstream Git repository")
flags.StringVar(&imageUpdateArgs.gitRepoName, "git-repo-ref", "", "the name of a GitRepository resource with details of the upstream Git repository")
flags.StringVar(&imageUpdateArgs.gitRepoNamespace, "git-repo-namespace", "", "the namespace of the GitRepository resource, defaults to the ImageUpdateAutomation namespace")
flags.StringVar(&imageUpdateArgs.gitRepoPath, "git-repo-path", "", "path to the directory containing the manifests to be updated, defaults to the repository root")
flags.StringVar(&imageUpdateArgs.checkoutBranch, "checkout-branch", "", "the branch to checkout")
flags.StringVar(&imageUpdateArgs.pushBranch, "push-branch", "", "the branch to push commits to, defaults to the checkout branch if not specified")
@@ -80,12 +94,9 @@ func init() {
}
func createImageUpdateRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("ImageUpdateAutomation name is required")
}
objectName := args[0]
if imageUpdateArgs.gitRepoRef == "" {
if imageUpdateArgs.gitRepoName == "" {
return fmt.Errorf("a reference to a GitRepository is required (--git-repo-ref)")
}
@@ -109,29 +120,38 @@ func createImageUpdateRun(cmd *cobra.Command, args []string) error {
var update = autov1.ImageUpdateAutomation{
ObjectMeta: metav1.ObjectMeta{
Name: objectName,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: labels,
},
Spec: autov1.ImageUpdateAutomationSpec{
Checkout: autov1.GitCheckoutSpec{
GitRepositoryRef: meta.LocalObjectReference{
Name: imageUpdateArgs.gitRepoRef,
SourceRef: autov1.CrossNamespaceSourceReference{
Kind: sourcev1.GitRepositoryKind,
Name: imageUpdateArgs.gitRepoName,
Namespace: imageUpdateArgs.gitRepoNamespace,
},
GitSpec: &autov1.GitSpec{
Checkout: &autov1.GitCheckoutSpec{
Reference: sourcev1.GitRepositoryRef{
Branch: imageUpdateArgs.checkoutBranch,
},
},
Commit: autov1.CommitSpec{
Author: autov1.CommitUser{
Name: imageUpdateArgs.authorName,
Email: imageUpdateArgs.authorEmail,
},
MessageTemplate: imageUpdateArgs.commitTemplate,
},
Branch: imageUpdateArgs.checkoutBranch,
},
Interval: metav1.Duration{
Duration: createArgs.interval,
},
Commit: autov1.CommitSpec{
AuthorName: imageUpdateArgs.authorName,
AuthorEmail: imageUpdateArgs.authorEmail,
MessageTemplate: imageUpdateArgs.commitTemplate,
},
},
}
if imageUpdateArgs.pushBranch != "" {
update.Spec.Push = &autov1.PushSpec{
update.Spec.GitSpec.Push = &autov1.PushSpec{
Branch: imageUpdateArgs.pushBranch,
}
}

View File

@@ -31,7 +31,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
helmv2 "github.com/fluxcd/helm-controller/api/v2beta1"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta1"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
"github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/flux2/internal/flags"
@@ -42,35 +42,38 @@ var createKsCmd = &cobra.Command{
Use: "kustomization [name]",
Aliases: []string{"ks"},
Short: "Create or update a Kustomization resource",
Long: "The kustomization source create command generates a Kustomize resource for a given source.",
Long: "The create command generates a Kustomization resource for a given source.",
Example: ` # Create a Kustomization resource from a source at a given path
flux create kustomization contour \
--source=GitRepository/contour \
--path="./examples/contour/" \
flux create kustomization kyverno \
--source=GitRepository/kyverno \
--path="./config/release" \
--prune=true \
--interval=10m \
--validation=client \
--health-check="Deployment/contour.projectcontour" \
--health-check="DaemonSet/envoy.projectcontour" \
--interval=60m \
--wait=true \
--health-check-timeout=3m
# Create a Kustomization resource that depends on the previous one
flux create kustomization webapp \
--depends-on=contour \
--source=GitRepository/webapp \
--path="./deploy/overlays/dev" \
flux create kustomization kyverno-policies \
--depends-on=kyverno \
--source=GitRepository/kyverno-policies \
--path="./policies/flux" \
--prune=true \
--interval=5m \
--validation=client
--interval=5m
# Create a Kustomization using a source from a different namespace
flux create kustomization podinfo \
--namespace=default \
--source=GitRepository/podinfo.flux-system \
--path="./deploy/overlays/dev" \
--path="./kustomize" \
--prune=true \
--interval=5m \
--validation=client
--interval=5m
# Create a Kustomization resource that references an OCIRepository
flux create kustomization podinfo \
--source=OCIRepository/podinfo \
--target-namespace=default \
--prune=true \
--interval=5m
# Create a Kustomization resource that references a Bucket
flux create kustomization secrets \
@@ -81,17 +84,19 @@ var createKsCmd = &cobra.Command{
}
type kustomizationFlags struct {
source flags.KustomizationSource
path flags.SafeRelativePath
prune bool
dependsOn []string
validation string
healthCheck []string
healthTimeout time.Duration
saName string
decryptionProvider flags.DecryptionProvider
decryptionSecret string
targetNamespace string
source flags.KustomizationSource
path flags.SafeRelativePath
prune bool
dependsOn []string
validation string
healthCheck []string
healthTimeout time.Duration
saName string
decryptionProvider flags.DecryptionProvider
decryptionSecret string
targetNamespace string
wait bool
kubeConfigSecretRef string
}
var kustomizationArgs = NewKustomizationFlags()
@@ -100,14 +105,18 @@ func init() {
createKsCmd.Flags().Var(&kustomizationArgs.source, "source", kustomizationArgs.source.Description())
createKsCmd.Flags().Var(&kustomizationArgs.path, "path", "path to the directory containing a kustomization.yaml file")
createKsCmd.Flags().BoolVar(&kustomizationArgs.prune, "prune", false, "enable garbage collection")
createKsCmd.Flags().StringArrayVar(&kustomizationArgs.healthCheck, "health-check", nil, "workload to be included in the health assessment, in the format '<kind>/<name>.<namespace>'")
createKsCmd.Flags().BoolVar(&kustomizationArgs.wait, "wait", false, "enable health checking of all the applied resources")
createKsCmd.Flags().StringSliceVar(&kustomizationArgs.healthCheck, "health-check", nil, "workload to be included in the health assessment, in the format '<kind>/<name>.<namespace>'")
createKsCmd.Flags().DurationVar(&kustomizationArgs.healthTimeout, "health-check-timeout", 2*time.Minute, "timeout of health checking operations")
createKsCmd.Flags().StringVar(&kustomizationArgs.validation, "validation", "", "validate the manifests before applying them on the cluster, can be 'client' or 'server'")
createKsCmd.Flags().StringArrayVar(&kustomizationArgs.dependsOn, "depends-on", nil, "Kustomization that must be ready before this Kustomization can be applied, supported formats '<name>' and '<namespace>/<name>'")
createKsCmd.Flags().StringSliceVar(&kustomizationArgs.dependsOn, "depends-on", nil, "Kustomization that must be ready before this Kustomization can be applied, supported formats '<name>' and '<namespace>/<name>', also accepts comma-separated values")
createKsCmd.Flags().StringVar(&kustomizationArgs.saName, "service-account", "", "the name of the service account to impersonate when reconciling this Kustomization")
createKsCmd.Flags().Var(&kustomizationArgs.decryptionProvider, "decryption-provider", kustomizationArgs.decryptionProvider.Description())
createKsCmd.Flags().StringVar(&kustomizationArgs.decryptionSecret, "decryption-secret", "", "set the Kubernetes secret name that contains the OpenPGP private keys used for sops decryption")
createKsCmd.Flags().StringVar(&kustomizationArgs.targetNamespace, "target-namespace", "", "overrides the namespace of all Kustomization objects reconciled by this Kustomization")
createKsCmd.Flags().StringVar(&kustomizationArgs.kubeConfigSecretRef, "kubeconfig-secret-ref", "", "the name of the Kubernetes Secret that contains a key with the kubeconfig file for connecting to a remote cluster")
createKsCmd.Flags().MarkDeprecated("validation", "this arg is no longer used, all resources are validated using server-side apply dry-run")
createCmd.AddCommand(createKsCmd)
}
@@ -118,9 +127,6 @@ func NewKustomizationFlags() kustomizationFlags {
}
func createKsCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("Kustomization name is required")
}
name := args[0]
if kustomizationArgs.path == "" {
@@ -142,7 +148,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
kustomization := kustomizev1.Kustomization{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: kslabels,
},
Spec: kustomizev1.KustomizationSpec{
@@ -158,12 +164,19 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
Namespace: kustomizationArgs.source.Namespace,
},
Suspend: false,
Validation: kustomizationArgs.validation,
TargetNamespace: kustomizationArgs.targetNamespace,
},
}
if len(kustomizationArgs.healthCheck) > 0 {
if kustomizationArgs.kubeConfigSecretRef != "" {
kustomization.Spec.KubeConfig = &meta.KubeConfigReference{
SecretRef: meta.SecretKeyReference{
Name: kustomizationArgs.kubeConfigSecretRef,
},
}
}
if len(kustomizationArgs.healthCheck) > 0 && !kustomizationArgs.wait {
healthChecks := make([]meta.NamespacedObjectKindReference, 0)
for _, w := range kustomizationArgs.healthCheck {
kindObj := strings.Split(w, "/")
@@ -204,6 +217,13 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
}
}
if kustomizationArgs.wait {
kustomization.Spec.Wait = true
kustomization.Spec.Timeout = &metav1.Duration{
Duration: kustomizationArgs.healthTimeout,
}
}
if kustomizationArgs.saName != "" {
kustomization.Spec.ServiceAccountName = kustomizationArgs.saName
}
@@ -225,7 +245,7 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}

View File

@@ -61,15 +61,12 @@ var receiverArgs receiverFlags
func init() {
createReceiverCmd.Flags().StringVar(&receiverArgs.receiverType, "type", "", "")
createReceiverCmd.Flags().StringVar(&receiverArgs.secretRef, "secret-ref", "", "")
createReceiverCmd.Flags().StringArrayVar(&receiverArgs.events, "event", []string{}, "")
createReceiverCmd.Flags().StringArrayVar(&receiverArgs.resources, "resource", []string{}, "")
createReceiverCmd.Flags().StringSliceVar(&receiverArgs.events, "event", []string{}, "also accepts comma-separated values")
createReceiverCmd.Flags().StringSliceVar(&receiverArgs.resources, "resource", []string{}, "also accepts comma-separated values")
createCmd.AddCommand(createReceiverCmd)
}
func createReceiverCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("Receiver name is required")
}
name := args[0]
if receiverArgs.receiverType == "" {
@@ -109,7 +106,7 @@ func createReceiverCmdRun(cmd *cobra.Command, args []string) error {
receiver := notificationv1.Receiver{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
Spec: notificationv1.ReceiverSpec{
@@ -130,7 +127,7 @@ func createReceiverCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}

View File

@@ -50,25 +50,28 @@ For Git over HTTP/S, the provided basic authentication credentials are stored in
--url=ssh://git@github.com/stefanprodan/podinfo \
--private-key-file=./private.key
# Create a Git SSH authentication secret with a passworded private key from file
# The public SSH host key will still be gathered from the host
flux create secret git podinfo-auth \
--url=ssh://git@github.com/stefanprodan/podinfo \
--private-key-file=./private.key \
--password=<password>
# Create a secret for a Git repository using basic authentication
flux create secret git podinfo-auth \
--url=https://github.com/stefanprodan/podinfo \
--username=username \
--password=password
# Create a Git SSH secret on disk and print the deploy key
# Create a Git SSH secret on disk
flux create secret git podinfo-auth \
--url=ssh://git@github.com/stefanprodan/podinfo \
--export > podinfo-auth.yaml
yq read podinfo-auth.yaml 'data."identity.pub"' | base64 --decode
# Create a Git SSH secret on disk and encrypt it with Mozilla SOPS
flux create secret git podinfo-auth \
--namespace=apps \
--url=ssh://git@github.com/stefanprodan/podinfo \
--export > podinfo-auth.yaml
# Print the deploy key
yq eval '.stringData."identity.pub"' podinfo-auth.yaml
# Encrypt the secret on disk with Mozilla SOPS
sops --encrypt --encrypted-regex '^(data|stringData)$' \
--in-place podinfo-auth.yaml`,
RunE: createSecretGitCmdRun,
@@ -102,16 +105,13 @@ func init() {
func NewSecretGitFlags() secretGitFlags {
return secretGitFlags{
keyAlgorithm: flags.PublicKeyAlgorithm(sourcesecret.RSAPrivateKeyAlgorithm),
keyAlgorithm: flags.PublicKeyAlgorithm(sourcesecret.ECDSAPrivateKeyAlgorithm),
rsaBits: 2048,
ecdsaCurve: flags.ECDSACurve{Curve: elliptic.P384()},
}
}
func createSecretGitCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("secret name is required")
}
name := args[0]
if secretGitArgs.url == "" {
return fmt.Errorf("url is required")
@@ -129,7 +129,7 @@ func createSecretGitCmdRun(cmd *cobra.Command, args []string) error {
opts := sourcesecret.Options{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: labels,
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
}
@@ -140,6 +140,7 @@ func createSecretGitCmdRun(cmd *cobra.Command, args []string) error {
opts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(secretGitArgs.keyAlgorithm)
opts.RSAKeyBits = int(secretGitArgs.rsaBits)
opts.ECDSACurve = secretGitArgs.ecdsaCurve.Curve
opts.Password = secretGitArgs.password
case "http", "https":
if secretGitArgs.username == "" || secretGitArgs.password == "" {
return fmt.Errorf("for Git over HTTP/S the username and password are required")
@@ -157,7 +158,7 @@ func createSecretGitCmdRun(cmd *cobra.Command, args []string) error {
}
if createArgs.export {
fmt.Println(secret.Content)
rootCmd.Println(secret.Content)
return nil
}
@@ -172,14 +173,14 @@ func createSecretGitCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
if err := upsertSecret(ctx, kubeClient, s); err != nil {
return err
}
logger.Actionf("secret '%s' created in '%s' namespace", name, rootArgs.namespace)
logger.Actionf("git secret '%s' created in '%s' namespace", name, *kubeconfigArgs.Namespace)
return nil
}

View File

@@ -0,0 +1,44 @@
package main
import (
"testing"
)
func TestCreateGitSecret(t *testing.T) {
tests := []struct {
name string
args string
assert assertFunc
}{
{
name: "no args",
args: "create secret git",
assert: assertError("name is required"),
},
{
name: "basic secret",
args: "create secret git podinfo-auth --url=https://github.com/stefanprodan/podinfo --username=my-username --password=my-password --namespace=my-namespace --export",
assert: assertGoldenFile("./testdata/create_secret/git/secret-git-basic.yaml"),
},
{
name: "ssh key",
args: "create secret git podinfo-auth --url=ssh://git@github.com/stefanprodan/podinfo --private-key-file=./testdata/create_secret/git/ecdsa.private --namespace=my-namespace --export",
assert: assertGoldenFile("testdata/create_secret/git/git-ssh-secret.yaml"),
},
{
name: "ssh key with password",
args: "create secret git podinfo-auth --url=ssh://git@github.com/stefanprodan/podinfo --private-key-file=./testdata/create_secret/git/ecdsa-password.private --password=password --namespace=my-namespace --export",
assert: assertGoldenFile("testdata/create_secret/git/git-ssh-secret-password.yaml"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cmd := cmdTestCase{
args: tt.args,
assert: tt.assert,
}
cmd.runTestCmd(t)
})
}
}

View File

@@ -18,7 +18,6 @@ package main
import (
"context"
"fmt"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
@@ -68,9 +67,6 @@ func init() {
}
func createSecretHelmCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("secret name is required")
}
name := args[0]
labels, err := parseLabels()
@@ -80,7 +76,7 @@ func createSecretHelmCmdRun(cmd *cobra.Command, args []string) error {
opts := sourcesecret.Options{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: labels,
Username: secretHelmArgs.username,
Password: secretHelmArgs.password,
@@ -94,13 +90,13 @@ func createSecretHelmCmdRun(cmd *cobra.Command, args []string) error {
}
if createArgs.export {
fmt.Println(secret.Content)
rootCmd.Println(secret.Content)
return nil
}
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
@@ -112,5 +108,6 @@ func createSecretHelmCmdRun(cmd *cobra.Command, args []string) error {
return err
}
logger.Actionf("helm secret '%s' created in '%s' namespace", name, *kubeconfigArgs.Namespace)
return nil
}

View File

@@ -0,0 +1,47 @@
/*
Copyright 2022 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 (
"testing"
)
func TestCreateHelmSecret(t *testing.T) {
tests := []struct {
name string
args string
assert assertFunc
}{
{
args: "create secret helm",
assert: assertError("name is required"),
},
{
args: "create secret helm helm-secret --username=my-username --password=my-password --namespace=my-namespace --export",
assert: assertGoldenFile("testdata/create_secret/helm/secret-helm.yaml"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cmd := cmdTestCase{
args: tt.args,
assert: tt.assert,
}
cmd.runTestCmd(t)
})
}
}

View File

@@ -0,0 +1,121 @@
/*
Copyright 2022 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 (
"context"
"fmt"
"github.com/fluxcd/flux2/internal/utils"
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
"github.com/google/go-containerregistry/pkg/name"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/yaml"
)
var createSecretOCICmd = &cobra.Command{
Use: "oci [name]",
Short: "Create or update a Kubernetes image pull secret",
Long: `The create secret oci command generates a Kubernetes secret that can be used for OCIRepository authentication`,
Example: ` # Create an OCI authentication secret on disk and encrypt it with Mozilla SOPS
flux create secret oci podinfo-auth \
--url=ghcr.io \
--username=username \
--password=password \
--export > repo-auth.yaml
sops --encrypt --encrypted-regex '^(data|stringData)$' \
--in-place repo-auth.yaml
`,
RunE: createSecretOCICmdRun,
}
type secretOCIFlags struct {
url string
password string
username string
}
var secretOCIArgs = secretOCIFlags{}
func init() {
createSecretOCICmd.Flags().StringVar(&secretOCIArgs.url, "url", "", "oci repository address e.g ghcr.io/stefanprodan/charts")
createSecretOCICmd.Flags().StringVarP(&secretOCIArgs.username, "username", "u", "", "basic authentication username")
createSecretOCICmd.Flags().StringVarP(&secretOCIArgs.password, "password", "p", "", "basic authentication password")
createSecretCmd.AddCommand(createSecretOCICmd)
}
func createSecretOCICmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("name is required")
}
secretName := args[0]
if secretOCIArgs.url == "" {
return fmt.Errorf("--url is required")
}
if secretOCIArgs.username == "" {
return fmt.Errorf("--username is required")
}
if secretOCIArgs.password == "" {
return fmt.Errorf("--password is required")
}
if _, err := name.ParseReference(secretOCIArgs.url); err != nil {
return fmt.Errorf("error parsing url: '%s'", err)
}
opts := sourcesecret.Options{
Name: secretName,
Namespace: *kubeconfigArgs.Namespace,
Registry: secretOCIArgs.url,
Password: secretOCIArgs.password,
Username: secretOCIArgs.username,
}
secret, err := sourcesecret.Generate(opts)
if err != nil {
return err
}
if createArgs.export {
rootCmd.Println(secret.Content)
return nil
}
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
var s corev1.Secret
if err := yaml.Unmarshal([]byte(secret.Content), &s); err != nil {
return err
}
if err := upsertSecret(ctx, kubeClient, s); err != nil {
return err
}
logger.Actionf("oci secret '%s' created in '%s' namespace", secretName, *kubeconfigArgs.Namespace)
return nil
}

View File

@@ -0,0 +1,51 @@
/*
Copyright 2022 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 (
"testing"
)
func TestCreateSecretOCI(t *testing.T) {
tests := []struct {
name string
args string
assert assertFunc
}{
{
args: "create secret oci",
assert: assertError("name is required"),
},
{
args: "create secret oci ghcr",
assert: assertError("--url is required"),
},
{
args: "create secret oci ghcr --namespace=my-namespace --url ghcr.io --username stefanprodan --password=password --export",
assert: assertGoldenFile("testdata/create_secret/oci/create-secret.yaml"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cmd := cmdTestCase{
args: tt.args,
assert: tt.assert,
}
cmd.runTestCmd(t)
})
}
}

View File

@@ -18,7 +18,6 @@ package main
import (
"context"
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@@ -67,9 +66,6 @@ func init() {
}
func createSecretTLSCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("secret name is required")
}
name := args[0]
labels, err := parseLabels()
@@ -79,7 +75,7 @@ func createSecretTLSCmdRun(cmd *cobra.Command, args []string) error {
opts := sourcesecret.Options{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: labels,
CAFilePath: secretTLSArgs.caFile,
CertFilePath: secretTLSArgs.certFile,
@@ -91,13 +87,13 @@ func createSecretTLSCmdRun(cmd *cobra.Command, args []string) error {
}
if createArgs.export {
fmt.Println(secret.Content)
rootCmd.Print(secret.Content)
return nil
}
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
@@ -109,5 +105,6 @@ func createSecretTLSCmdRun(cmd *cobra.Command, args []string) error {
return err
}
logger.Actionf("tls secret '%s' created in '%s' namespace", name, *kubeconfigArgs.Namespace)
return nil
}

View File

@@ -0,0 +1,31 @@
package main
import (
"testing"
)
func TestCreateTlsSecretNoArgs(t *testing.T) {
tests := []struct {
name string
args string
assert assertFunc
}{
{
args: "create secret tls",
assert: assertError("name is required"),
},
{
args: "create secret tls certs --namespace=my-namespace --cert-file=./testdata/create_secret/tls/test-cert.pem --key-file=./testdata/create_secret/tls/test-key.pem --export",
assert: assertGoldenFile("testdata/create_secret/tls/secret-tls.yaml"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cmd := cmdTestCase{
args: tt.args,
assert: tt.assert,
}
cmd.runTestCmd(t)
})
}
}

View File

@@ -17,6 +17,8 @@ limitations under the License.
package main
import (
"time"
"github.com/spf13/cobra"
)
@@ -26,6 +28,14 @@ var createSourceCmd = &cobra.Command{
Long: "The create source sub-commands generate sources.",
}
type createSourceFlags struct {
fetchTimeout time.Duration
}
var createSourceArgs createSourceFlags
func init() {
createSourceCmd.PersistentFlags().DurationVar(&createSourceArgs.fetchTimeout, "fetch-timeout", createSourceArgs.fetchTimeout,
"set a timeout for fetch operations performed by source-controller (e.g. 'git clone' or 'helm repo update')")
createCmd.AddCommand(createSourceCmd)
}

View File

@@ -19,8 +19,8 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
@@ -31,7 +31,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/fluxcd/pkg/apis/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
"github.com/fluxcd/pkg/runtime/conditions"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/internal/flags"
"github.com/fluxcd/flux2/internal/utils"
@@ -62,17 +64,18 @@ For Buckets with static authentication, the credentials are stored in a Kubernet
}
type sourceBucketFlags struct {
name string
provider flags.SourceBucketProvider
endpoint string
accessKey string
secretKey string
region string
insecure bool
secretRef string
name string
provider flags.SourceBucketProvider
endpoint string
accessKey string
secretKey string
region string
insecure bool
secretRef string
ignorePaths []string
}
var sourceBucketArgs = NewSourceBucketFlags()
var sourceBucketArgs = newSourceBucketFlags()
func init() {
createSourceBucketCmd.Flags().Var(&sourceBucketArgs.provider, "provider", sourceBucketArgs.provider.Description())
@@ -83,20 +86,18 @@ func init() {
createSourceBucketCmd.Flags().StringVar(&sourceBucketArgs.region, "region", "", "the bucket region")
createSourceBucketCmd.Flags().BoolVar(&sourceBucketArgs.insecure, "insecure", false, "for when connecting to a non-TLS S3 HTTP endpoint")
createSourceBucketCmd.Flags().StringVar(&sourceBucketArgs.secretRef, "secret-ref", "", "the name of an existing secret containing credentials")
createSourceBucketCmd.Flags().StringSliceVar(&sourceBucketArgs.ignorePaths, "ignore-paths", nil, "set paths to ignore in bucket resource (can specify multiple paths with commas: path1,path2)")
createSourceCmd.AddCommand(createSourceBucketCmd)
}
func NewSourceBucketFlags() sourceBucketFlags {
func newSourceBucketFlags() sourceBucketFlags {
return sourceBucketFlags{
provider: flags.SourceBucketProvider(sourcev1.GenericBucketProvider),
}
}
func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("Bucket source name is required")
}
name := args[0]
if sourceBucketArgs.name == "" {
@@ -112,16 +113,22 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
return err
}
tmpDir, err := ioutil.TempDir("", name)
tmpDir, err := os.MkdirTemp("", name)
if err != nil {
return err
}
defer os.RemoveAll(tmpDir)
var ignorePaths *string
if len(sourceBucketArgs.ignorePaths) > 0 {
ignorePathsStr := strings.Join(sourceBucketArgs.ignorePaths, "\n")
ignorePaths = &ignorePathsStr
}
bucket := &sourcev1.Bucket{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
Spec: sourcev1.BucketSpec{
@@ -133,9 +140,15 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
Interval: metav1.Duration{
Duration: createArgs.interval,
},
Ignore: ignorePaths,
},
}
if sourceHelmArgs.secretRef != "" {
if createSourceArgs.fetchTimeout > 0 {
bucket.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout}
}
if sourceBucketArgs.secretRef != "" {
bucket.Spec.SecretRef = &meta.LocalObjectReference{
Name: sourceBucketArgs.secretRef,
}
@@ -148,7 +161,7 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
@@ -161,7 +174,7 @@ func createSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
secret := corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
StringData: map[string]string{},
@@ -234,3 +247,30 @@ func upsertBucket(ctx context.Context, kubeClient client.Client,
logger.Successf("Bucket source updated")
return namespacedName, nil
}
func isBucketReady(ctx context.Context, kubeClient client.Client,
namespacedName types.NamespacedName, bucket *sourcev1.Bucket) wait.ConditionFunc {
return func() (bool, error) {
err := kubeClient.Get(ctx, namespacedName, bucket)
if err != nil {
return false, err
}
if c := conditions.Get(bucket, meta.ReadyCondition); c != nil {
// Confirm the Ready condition we are observing is for the
// current generation
if c.ObservedGeneration != bucket.GetGeneration() {
return false, nil
}
// Further check the Status
switch c.Status {
case metav1.ConditionTrue:
return true, nil
case metav1.ConditionFalse:
return false, fmt.Errorf(c.Message)
}
}
return false, nil
}
}

View File

@@ -20,23 +20,25 @@ import (
"context"
"crypto/elliptic"
"fmt"
"io/ioutil"
"net/url"
"os"
"strings"
"github.com/fluxcd/pkg/apis/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"
"github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/pkg/runtime/conditions"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/internal/flags"
"github.com/fluxcd/flux2/internal/utils"
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
@@ -57,6 +59,8 @@ type sourceGitFlags struct {
caFile string
privateKeyFile string
recurseSubmodules bool
silent bool
ignorePaths []string
}
var createSourceGitCmd = &cobra.Command{
@@ -101,9 +105,19 @@ For private Git repositories, the basic authentication credentials are stored in
--branch=master \
--private-key-file=./private.key
# Create a source for a Git repository using SSH authentication and a
# private key with a password from file
# The public SSH host key will still be gathered from the host
flux create source git podinfo \
--url=ssh://git@github.com/stefanprodan/podinfo \
--branch=master \
--private-key-file=./private.key \
--password=<password>
# Create a source for a Git repository using basic authentication
flux create source git podinfo \
--url=https://github.com/stefanprodan/podinfo \
--branch=master \
--username=username \
--password=password`,
RunE: createSourceGitCmdRun,
@@ -113,7 +127,7 @@ var sourceGitArgs = newSourceGitFlags()
func init() {
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.url, "url", "", "git address, e.g. ssh://git@host/org/repository")
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.branch, "branch", "master", "git branch")
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.branch, "branch", "", "git branch")
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.tag, "tag", "", "git tag")
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.semver, "tag-semver", "", "git tag semver range")
createSourceGitCmd.Flags().StringVarP(&sourceGitArgs.username, "username", "u", "", "basic authentication username")
@@ -127,22 +141,21 @@ func init() {
createSourceGitCmd.Flags().StringVar(&sourceGitArgs.privateKeyFile, "private-key-file", "", "path to a passwordless private key file used for authenticating to the Git SSH server")
createSourceGitCmd.Flags().BoolVar(&sourceGitArgs.recurseSubmodules, "recurse-submodules", false,
"when enabled, configures the GitRepository source to initialize and include Git submodules in the artifact it produces")
createSourceGitCmd.Flags().BoolVarP(&sourceGitArgs.silent, "silent", "s", false, "assumes the deploy key is already setup, skips confirmation")
createSourceGitCmd.Flags().StringSliceVar(&sourceGitArgs.ignorePaths, "ignore-paths", nil, "set paths to ignore in git resource (can specify multiple paths with commas: path1,path2)")
createSourceCmd.AddCommand(createSourceGitCmd)
}
func newSourceGitFlags() sourceGitFlags {
return sourceGitFlags{
keyAlgorithm: flags.PublicKeyAlgorithm(sourcesecret.RSAPrivateKeyAlgorithm),
keyAlgorithm: flags.PublicKeyAlgorithm(sourcesecret.ECDSAPrivateKeyAlgorithm),
keyRSABits: 2048,
keyECDSACurve: flags.ECDSACurve{Curve: elliptic.P384()},
}
}
func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("GitRepository source name is required")
}
name := args[0]
if sourceGitArgs.url == "" {
@@ -157,15 +170,19 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("git URL scheme '%s' not supported, can be: ssh, http and https", u.Scheme)
}
if sourceGitArgs.branch == "" && sourceGitArgs.tag == "" && sourceGitArgs.semver == "" {
return fmt.Errorf("a Git ref is required, use one of the following: --branch, --tag or --tag-semver")
}
if sourceGitArgs.caFile != "" && u.Scheme == "ssh" {
return fmt.Errorf("specifing a CA file is not supported for Git over SSH")
return fmt.Errorf("specifying a CA file is not supported for Git over SSH")
}
if sourceGitArgs.recurseSubmodules && sourceGitArgs.gitImplementation == sourcev1.LibGit2Implementation {
return fmt.Errorf("recurse submodules requires --git-implementation=%s", sourcev1.GoGitImplementation)
}
tmpDir, err := ioutil.TempDir("", name)
tmpDir, err := os.MkdirTemp("", name)
if err != nil {
return err
}
@@ -176,10 +193,16 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
return err
}
var ignorePaths *string
if len(sourceGitArgs.ignorePaths) > 0 {
ignorePathsStr := strings.Join(sourceGitArgs.ignorePaths, "\n")
ignorePaths = &ignorePathsStr
}
gitRepository := sourcev1.GitRepository{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
Spec: sourcev1.GitRepositorySpec{
@@ -189,9 +212,14 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
},
RecurseSubmodules: sourceGitArgs.recurseSubmodules,
Reference: &sourcev1.GitRepositoryRef{},
Ignore: ignorePaths,
},
}
if createSourceArgs.fetchTimeout > 0 {
gitRepository.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout}
}
if sourceGitArgs.gitImplementation != "" {
gitRepository.Spec.GitImplementation = sourceGitArgs.gitImplementation.String()
}
@@ -217,7 +245,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
@@ -226,7 +254,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
if sourceGitArgs.secretRef == "" {
secretOpts := sourcesecret.Options{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
ManifestFile: sourcesecret.MakeDefaultOptions().ManifestFile,
}
switch u.Scheme {
@@ -236,6 +264,7 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
secretOpts.PrivateKeyAlgorithm = sourcesecret.PrivateKeyAlgorithm(sourceGitArgs.keyAlgorithm)
secretOpts.RSAKeyBits = int(sourceGitArgs.keyRSABits)
secretOpts.ECDSACurve = sourceGitArgs.keyECDSACurve.Curve
secretOpts.Password = sourceGitArgs.password
case "https":
secretOpts.Username = sourceGitArgs.username
secretOpts.Password = sourceGitArgs.password
@@ -259,12 +288,14 @@ func createSourceGitCmdRun(cmd *cobra.Command, args []string) error {
}
if ppk, ok := s.StringData[sourcesecret.PublicKeySecretKey]; ok {
logger.Generatef("deploy key: %s", ppk)
prompt := promptui.Prompt{
Label: "Have you added the deploy key to your repository",
IsConfirm: true,
}
if _, err := prompt.Run(); err != nil {
return fmt.Errorf("aborting")
if !sourceGitArgs.silent {
prompt := promptui.Prompt{
Label: "Have you added the deploy key to your repository",
IsConfirm: true,
}
if _, err := prompt.Run(); err != nil {
return fmt.Errorf("aborting")
}
}
}
logger.Actionf("applying secret with repository credentials")
@@ -337,7 +368,14 @@ func isGitRepositoryReady(ctx context.Context, kubeClient client.Client,
return false, err
}
if c := apimeta.FindStatusCondition(gitRepository.Status.Conditions, meta.ReadyCondition); c != nil {
if c := conditions.Get(gitRepository, meta.ReadyCondition); c != nil {
// Confirm the Ready condition we are observing is for the
// current generation
if c.ObservedGeneration != gitRepository.GetGeneration() {
return false, nil
}
// Further check the Status
switch c.Status {
case metav1.ConditionTrue:
return true, nil

View File

@@ -0,0 +1,196 @@
//go:build unit
// +build unit
/*
Copyright 2021 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 (
"context"
"testing"
"time"
"github.com/fluxcd/pkg/apis/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
"k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/controller-runtime/pkg/client"
)
var pollInterval = 50 * time.Millisecond
var testTimeout = 10 * time.Second
// Update the GitRepository once created to exercise test specific behavior
type reconcileFunc func(repo *sourcev1.GitRepository)
// reconciler waits for an object to be created, then invokes a test supplied
// function to mutate that object, simulating a controller.
// Test should invoke run() to run the background reconciler task which
// polls to wait for the object to exist before applying the update function.
// Any errors from the reconciler are asserted on test completion.
type reconciler struct {
client client.Client
name types.NamespacedName
reconcile reconcileFunc
}
// Start the background task that waits for the object to exist then applies
// the update function.
func (r *reconciler) run(t *testing.T) {
result := make(chan error)
go func() {
defer close(result)
err := wait.PollImmediate(
pollInterval,
testTimeout,
r.conditionFunc)
result <- err
}()
t.Cleanup(func() {
if err := <-result; err != nil {
t.Errorf("Failure from test reconciler: '%v':", err.Error())
}
})
}
// A ConditionFunction that waits for the named GitRepository to be created,
// then sets the ready condition to true.
func (r *reconciler) conditionFunc() (bool, error) {
var repo sourcev1.GitRepository
if err := r.client.Get(context.Background(), r.name, &repo); err != nil {
if errors.IsNotFound(err) {
return false, nil // Keep polling until object is created
}
return true, err
}
r.reconcile(&repo)
err := r.client.Status().Update(context.Background(), &repo)
return true, err
}
func TestCreateSourceGitExport(t *testing.T) {
var command = "create source git podinfo --url=https://github.com/stefanprodan/podinfo --branch=master --ignore-paths .cosign,non-existent-dir/ -n default --interval 1m --export --timeout=" + testTimeout.String()
cases := []struct {
name string
args string
assert assertFunc
}{
{
"ExportSucceeded",
command,
assertGoldenFile("testdata/create_source_git/export.golden"),
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
cmd := cmdTestCase{
args: tc.args,
assert: tc.assert,
}
cmd.runTestCmd(t)
})
}
}
func TestCreateSourceGit(t *testing.T) {
// Default command used for multiple tests
var command = "create source git podinfo --url=https://github.com/stefanprodan/podinfo --branch=master --timeout=" + testTimeout.String()
cases := []struct {
name string
args string
assert assertFunc
reconcile reconcileFunc
}{
{
"NoArgs",
"create source git",
assertError("name is required"),
nil,
}, {
"Succeeded",
command,
assertGoldenFile("testdata/create_source_git/success.golden"),
func(repo *sourcev1.GitRepository) {
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionTrue,
Reason: sourcev1.GitOperationSucceedReason,
Message: "succeeded message",
ObservedGeneration: repo.GetGeneration(),
}
apimeta.SetStatusCondition(&repo.Status.Conditions, newCondition)
repo.Status.Artifact = &sourcev1.Artifact{
Path: "some-path",
Revision: "v1",
}
},
}, {
"Failed",
command,
assertError("failed message"),
func(repo *sourcev1.GitRepository) {
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionFalse,
Reason: sourcev1.URLInvalidReason,
Message: "failed message",
ObservedGeneration: repo.GetGeneration(),
}
apimeta.SetStatusCondition(&repo.Status.Conditions, newCondition)
},
}, {
"NoArtifact",
command,
assertError("GitRepository source reconciliation completed but no artifact was found"),
func(repo *sourcev1.GitRepository) {
// Updated with no artifact
newCondition := metav1.Condition{
Type: meta.ReadyCondition,
Status: metav1.ConditionTrue,
Reason: sourcev1.GitOperationSucceedReason,
Message: "succeeded message",
ObservedGeneration: repo.GetGeneration(),
}
apimeta.SetStatusCondition(&repo.Status.Conditions, newCondition)
},
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
ns := allocateNamespace("podinfo")
setupTestNamespace(ns, t)
if tc.reconcile != nil {
r := reconciler{
client: testEnv.client,
name: types.NamespacedName{Namespace: ns, Name: "podinfo"},
reconcile: tc.reconcile,
}
r.run(t)
}
cmd := cmdTestCase{
args: tc.args + " -n=" + ns,
assert: tc.assert,
}
cmd.runTestCmd(t)
})
}
}

View File

@@ -19,22 +19,21 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"net/url"
"os"
"github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/pkg/runtime/conditions"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/internal/utils"
"github.com/fluxcd/flux2/pkg/manifestgen/sourcesecret"
@@ -45,34 +44,46 @@ var createSourceHelmCmd = &cobra.Command{
Short: "Create or update a HelmRepository source",
Long: `The create source helm command generates a HelmRepository resource and waits for it to fetch the index.
For private Helm repositories, the basic authentication credentials are stored in a Kubernetes secret.`,
Example: ` # Create a source for a public Helm repository
Example: ` # Create a source for an HTTPS public Helm repository
flux create source helm podinfo \
--url=https://stefanprodan.github.io/podinfo \
--interval=10m
# Create a source for a Helm repository using basic authentication
# Create a source for an HTTPS Helm repository using basic authentication
flux create source helm podinfo \
--url=https://stefanprodan.github.io/podinfo \
--username=username \
--password=password
# Create a source for a Helm repository using TLS authentication
# Create a source for an HTTPS Helm repository using TLS authentication
flux create source helm podinfo \
--url=https://stefanprodan.github.io/podinfo \
--cert-file=./cert.crt \
--key-file=./key.crt \
--ca-file=./ca.crt`,
--ca-file=./ca.crt
# Create a source for an OCI Helm repository
flux create source helm podinfo \
--url=oci://ghcr.io/stefanprodan/charts/podinfo
--username=username \
--password=password
# Create a source for an OCI Helm repository using an existing secret with basic auth or dockerconfig credentials
flux create source helm podinfo \
--url=oci://ghcr.io/stefanprodan/charts/podinfo
--secret-ref=docker-config`,
RunE: createSourceHelmCmdRun,
}
type sourceHelmFlags struct {
url string
username string
password string
certFile string
keyFile string
caFile string
secretRef string
url string
username string
password string
certFile string
keyFile string
caFile string
secretRef string
passCredentials bool
}
var sourceHelmArgs sourceHelmFlags
@@ -84,15 +95,13 @@ func init() {
createSourceHelmCmd.Flags().StringVar(&sourceHelmArgs.certFile, "cert-file", "", "TLS authentication cert file path")
createSourceHelmCmd.Flags().StringVar(&sourceHelmArgs.keyFile, "key-file", "", "TLS authentication key file path")
createSourceHelmCmd.Flags().StringVar(&sourceHelmArgs.caFile, "ca-file", "", "TLS authentication CA file path")
createSourceHelmCmd.Flags().StringVarP(&sourceHelmArgs.secretRef, "secret-ref", "", "", "the name of an existing secret containing TLS or basic auth credentials")
createSourceHelmCmd.Flags().StringVarP(&sourceHelmArgs.secretRef, "secret-ref", "", "", "the name of an existing secret containing TLS, basic auth or docker-config credentials")
createSourceHelmCmd.Flags().BoolVarP(&sourceHelmArgs.passCredentials, "pass-credentials", "", false, "pass credentials to all domains")
createSourceCmd.AddCommand(createSourceHelmCmd)
}
func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("HelmRepository source name is required")
}
name := args[0]
if sourceHelmArgs.url == "" {
@@ -104,7 +113,7 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
return err
}
tmpDir, err := ioutil.TempDir("", name)
tmpDir, err := os.MkdirTemp("", name)
if err != nil {
return err
}
@@ -117,7 +126,7 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
helmRepository := &sourcev1.HelmRepository{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
Spec: sourcev1.HelmRepositorySpec{
@@ -128,10 +137,23 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
},
}
url, err := url.Parse(sourceHelmArgs.url)
if err != nil {
return fmt.Errorf("failed to parse URL: %w", err)
}
if url.Scheme == sourcev1.HelmRepositoryTypeOCI {
helmRepository.Spec.Type = sourcev1.HelmRepositoryTypeOCI
}
if createSourceArgs.fetchTimeout > 0 {
helmRepository.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout}
}
if sourceHelmArgs.secretRef != "" {
helmRepository.Spec.SecretRef = &meta.LocalObjectReference{
Name: sourceHelmArgs.secretRef,
}
helmRepository.Spec.PassCredentials = sourceHelmArgs.passCredentials
}
if createArgs.export {
@@ -141,7 +163,7 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
@@ -151,7 +173,7 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
secretName := fmt.Sprintf("helm-%s", name)
secretOpts := sourcesecret.Options{
Name: secretName,
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Username: sourceHelmArgs.username,
Password: sourceHelmArgs.password,
CertFilePath: sourceHelmArgs.certFile,
@@ -175,6 +197,7 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
helmRepository.Spec.SecretRef = &meta.LocalObjectReference{
Name: secretName,
}
helmRepository.Spec.PassCredentials = sourceHelmArgs.passCredentials
logger.Successf("authentication configured")
}
}
@@ -192,6 +215,11 @@ func createSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
}
logger.Successf("HelmRepository source reconciliation completed")
if helmRepository.Spec.Type == sourcev1.HelmRepositoryTypeOCI {
// OCI repos don't expose any artifact so we just return early here
return nil
}
if helmRepository.Status.Artifact == nil {
return fmt.Errorf("HelmRepository source reconciliation completed but no artifact was found")
}
@@ -238,12 +266,14 @@ func isHelmRepositoryReady(ctx context.Context, kubeClient client.Client,
return false, err
}
// Confirm the state we are observing is for the current generation
if helmRepository.Generation != helmRepository.Status.ObservedGeneration {
return false, nil
}
if c := conditions.Get(helmRepository, meta.ReadyCondition); c != nil {
// Confirm the Ready condition we are observing is for the
// current generation
if c.ObservedGeneration != helmRepository.GetGeneration() {
return false, nil
}
if c := apimeta.FindStatusCondition(helmRepository.Status.Conditions, meta.ReadyCondition); c != nil {
// Further check the Status
switch c.Status {
case metav1.ConditionTrue:
return true, nil

View File

@@ -0,0 +1,81 @@
//go:build unit
// +build unit
/*
Copyright 2022 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 (
"testing"
)
func TestCreateSourceHelm(t *testing.T) {
tests := []struct {
name string
args string
resultFile string
assertFunc string
}{
{
name: "no args",
args: "create source helm",
resultFile: "name is required",
assertFunc: "assertError",
},
{
name: "OCI repo",
args: "create source helm podinfo --url=oci://ghcr.io/stefanprodan/charts/podinfo --interval 5m --export",
resultFile: "./testdata/create_source_helm/oci.golden",
assertFunc: "assertGoldenTemplateFile",
},
{
name: "OCI repo with Secret ref",
args: "create source helm podinfo --url=oci://ghcr.io/stefanprodan/charts/podinfo --interval 5m --secret-ref=creds --export",
resultFile: "./testdata/create_source_helm/oci-with-secret.golden",
assertFunc: "assertGoldenTemplateFile",
},
{
name: "HTTPS repo",
args: "create source helm podinfo --url=https://stefanprodan.github.io/charts/podinfo --interval 5m --export",
resultFile: "./testdata/create_source_helm/https.golden",
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)
})
}
}

View File

@@ -0,0 +1,247 @@
/*
Copyright 2022 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 (
"context"
"fmt"
"strings"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/fluxcd/pkg/apis/meta"
"github.com/fluxcd/pkg/runtime/conditions"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/fluxcd/flux2/internal/flags"
"github.com/fluxcd/flux2/internal/utils"
)
var createSourceOCIRepositoryCmd = &cobra.Command{
Use: "oci [name]",
Short: "Create or update an OCIRepository",
Long: `The create source oci command generates an OCIRepository resource and waits for it to be ready.`,
Example: ` # Create an OCIRepository for a public container image
flux create source oci podinfo \
--url=oci://ghcr.io/stefanprodan/manifests/podinfo \
--tag=6.1.6 \
--interval=10m
`,
RunE: createSourceOCIRepositoryCmdRun,
}
type sourceOCIRepositoryFlags struct {
url string
tag string
semver string
digest string
secretRef string
serviceAccount string
certSecretRef string
ignorePaths []string
provider flags.SourceOCIProvider
insecure bool
}
var sourceOCIRepositoryArgs = newSourceOCIFlags()
func newSourceOCIFlags() sourceOCIRepositoryFlags {
return sourceOCIRepositoryFlags{
provider: flags.SourceOCIProvider(sourcev1.GenericOCIProvider),
}
}
func init() {
createSourceOCIRepositoryCmd.Flags().Var(&sourceOCIRepositoryArgs.provider, "provider", sourceOCIRepositoryArgs.provider.Description())
createSourceOCIRepositoryCmd.Flags().StringVar(&sourceOCIRepositoryArgs.url, "url", "", "the OCI repository URL")
createSourceOCIRepositoryCmd.Flags().StringVar(&sourceOCIRepositoryArgs.tag, "tag", "", "the OCI artifact tag")
createSourceOCIRepositoryCmd.Flags().StringVar(&sourceOCIRepositoryArgs.semver, "tag-semver", "", "the OCI artifact tag semver range")
createSourceOCIRepositoryCmd.Flags().StringVar(&sourceOCIRepositoryArgs.digest, "digest", "", "the OCI artifact digest")
createSourceOCIRepositoryCmd.Flags().StringVar(&sourceOCIRepositoryArgs.secretRef, "secret-ref", "", "the name of the Kubernetes image pull secret (type 'kubernetes.io/dockerconfigjson')")
createSourceOCIRepositoryCmd.Flags().StringVar(&sourceOCIRepositoryArgs.serviceAccount, "service-account", "", "the name of the Kubernetes service account that refers to an image pull secret")
createSourceOCIRepositoryCmd.Flags().StringVar(&sourceOCIRepositoryArgs.certSecretRef, "cert-ref", "", "the name of a secret to use for TLS certificates")
createSourceOCIRepositoryCmd.Flags().StringSliceVar(&sourceOCIRepositoryArgs.ignorePaths, "ignore-paths", nil, "set paths to ignore resources (can specify multiple paths with commas: path1,path2)")
createSourceOCIRepositoryCmd.Flags().BoolVar(&sourceOCIRepositoryArgs.insecure, "insecure", false, "for when connecting to a non-TLS registries over plain HTTP")
createSourceCmd.AddCommand(createSourceOCIRepositoryCmd)
}
func createSourceOCIRepositoryCmdRun(cmd *cobra.Command, args []string) error {
name := args[0]
if sourceOCIRepositoryArgs.url == "" {
return fmt.Errorf("url is required")
}
if sourceOCIRepositoryArgs.semver == "" && sourceOCIRepositoryArgs.tag == "" && sourceOCIRepositoryArgs.digest == "" {
return fmt.Errorf("--tag, --tag-semver or --digest is required")
}
sourceLabels, err := parseLabels()
if err != nil {
return err
}
var ignorePaths *string
if len(sourceOCIRepositoryArgs.ignorePaths) > 0 {
ignorePathsStr := strings.Join(sourceOCIRepositoryArgs.ignorePaths, "\n")
ignorePaths = &ignorePathsStr
}
repository := &sourcev1.OCIRepository{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: *kubeconfigArgs.Namespace,
Labels: sourceLabels,
},
Spec: sourcev1.OCIRepositorySpec{
Provider: sourceOCIRepositoryArgs.provider.String(),
URL: sourceOCIRepositoryArgs.url,
Insecure: sourceOCIRepositoryArgs.insecure,
Interval: metav1.Duration{
Duration: createArgs.interval,
},
Reference: &sourcev1.OCIRepositoryRef{},
Ignore: ignorePaths,
},
}
if digest := sourceOCIRepositoryArgs.digest; digest != "" {
repository.Spec.Reference.Digest = digest
}
if semver := sourceOCIRepositoryArgs.semver; semver != "" {
repository.Spec.Reference.SemVer = semver
}
if tag := sourceOCIRepositoryArgs.tag; tag != "" {
repository.Spec.Reference.Tag = tag
}
if createSourceArgs.fetchTimeout > 0 {
repository.Spec.Timeout = &metav1.Duration{Duration: createSourceArgs.fetchTimeout}
}
if saName := sourceOCIRepositoryArgs.serviceAccount; saName != "" {
repository.Spec.ServiceAccountName = saName
}
if secretName := sourceOCIRepositoryArgs.secretRef; secretName != "" {
repository.Spec.SecretRef = &meta.LocalObjectReference{
Name: secretName,
}
}
if secretName := sourceOCIRepositoryArgs.certSecretRef; secretName != "" {
repository.Spec.CertSecretRef = &meta.LocalObjectReference{
Name: secretName,
}
}
if createArgs.export {
return printExport(exportOCIRepository(repository))
}
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
logger.Actionf("applying OCIRepository")
namespacedName, err := upsertOCIRepository(ctx, kubeClient, repository)
if err != nil {
return err
}
logger.Waitingf("waiting for OCIRepository reconciliation")
if err := wait.PollImmediate(rootArgs.pollInterval, rootArgs.timeout,
isOCIRepositoryReady(ctx, kubeClient, namespacedName, repository)); err != nil {
return err
}
logger.Successf("OCIRepository reconciliation completed")
if repository.Status.Artifact == nil {
return fmt.Errorf("no artifact was found")
}
logger.Successf("fetched revision: %s", repository.Status.Artifact.Revision)
return nil
}
func upsertOCIRepository(ctx context.Context, kubeClient client.Client,
ociRepository *sourcev1.OCIRepository) (types.NamespacedName, error) {
namespacedName := types.NamespacedName{
Namespace: ociRepository.GetNamespace(),
Name: ociRepository.GetName(),
}
var existing sourcev1.OCIRepository
err := kubeClient.Get(ctx, namespacedName, &existing)
if err != nil {
if errors.IsNotFound(err) {
if err := kubeClient.Create(ctx, ociRepository); err != nil {
return namespacedName, err
} else {
logger.Successf("OCIRepository created")
return namespacedName, nil
}
}
return namespacedName, err
}
existing.Labels = ociRepository.Labels
existing.Spec = ociRepository.Spec
if err := kubeClient.Update(ctx, &existing); err != nil {
return namespacedName, err
}
ociRepository = &existing
logger.Successf("OCIRepository updated")
return namespacedName, nil
}
func isOCIRepositoryReady(ctx context.Context, kubeClient client.Client,
namespacedName types.NamespacedName, ociRepository *sourcev1.OCIRepository) wait.ConditionFunc {
return func() (bool, error) {
err := kubeClient.Get(ctx, namespacedName, ociRepository)
if err != nil {
return false, err
}
if c := conditions.Get(ociRepository, meta.ReadyCondition); c != nil {
// Confirm the Ready condition we are observing is for the
// current generation
if c.ObservedGeneration != ociRepository.GetGeneration() {
return false, nil
}
// Further check the Status
switch c.Status {
case metav1.ConditionTrue:
return true, nil
case metav1.ConditionFalse:
return false, fmt.Errorf(c.Message)
}
}
return false, nil
}
}

View File

@@ -0,0 +1,61 @@
/*
Copyright 2022 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 (
"testing"
)
func TestCreateSourceOCI(t *testing.T) {
tests := []struct {
name string
args string
assertFunc assertFunc
}{
{
name: "NoArgs",
args: "create source oci",
assertFunc: assertError("name is required"),
},
{
name: "NoURL",
args: "create source oci podinfo",
assertFunc: assertError("url is required"),
},
{
name: "export manifest",
args: "create source oci podinfo --url=oci://ghcr.io/stefanprodan/manifests/podinfo --tag=6.1.6 --interval 10m --export",
assertFunc: assertGoldenFile("./testdata/oci/export.golden"),
},
{
name: "export manifest with secret",
args: "create source oci podinfo --url=oci://ghcr.io/stefanprodan/manifests/podinfo --tag=6.1.6 --interval 10m --secret-ref=creds --export",
assertFunc: assertGoldenFile("./testdata/oci/export_with_secret.golden"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cmd := cmdTestCase{
args: tt.args,
assert: tt.assertFunc,
}
cmd.runTestCmd(t)
})
}
}

View File

@@ -70,9 +70,6 @@ func init() {
}
func createTenantCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("tenant name is required")
}
tenant := args[0]
if err := validation.IsQualifiedName(tenant); len(err) > 0 {
return fmt.Errorf("invalid tenant name '%s': %v", tenant, err)
@@ -148,7 +145,7 @@ func createTenantCmdRun(cmd *cobra.Command, args []string) error {
}
if createArgs.export {
for i, _ := range tenantArgs.namespaces {
for i := range tenantArgs.namespaces {
if err := exportTenant(namespaces[i], accounts[i], roleBindings[i]); err != nil {
return err
}
@@ -159,12 +156,12 @@ func createTenantCmdRun(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
for i, _ := range tenantArgs.namespaces {
for i := range tenantArgs.namespaces {
logger.Actionf("applying namespace %s", namespaces[i].Name)
if err := upsertNamespace(ctx, kubeClient, namespaces[i]); err != nil {
return err

55
cmd/flux/create_test.go Normal file
View File

@@ -0,0 +1,55 @@
package main
import (
"testing"
"k8s.io/apimachinery/pkg/util/rand"
)
func Test_validateObjectName(t *testing.T) {
tests := []struct {
name string
valid bool
}{
{
name: "flux-system",
valid: true,
},
{
name: "-flux-system",
valid: false,
},
{
name: "-flux-system-",
valid: false,
},
{
name: "third.first",
valid: false,
},
{
name: "THirdfirst",
valid: false,
},
{
name: "THirdfirst",
valid: false,
},
{
name: rand.String(63),
valid: true,
},
{
name: rand.String(64),
valid: false,
},
}
for _, tt := range tests {
valid := validateObjectName(tt.name)
if valid != tt.valid {
t.Errorf("expected name %q to return %t for validateObjectName func but got %t",
tt.name, tt.valid, valid)
}
}
}

View File

@@ -60,13 +60,13 @@ func (del deleteCommand) run(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
namespacedName := types.NamespacedName{
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Name: name,
}
@@ -85,7 +85,7 @@ func (del deleteCommand) run(cmd *cobra.Command, args []string) error {
}
}
logger.Actionf("deleting %s %s in %s namespace", del.humanKind, name, rootArgs.namespace)
logger.Actionf("deleting %s %s in %s namespace", del.humanKind, name, *kubeconfigArgs.Namespace)
err = kubeClient.Delete(ctx, del.object.asClientObject())
if err != nil {
return err

View File

@@ -28,6 +28,7 @@ var deleteAlertCmd = &cobra.Command{
Long: "The delete alert command removes the given Alert from the cluster.",
Example: ` # Delete an Alert and the Kubernetes resources created by it
flux delete alert main`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.AlertKind)),
RunE: deleteCommand{
apiType: alertType,
object: universalAdapter{&notificationv1.Alert{}},

View File

@@ -28,6 +28,7 @@ var deleteAlertProviderCmd = &cobra.Command{
Long: "The delete alert-provider command removes the given Provider from the cluster.",
Example: ` # Delete a Provider and the Kubernetes resources created by it
flux delete alert-provider slack`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ProviderKind)),
RunE: deleteCommand{
apiType: alertProviderType,
object: universalAdapter{&notificationv1.Provider{}},

View File

@@ -29,6 +29,7 @@ var deleteHelmReleaseCmd = &cobra.Command{
Long: "The delete helmrelease command removes the given HelmRelease from the cluster.",
Example: ` # Delete a Helm release and the Kubernetes resources created by it
flux delete hr podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
RunE: deleteCommand{
apiType: helmReleaseType,
object: universalAdapter{&helmv2.HelmRelease{}},

View File

@@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta1"
)
var deleteImagePolicyCmd = &cobra.Command{
@@ -28,6 +28,7 @@ var deleteImagePolicyCmd = &cobra.Command{
Long: "The delete image policy command deletes the given ImagePolicy from the cluster.",
Example: ` # Delete an image policy
flux delete image policy alpine3.x`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImagePolicyKind)),
RunE: deleteCommand{
apiType: imagePolicyType,
object: universalAdapter{&imagev1.ImagePolicy{}},

View File

@@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta1"
)
var deleteImageRepositoryCmd = &cobra.Command{
@@ -28,6 +28,7 @@ var deleteImageRepositoryCmd = &cobra.Command{
Long: "The delete image repository command deletes the given ImageRepository from the cluster.",
Example: ` # Delete an image repository
flux delete image repository alpine`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)),
RunE: deleteCommand{
apiType: imageRepositoryType,
object: universalAdapter{&imagev1.ImageRepository{}},

View File

@@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
autov1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
)
var deleteImageUpdateCmd = &cobra.Command{
@@ -28,6 +28,7 @@ var deleteImageUpdateCmd = &cobra.Command{
Long: "The delete image update command deletes the given ImageUpdateAutomation from the cluster.",
Example: ` # Delete an image update automation
flux delete image update latest-images`,
ValidArgsFunction: resourceNamesCompletionFunc(autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)),
RunE: deleteCommand{
apiType: imageUpdateAutomationType,
object: universalAdapter{&autov1.ImageUpdateAutomation{}},

View File

@@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta1"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
)
var deleteKsCmd = &cobra.Command{
@@ -27,8 +27,9 @@ var deleteKsCmd = &cobra.Command{
Aliases: []string{"ks"},
Short: "Delete a Kustomization resource",
Long: "The delete kustomization command deletes the given Kustomization from the cluster.",
Example: ` # Delete a kustomization and the Kubernetes resources created by it
Example: ` # Delete a kustomization and the Kubernetes resources created by it when prune is enabled
flux delete kustomization podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
RunE: deleteCommand{
apiType: kustomizationType,
object: universalAdapter{&kustomizev1.Kustomization{}},

View File

@@ -28,6 +28,7 @@ var deleteReceiverCmd = &cobra.Command{
Long: "The delete receiver command removes the given Receiver from the cluster.",
Example: ` # Delete an Receiver and the Kubernetes resources created by it
flux delete receiver main`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ReceiverKind)),
RunE: deleteCommand{
apiType: receiverType,
object: universalAdapter{&notificationv1.Receiver{}},

View File

@@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
)
var deleteSourceBucketCmd = &cobra.Command{
@@ -28,6 +28,7 @@ var deleteSourceBucketCmd = &cobra.Command{
Long: "The delete source bucket command deletes the given Bucket from the cluster.",
Example: ` # Delete a Bucket source
flux delete source bucket podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.BucketKind)),
RunE: deleteCommand{
apiType: bucketType,
object: universalAdapter{&sourcev1.Bucket{}},

View File

@@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
)
var deleteSourceGitCmd = &cobra.Command{
@@ -28,6 +28,7 @@ var deleteSourceGitCmd = &cobra.Command{
Long: "The delete source git command deletes the given GitRepository from the cluster.",
Example: ` # Delete a Git repository
flux delete source git podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.GitRepositoryKind)),
RunE: deleteCommand{
apiType: gitRepositoryType,
object: universalAdapter{&sourcev1.GitRepository{}},

View File

@@ -19,7 +19,7 @@ package main
import (
"github.com/spf13/cobra"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
)
var deleteSourceHelmCmd = &cobra.Command{
@@ -28,6 +28,7 @@ var deleteSourceHelmCmd = &cobra.Command{
Long: "The delete source helm command deletes the given HelmRepository from the cluster.",
Example: ` # Delete a Helm repository
flux delete source helm podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.HelmRepositoryKind)),
RunE: deleteCommand{
apiType: helmRepositoryType,
object: universalAdapter{&sourcev1.HelmRepository{}},

View File

@@ -0,0 +1,40 @@
/*
Copyright 2022 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"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
)
var deleteSourceOCIRepositoryCmd = &cobra.Command{
Use: "oci [name]",
Short: "Delete an OCIRepository source",
Long: "The delete source oci command deletes the given OCIRepository from the cluster.",
Example: ` # Delete an OCIRepository
flux delete source oci podinfo`,
ValidArgsFunction: resourceNamesCompletionFunc(sourcev1.GroupVersion.WithKind(sourcev1.OCIRepositoryKind)),
RunE: deleteCommand{
apiType: ociRepositoryType,
object: universalAdapter{&sourcev1.OCIRepository{}},
}.run,
}
func init() {
deleteSourceCmd.AddCommand(deleteSourceOCIRepositoryCmd)
}

31
cmd/flux/diff.go Normal file
View File

@@ -0,0 +1,31 @@
/*
Copyright 2021 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"
)
var diffCmd = &cobra.Command{
Use: "diff",
Short: "Diff a flux resource",
Long: "The diff command is used to do a server-side dry-run on flux resources, then prints the diff.",
}
func init() {
rootCmd.AddCommand(diffCmd)
}

111
cmd/flux/diff_artifact.go Normal file
View File

@@ -0,0 +1,111 @@
/*
Copyright 2022 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 (
"context"
"fmt"
"os"
"github.com/fluxcd/flux2/internal/flags"
oci "github.com/fluxcd/pkg/oci/client"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/spf13/cobra"
)
var diffArtifactCmd = &cobra.Command{
Use: "artifact",
Short: "Diff Artifact",
Long: `The diff artifact command computes the diff between the remote OCI artifact and a local directory or file`,
Example: `# Check if local files differ from remote
flux diff artifact oci://ghcr.io/stefanprodan/manifests:podinfo:6.2.0 --path=./kustomize`,
RunE: diffArtifactCmdRun,
}
type diffArtifactFlags struct {
path string
creds string
provider flags.SourceOCIProvider
ignorePaths []string
}
var diffArtifactArgs = newDiffArtifactArgs()
func newDiffArtifactArgs() diffArtifactFlags {
return diffArtifactFlags{
provider: flags.SourceOCIProvider(sourcev1.GenericOCIProvider),
}
}
func init() {
diffArtifactCmd.Flags().StringVar(&diffArtifactArgs.path, "path", "", "path to the directory where the Kubernetes manifests are located")
diffArtifactCmd.Flags().StringVar(&diffArtifactArgs.creds, "creds", "", "credentials for OCI registry in the format <username>[:<password>] if --provider is generic")
diffArtifactCmd.Flags().Var(&diffArtifactArgs.provider, "provider", sourceOCIRepositoryArgs.provider.Description())
diffArtifactCmd.Flags().StringSliceVar(&diffArtifactArgs.ignorePaths, "ignore-paths", excludeOCI, "set paths to ignore in .gitignore format")
diffCmd.AddCommand(diffArtifactCmd)
}
func diffArtifactCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("artifact URL is required")
}
ociURL := args[0]
if diffArtifactArgs.path == "" {
return fmt.Errorf("invalid path %q", diffArtifactArgs.path)
}
url, err := oci.ParseArtifactURL(ociURL)
if err != nil {
return err
}
if _, err := os.Stat(diffArtifactArgs.path); err != nil {
return fmt.Errorf("invalid path '%s', must point to an existing directory or file", diffArtifactArgs.path)
}
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
ociClient := oci.NewLocalClient()
if diffArtifactArgs.provider.String() == sourcev1.GenericOCIProvider && diffArtifactArgs.creds != "" {
logger.Actionf("logging in to registry with credentials")
if err := ociClient.LoginWithCredentials(diffArtifactArgs.creds); err != nil {
return fmt.Errorf("could not login with credentials: %w", err)
}
}
if diffArtifactArgs.provider.String() != sourcev1.GenericOCIProvider {
logger.Actionf("logging in to registry with provider credentials")
ociProvider, err := diffArtifactArgs.provider.ToOCIProvider()
if err != nil {
return fmt.Errorf("provider not supported: %w", err)
}
if err := ociClient.LoginWithProvider(ctx, url, ociProvider); err != nil {
return fmt.Errorf("error during login with provider: %w", err)
}
}
if err := ociClient.Diff(ctx, url, diffArtifactArgs.path, diffArtifactArgs.ignorePaths); err != nil {
return err
}
logger.Successf("no changes detected")
return nil
}

View File

@@ -0,0 +1,109 @@
//go:build unit
// +build unit
/*
Copyright 2021 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 (
"context"
"fmt"
"testing"
"time"
"github.com/distribution/distribution/v3/configuration"
"github.com/distribution/distribution/v3/registry"
_ "github.com/distribution/distribution/v3/registry/auth/htpasswd"
_ "github.com/distribution/distribution/v3/registry/storage/driver/inmemory"
"github.com/phayes/freeport"
ctrl "sigs.k8s.io/controller-runtime"
)
var dockerReg string
func setupRegistryServer(ctx context.Context) error {
// Registry config
config := &configuration.Configuration{}
port, err := freeport.GetFreePort()
if err != nil {
return fmt.Errorf("failed to get free port: %s", err)
}
dockerReg = fmt.Sprintf("localhost:%d", port)
config.HTTP.Addr = fmt.Sprintf("127.0.0.1:%d", port)
config.HTTP.DrainTimeout = time.Duration(10) * time.Second
config.Storage = map[string]configuration.Parameters{"inmemory": map[string]interface{}{}}
dockerRegistry, err := registry.NewRegistry(ctx, config)
if err != nil {
return fmt.Errorf("failed to create docker registry: %w", err)
}
// Start Docker registry
go dockerRegistry.ListenAndServe()
return nil
}
func TestDiffArtifact(t *testing.T) {
tests := []struct {
name string
url string
argsTpl string
pushFile string
diffFile string
assert assertFunc
}{
{
name: "should not fail if there is no diff",
url: "oci://%s/podinfo:1.0.0",
argsTpl: "diff artifact %s --path=%s",
pushFile: "./testdata/diff-artifact/deployment.yaml",
diffFile: "./testdata/diff-artifact/deployment.yaml",
assert: assertGoldenFile("testdata/diff-artifact/success.golden"),
},
{
name: "should fail if there is a diff",
url: "oci://%s/podinfo:2.0.0",
argsTpl: "diff artifact %s --path=%s",
pushFile: "./testdata/diff-artifact/deployment.yaml",
diffFile: "./testdata/diff-artifact/deployment-diff.yaml",
assert: assertError("the remote artifact contents differs from the local one"),
},
}
ctx := ctrl.SetupSignalHandler()
err := setupRegistryServer(ctx)
if err != nil {
panic(fmt.Sprintf("failed to start docker registry: %s", err))
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.url = fmt.Sprintf(tt.url, dockerReg)
_, err := executeCommand("push artifact " + tt.url + " --path=" + tt.pushFile + " --source=test --revision=test")
if err != nil {
t.Fatalf(fmt.Errorf("failed to push image: %w", err).Error())
}
cmd := cmdTestCase{
args: fmt.Sprintf(tt.argsTpl, tt.url, tt.diffFile),
assert: tt.assert,
}
cmd.runTestCmd(t)
})
}
}

View File

@@ -0,0 +1,124 @@
/*
Copyright 2021 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"
"os"
"os/signal"
"github.com/spf13/cobra"
"github.com/fluxcd/flux2/internal/build"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
)
var diffKsCmd = &cobra.Command{
Use: "kustomization",
Aliases: []string{"ks"},
Short: "Diff Kustomization",
Long: `The diff command does a build, then it performs a server-side dry-run and prints the diff.
Exit status: 0 No differences were found. 1 Differences were found. >1 diff failed with an error.`,
Example: `# Preview local changes as they were applied on the cluster
flux diff kustomization my-app --path ./path/to/local/manifests
# Preview using a local flux kustomization file
flux diff kustomization my-app --path ./path/to/local/manifests --kustomization-file ./path/to/local/my-app.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
RunE: diffKsCmdRun,
}
type diffKsFlags struct {
kustomizationFile string
path string
progressBar bool
}
var diffKsArgs diffKsFlags
func init() {
diffKsCmd.Flags().StringVar(&diffKsArgs.path, "path", "", "Path to a local directory that matches the specified Kustomization.spec.path.")
diffKsCmd.Flags().BoolVar(&diffKsArgs.progressBar, "progress-bar", true, "Boolean to set the progress bar. The default value is true.")
diffKsCmd.Flags().StringVar(&diffKsArgs.kustomizationFile, "kustomization-file", "", "Path to the Flux Kustomization YAML file.")
diffCmd.AddCommand(diffKsCmd)
}
func diffKsCmdRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf("%s name is required", kustomizationType.humanKind)
}
name := args[0]
if diffKsArgs.path == "" {
return &RequestError{StatusCode: 2, Err: fmt.Errorf("invalid resource path %q", diffKsArgs.path)}
}
if fs, err := os.Stat(diffKsArgs.path); err != nil || !fs.IsDir() {
return &RequestError{StatusCode: 2, Err: fmt.Errorf("invalid resource path %q", diffKsArgs.path)}
}
if diffKsArgs.kustomizationFile != "" {
if fs, err := os.Stat(diffKsArgs.kustomizationFile); os.IsNotExist(err) || fs.IsDir() {
return fmt.Errorf("invalid kustomization file %q", diffKsArgs.kustomizationFile)
}
}
var builder *build.Builder
var err error
if diffKsArgs.progressBar {
builder, err = build.NewBuilder(kubeconfigArgs, kubeclientOptions, name, diffKsArgs.path, build.WithTimeout(rootArgs.timeout), build.WithKustomizationFile(diffKsArgs.kustomizationFile), build.WithProgressBar())
} else {
builder, err = build.NewBuilder(kubeconfigArgs, kubeclientOptions, name, diffKsArgs.path, build.WithTimeout(rootArgs.timeout), build.WithKustomizationFile(diffKsArgs.kustomizationFile))
}
if err != nil {
return &RequestError{StatusCode: 2, Err: err}
}
// create a signal channel
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, os.Interrupt)
errChan := make(chan error)
go func() {
output, hasChanged, err := builder.Diff()
if err != nil {
errChan <- &RequestError{StatusCode: 2, Err: err}
}
cmd.Print(output)
if hasChanged {
errChan <- &RequestError{StatusCode: 1, Err: fmt.Errorf("identified at least one change, exiting with non-zero exit code")}
} else {
errChan <- nil
}
}()
select {
case <-sigc:
fmt.Println("Build cancelled... exiting.")
return builder.Cancel()
case err := <-errChan:
if err != nil {
return err
}
}
return nil
}

View File

@@ -0,0 +1,145 @@
//go:build unit
// +build unit
/*
Copyright 2021 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 (
"context"
"os"
"strings"
"testing"
"github.com/fluxcd/flux2/internal/build"
"github.com/fluxcd/pkg/ssa"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
func TestDiffKustomization(t *testing.T) {
tests := []struct {
name string
args string
objectFile string
assert assertFunc
}{
{
name: "no args",
args: "diff kustomization podinfo",
objectFile: "",
assert: assertError("invalid resource path \"\""),
},
{
name: "diff nothing deployed",
args: "diff kustomization podinfo --path ./testdata/build-kustomization/podinfo --progress-bar=false",
objectFile: "",
assert: assertGoldenFile("./testdata/diff-kustomization/nothing-is-deployed.golden"),
},
{
name: "diff with a deployment object",
args: "diff kustomization podinfo --path ./testdata/build-kustomization/podinfo --progress-bar=false",
objectFile: "./testdata/diff-kustomization/deployment.yaml",
assert: assertGoldenFile("./testdata/diff-kustomization/diff-with-deployment.golden"),
},
{
name: "diff with a drifted service object",
args: "diff kustomization podinfo --path ./testdata/build-kustomization/podinfo --progress-bar=false",
objectFile: "./testdata/diff-kustomization/service.yaml",
assert: assertGoldenFile("./testdata/diff-kustomization/diff-with-drifted-service.golden"),
},
{
name: "diff with a drifted secret object",
args: "diff kustomization podinfo --path ./testdata/build-kustomization/podinfo --progress-bar=false",
objectFile: "./testdata/diff-kustomization/secret.yaml",
assert: assertGoldenFile("./testdata/diff-kustomization/diff-with-drifted-secret.golden"),
},
{
name: "diff with a drifted key in sops secret object",
args: "diff kustomization podinfo --path ./testdata/build-kustomization/podinfo --progress-bar=false",
objectFile: "./testdata/diff-kustomization/key-sops-secret.yaml",
assert: assertGoldenFile("./testdata/diff-kustomization/diff-with-drifted-key-sops-secret.golden"),
},
{
name: "diff with a drifted value in sops secret object",
args: "diff kustomization podinfo --path ./testdata/build-kustomization/podinfo --progress-bar=false",
objectFile: "./testdata/diff-kustomization/value-sops-secret.yaml",
assert: assertGoldenFile("./testdata/diff-kustomization/diff-with-drifted-value-sops-secret.golden"),
},
{
name: "diff with a sops dockerconfigjson secret object",
args: "diff kustomization podinfo --path ./testdata/build-kustomization/podinfo --progress-bar=false",
objectFile: "./testdata/diff-kustomization/dockerconfigjson-sops-secret.yaml",
assert: assertGoldenFile("./testdata/diff-kustomization/diff-with-dockerconfigjson-sops-secret.golden"),
},
{
name: "diff with a sops stringdata secret object",
args: "diff kustomization podinfo --path ./testdata/build-kustomization/podinfo --progress-bar=false",
objectFile: "./testdata/diff-kustomization/stringdata-sops-secret.yaml",
assert: assertGoldenFile("./testdata/diff-kustomization/diff-with-drifted-stringdata-sops-secret.golden"),
},
}
tmpl := map[string]string{
"fluxns": allocateNamespace("flux-system"),
}
b, _ := build.NewBuilder(kubeconfigArgs, kubeclientOptions, "podinfo", "")
resourceManager, err := b.Manager()
if err != nil {
t.Fatal(err)
}
setup(t, tmpl)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.objectFile != "" {
resourceManager.ApplyAll(context.Background(), createObjectFromFile(tt.objectFile, tmpl, t), ssa.DefaultApplyOptions())
}
cmd := cmdTestCase{
args: tt.args + " -n " + tmpl["fluxns"],
assert: tt.assert,
}
cmd.runTestCmd(t)
if tt.objectFile != "" {
testEnv.DeleteObjectFile(tt.objectFile, tmpl, t)
}
})
}
}
func createObjectFromFile(objectFile string, templateValues map[string]string, t *testing.T) []*unstructured.Unstructured {
buf, err := os.ReadFile(objectFile)
if err != nil {
t.Fatalf("Error reading file '%s': %v", objectFile, err)
}
content, err := executeTemplate(string(buf), templateValues)
if err != nil {
t.Fatalf("Error evaluating template file '%s': '%v'", objectFile, err)
}
clientObjects, err := readYamlObjects(strings.NewReader(content))
if err != nil {
t.Fatalf("Error decoding yaml file '%s': %v", objectFile, err)
}
if err := ssa.SetNativeKindsDefaults(clientObjects); err != nil {
t.Fatalf("Error setting native kinds defaults for '%s': %v", objectFile, err)
}
return clientObjects
}

View File

@@ -59,7 +59,7 @@ func docgenCmdRun(cmd *cobra.Command, args []string) error {
func frontmatterPrepender(filename string) string {
name := filepath.Base(filename)
base := strings.TrimSuffix(name, path.Ext(name))
title := strings.Replace(base, "_", " ", -1) + " command"
title := strings.Replace(base, "_", " ", -1)
return fmt.Sprintf(fmTemplate, title)
}

View File

@@ -20,6 +20,7 @@ import (
"bytes"
"context"
"fmt"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -73,19 +74,19 @@ func (export exportCommand) run(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()
kubeClient, err := utils.KubeClient(rootArgs.kubeconfig, rootArgs.kubecontext)
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
if err != nil {
return err
}
if exportArgs.all {
err = kubeClient.List(ctx, export.list.asClientList(), client.InNamespace(rootArgs.namespace))
err = kubeClient.List(ctx, export.list.asClientList(), client.InNamespace(*kubeconfigArgs.Namespace))
if err != nil {
return err
}
if export.list.len() == 0 {
return fmt.Errorf("no objects found in %s namespace", rootArgs.namespace)
return fmt.Errorf("no objects found in %s namespace", *kubeconfigArgs.Namespace)
}
for i := 0; i < export.list.len(); i++ {
@@ -96,7 +97,7 @@ func (export exportCommand) run(cmd *cobra.Command, args []string) error {
} else {
name := args[0]
namespacedName := types.NamespacedName{
Namespace: rootArgs.namespace,
Namespace: *kubeconfigArgs.Namespace,
Name: name,
}
err = kubeClient.Get(ctx, namespacedName, export.object.asClientObject())
@@ -113,8 +114,8 @@ func printExport(export interface{}) error {
if err != nil {
return err
}
fmt.Println("---")
fmt.Println(resourceToString(data))
rootCmd.Println("---")
rootCmd.Println(resourceToString(data))
return nil
}

View File

@@ -32,6 +32,7 @@ var exportAlertCmd = &cobra.Command{
# Export a Alert
flux export alert main > main.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.AlertKind)),
RunE: exportCommand{
object: alertAdapter{&notificationv1.Alert{}},
list: alertListAdapter{&notificationv1.AlertList{}},

View File

@@ -32,6 +32,7 @@ var exportAlertProviderCmd = &cobra.Command{
# Export a Provider
flux export alert-provider slack > slack.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(notificationv1.GroupVersion.WithKind(notificationv1.ProviderKind)),
RunE: exportCommand{
object: alertProviderAdapter{&notificationv1.Provider{}},
list: alertProviderListAdapter{&notificationv1.ProviderList{}},

View File

@@ -33,6 +33,7 @@ var exportHelmReleaseCmd = &cobra.Command{
# Export a HelmRelease
flux export hr my-app > app-release.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(helmv2.GroupVersion.WithKind(helmv2.HelmReleaseKind)),
RunE: exportCommand{
object: helmReleaseAdapter{&helmv2.HelmRelease{}},
list: helmReleaseListAdapter{&helmv2.HelmReleaseList{}},

View File

@@ -20,7 +20,7 @@ import (
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta1"
)
var exportImagePolicyCmd = &cobra.Command{
@@ -32,6 +32,7 @@ var exportImagePolicyCmd = &cobra.Command{
# Export a specific policy
flux export image policy alpine1x > alpine1x.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImagePolicyKind)),
RunE: exportCommand{
object: imagePolicyAdapter{&imagev1.ImagePolicy{}},
list: imagePolicyListAdapter{&imagev1.ImagePolicyList{}},

View File

@@ -20,7 +20,7 @@ import (
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1alpha1"
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta1"
)
var exportImageRepositoryCmd = &cobra.Command{
@@ -32,6 +32,7 @@ var exportImageRepositoryCmd = &cobra.Command{
# Export a specific ImageRepository resource
flux export image repository alpine > alpine.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(imagev1.GroupVersion.WithKind(imagev1.ImageRepositoryKind)),
RunE: exportCommand{
object: imageRepositoryAdapter{&imagev1.ImageRepository{}},
list: imageRepositoryListAdapter{&imagev1.ImageRepositoryList{}},

View File

@@ -20,7 +20,7 @@ import (
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
autov1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
)
var exportImageUpdateCmd = &cobra.Command{
@@ -32,6 +32,7 @@ var exportImageUpdateCmd = &cobra.Command{
# Export a specific automation
flux export image update latest-images > latest.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(autov1.GroupVersion.WithKind(autov1.ImageUpdateAutomationKind)),
RunE: exportCommand{
object: imageUpdateAutomationAdapter{&autov1.ImageUpdateAutomation{}},
list: imageUpdateAutomationListAdapter{&autov1.ImageUpdateAutomationList{}},

View File

@@ -20,7 +20,7 @@ import (
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta1"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1beta2"
)
var exportKsCmd = &cobra.Command{
@@ -33,6 +33,7 @@ var exportKsCmd = &cobra.Command{
# Export a Kustomization
flux export kustomization my-app > kustomization.yaml`,
ValidArgsFunction: resourceNamesCompletionFunc(kustomizev1.GroupVersion.WithKind(kustomizev1.KustomizationKind)),
RunE: exportCommand{
object: kustomizationAdapter{&kustomizev1.Kustomization{}},
list: kustomizationListAdapter{&kustomizev1.KustomizationList{}},

Some files were not shown because too many files have changed in this diff Show More