Skip to content

Commit

Permalink
fix comments and trim down crd
Browse files Browse the repository at this point in the history
Signed-off-by: Somtochi Onyekwere <[email protected]>
  • Loading branch information
somtochiama committed Oct 19, 2023
1 parent 32e9be6 commit e052adb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 783 deletions.
25 changes: 15 additions & 10 deletions cmd/flux/cluster_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,36 @@ package main
import (
"context"
"fmt"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
)

// bootstrapLabels are labels put on a resource by kustomize-controller. These labels on the CRD indicates
// that flux has been bootstrapped.
var bootstrapLabels = []string{"kustomize.toolkit.fluxcd.io/name", "kustomize.toolkit.fluxcd.io/namespace"}
var bootstrapLabels = []string{
fmt.Sprintf("%s/name", kustomizev1.GroupVersion.Group),
fmt.Sprintf("%s/namespace", kustomizev1.GroupVersion.Group),
}

// fluxClusterInfo contains information about an existing flux installation on a cluster.
type fluxClusterInfo struct {
// crdBootstrapped indicates if flux was installed using the `flux bootstrap` command.
// bootstrapped indicates if flux was installed using the `flux bootstrap` command.
bootstrapped bool
// managedBy contains the manager of the installation
// managedBy is the manager of the installation
managedBy string
// version contains the flux version of the installation.
// version is the flux version of the installation.
version string
}

// gatherPreflightInfo checks the GitRepository CRD for labels passed into the function. It returns the version of flux
// (from the app.kubernetes.io/version labels), a boolean to indicate whether the CRD was found
// with the specified labels and an error.
// getFluxClusterInfo checks the GitRepository CRD for labels passed into the function. It returns the version of Flux
// (from the app.kubernetes.io/version label), a boolean to indicate whether the CRD was found
// with the required labels and an error if the CRD query failed.
func getFluxClusterInfo(ctx context.Context, c client.Client) (fluxClusterInfo, bool, error) {
var info fluxClusterInfo
crdMetadata := &metav1.PartialObjectMetadata{
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/cluster_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/fluxcd/pkg/ssa"
)

func Test_gatherPreflightInfo(t *testing.T) {
func Test_getFluxClusterInfo(t *testing.T) {
g := NewWithT(t)
f, err := os.Open("./testdata/cluster_info/gitrepositories.yaml")
g.Expect(err).To(BeNil())
Expand Down
Loading

0 comments on commit e052adb

Please sign in to comment.