Skip to content

Commit

Permalink
Make it more visible that dashboards are only for openshift
Browse files Browse the repository at this point in the history
  • Loading branch information
jotak committed Aug 31, 2023
1 parent 8151222 commit 90498ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func NewInfo(dcl *discovery.DiscoveryClient) (Info, error) {
}

func (c *Info) CheckClusterInfo(ctx context.Context, cl client.Client) error {
if c.HasOCPSecurity() && !c.fetchedClusterVersion {
// Assumes having openshift security <=> being on openshift
if c.IsOpenShift() && !c.fetchedClusterVersion {
if err := c.fetchOpenShiftClusterVersion(ctx, cl); err != nil {
return err
}
Expand Down Expand Up @@ -114,6 +113,11 @@ func (c *Info) OpenShiftVersionIsAtLeast(v string) (bool, error) {
return !c.openShiftVersion.LessThan(*version), nil
}

// IsOpenShift assumes having openshift SCC API <=> being on openshift
func (c *Info) IsOpenShift() bool {
return c.HasOCPSecurity()
}

// HasOCPSecurity returns true if "securitycontextconstraints.security.openshift.io" API was found
func (c *Info) HasOCPSecurity() bool {
return c.apisMap[ocpSecurity]
Expand Down
4 changes: 3 additions & 1 deletion pkg/cluster/dashboards_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ func NewDashboards() Dashboards {
}
}

// CheckClusterDashboards sets the available dashboards based on OpenShift version.
// This function shouldn't be called in non-OpenShift context.
func (d *Dashboards) CheckClusterDashboards(ctx context.Context, clusterInfo *Info) {
if ok, err := clusterInfo.OpenShiftVersionIsAtLeast("4.15.0"); err != nil {
// Log error but do not fail: it's likely a bug in code, if the openshift version cannot be found
log.FromContext(ctx).Error(err, "Could not get available dashboards for this cluster version. Is it OpenShift?")
log.FromContext(ctx).Error(err, "Could not get available dashboards for this cluster version.")
} else if ok {
d.SetAvailable(constants.IngressDashboardCMName)
d.SetAvailable(constants.NetStatsDashboardCMName)
Expand Down

0 comments on commit 90498ef

Please sign in to comment.