Skip to content

Commit

Permalink
Big Bang extension flux api version update (#1933)
Browse files Browse the repository at this point in the history
## Description

Updates the Flux GitRepo version to v1.

Not sure if this is the right/desired fix or if this should be more
backwards compatible (similar to the way credentials are handled for BB
1/2.

## Related Issue

Fixes #1932

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging

- [x] Test, docs, adr added or updated as needed
- [x] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed

---------

Co-authored-by: Wayne Starr <Racer159@users.noreply.github.com>
Co-authored-by: razzle <harry@razzle.cloud>
Co-authored-by: Case Wylie <cmwylie19@defenseunicorns.com>
  • Loading branch information
4 people authored Aug 8, 2023
1 parent 52c76d6 commit ca6546b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/zarf-agent/manifests/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ webhooks:
apiVersions:
- "v1beta1"
- "v1beta2"
- "v1"
resources:
- "gitrepositories"
admissionReviewVersions:
Expand Down
18 changes: 16 additions & 2 deletions src/extensions/bigbang/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/Masterminds/semver/v3"
"github.com/defenseunicorns/zarf/src/types/extensions"
fluxHelmCtrl "github.com/fluxcd/helm-controller/api/v2beta1"
fluxSrcCtrl "github.com/fluxcd/source-controller/api/v1beta2"
fluxSrcCtrl "github.com/fluxcd/source-controller/api/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -88,10 +88,24 @@ func manifestZarfCredentials(version string) corev1.Secret {

// manifestGitRepo generates a GitRepository object for the Big Bang umbrella repo.
func manifestGitRepo(cfg *extensions.BigBang) fluxSrcCtrl.GitRepository {
apiVersion := "source.toolkit.fluxcd.io/v1beta2"

// Set apiVersion to v1 on BB v2.7.0 or higher falling back to v1beta2 as needed
semverVersion, _ := semver.NewVersion(cfg.Version)
if semverVersion != nil {
c, _ := semver.NewConstraint(">= 2.7.0")
if c != nil {
updateFlux, _ := c.Validate(semverVersion)
if updateFlux && !cfg.SkipFlux {
apiVersion = "source.toolkit.fluxcd.io/v1"
}
}
}

return fluxSrcCtrl.GitRepository{
TypeMeta: metav1.TypeMeta{
Kind: fluxSrcCtrl.GitRepositoryKind,
APIVersion: "source.toolkit.fluxcd.io/v1beta2",
APIVersion: apiVersion,
},
ObjectMeta: metav1.ObjectMeta{
Name: bb,
Expand Down

0 comments on commit ca6546b

Please sign in to comment.