Skip to content

Commit

Permalink
fix comments and error msg
Browse files Browse the repository at this point in the history
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
  • Loading branch information
somtochiama committed Oct 20, 2023
1 parent 087e94a commit 0f925c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions cmd/flux/cluster_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,18 @@ var bootstrapLabels = []string{
type fluxClusterInfo struct {
// bootstrapped indicates that Flux was installed using the `flux bootstrap` command.
bootstrapped bool
// managedBy is the name of the manager who installed Flux.
// managedBy is the name of the tool being used to manage the installation of Flux.
managedBy string
// version is the Flux version number in semver format.
version string
}

// 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.
// getFluxClusterInfo returns information on the Flux installation running on the cluster.
// If the information cannot be retrieved, the boolean return value will be false.
// If an error occurred, the returned error will be non-nil.
//
// This function retrieves the GitRepository CRD from the cluster and checks it
// for a set of labels used to determine the Flux version and how Flux was installed.
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/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {

info, installed, err := getFluxClusterInfo(ctx, kubeClient)
if err != nil {
return fmt.Errorf("error checking for exisiting flux installation: %w", err)
return fmt.Errorf("cluster info unavailable: %w", err)
}

if installed && info.bootstrapped {
Expand Down

0 comments on commit 0f925c6

Please sign in to comment.