Skip to content

Commit

Permalink
add condition badges support
Browse files Browse the repository at this point in the history
This change adds a new interface function to the Resource type so that
conditions can be exposed in the accordion views. When present, the
conditions are show as badges in the accordion button header.
  • Loading branch information
elmiko committed Jul 12, 2024
1 parent 0de53d9 commit ba1b010
Show file tree
Hide file tree
Showing 9 changed files with 728 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,25 @@ fn add_accordion_section(
(_, true) => " bg-danger text-white",
_ => "",
};
itemdiv
let mut itemh2 = itemdiv
.h2()
.attr("class=\"accordion-header\"")
.attr(format!("id=\"heading-{}\"", &resuuid.hyphenated()).as_str())
.attr(format!("id=\"heading-{}\"", &resuuid.hyphenated()).as_str());
let mut itembutton = itemh2
.button()
.attr(format!("class=\"accordion-button collapsed p-2{}\"", buttonclass).as_str())
.attr("type=\"button\"")
.attr("data-bs-toggle=\"collapse\"")
.attr(format!("data-bs-target=\"#collapse-{}\"", &resuuid.hyphenated()).as_str())
.attr("aria-exapnded=\"false\"")
.attr(format!("aria-controls=\"collapse-{}\"", &resuuid.hyphenated()).as_str())
.write_str(res.name())?;
.attr(format!("aria-controls=\"collapse-{}\"", &resuuid.hyphenated()).as_str());
itembutton.write_str(res.name())?;
for condition in &res.conditions() {
itembutton
.span()
.attr("class=\"badge ms-1 bg-light text-dark\"")
.write_str(condition)?;
}
itemdiv
.div()
.attr(format!("id=\"collapse-{}\"", &resuuid.hyphenated()).as_str())
Expand Down
13 changes: 13 additions & 0 deletions src/resources/clusteroperator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,17 @@ impl Resource for ClusterOperator {
fn raw(&self) -> &String {
self.manifest.as_raw()
}

fn conditions(&self) -> Vec<String> {
let mut conditions = Vec::new();

if self.degraded {
conditions.push(String::from("Degraded"));
}
if self.manifest.has_condition_status("Progressing", "True") {
conditions.push(String::from("Progressing"));
}

conditions
}
}
4 changes: 4 additions & 0 deletions src/resources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ pub trait Resource {
fn is_warning(&self) -> bool {
false
}

fn conditions(&self) -> Vec<String> {
Vec::new()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
apiVersion: config.openshift.io/v1
kind: ClusterOperator
metadata:
annotations:
capability.openshift.io/name: Console
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
creationTimestamp: "2024-04-17T09:03:48Z"
generation: 1
managedFields:
- apiVersion: config.openshift.io/v1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.: {}
f:capability.openshift.io/name: {}
f:include.release.openshift.io/ibm-cloud-managed: {}
f:include.release.openshift.io/self-managed-high-availability: {}
f:include.release.openshift.io/single-node-developer: {}
f:ownerReferences:
.: {}
k:{"uid":"fb8ca3e4-5385-46a5-b3e4-aecc71c3fa51"}: {}
f:spec: {}
manager: cluster-version-operator
operation: Update
time: "2024-04-17T09:03:48Z"
- apiVersion: config.openshift.io/v1
fieldsType: FieldsV1
fieldsV1:
f:status:
.: {}
f:extension: {}
manager: cluster-version-operator
operation: Update
subresource: status
time: "2024-04-17T09:03:48Z"
- apiVersion: config.openshift.io/v1
fieldsType: FieldsV1
fieldsV1:
f:status:
f:conditions: {}
f:relatedObjects: {}
f:versions: {}
manager: console
operation: Update
subresource: status
time: "2024-04-17T14:49:45Z"
name: console
ownerReferences:
- apiVersion: config.openshift.io/v1
controller: true
kind: ClusterVersion
name: version
spec: {}
status:
conditions:
- lastTransitionTime: "2024-04-17T09:22:01Z"
message: All is well
reason: AsExpected
status: "False"
type: Degraded
- lastTransitionTime: "2024-04-17T14:49:44Z"
message: All is well
reason: AsExpected
status: "True"
type: Progressing
- lastTransitionTime: "2024-04-17T14:25:46Z"
message: All is well
reason: AsExpected
status: "True"
type: Available
- lastTransitionTime: "2024-04-17T09:21:54Z"
message: All is well
reason: AsExpected
status: "True"
type: Upgradeable
- lastTransitionTime: "2024-04-17T09:18:41Z"
reason: NoData
status: Unknown
type: EvaluationConditionsDetected
extension: null
relatedObjects:
- group: console.openshift.io
name: acm
resource: consoleplugins
- group: console.openshift.io
name: mce
resource: consoleplugins
- group: console.openshift.io
name: monitoring-plugin
resource: consoleplugins
- group: operator.openshift.io
name: cluster
resource: consoles
- group: config.openshift.io
name: cluster
resource: consoles
- group: config.openshift.io
name: cluster
resource: infrastructures
- group: config.openshift.io
name: cluster
resource: proxies
- group: config.openshift.io
name: cluster
resource: oauths
- group: oauth.openshift.io
name: console
resource: oauthclients
- group: ""
name: openshift-console-operator
resource: namespaces
- group: ""
name: openshift-console
resource: namespaces
- group: ""
name: console-public
namespace: openshift-config-managed
resource: configmaps
versions:
- name: operator
version: 4.14.17
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
apiVersion: config.openshift.io/v1
kind: ClusterOperator
metadata:
annotations:
exclude.release.openshift.io/internal-openshift-hosted: "true"
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
creationTimestamp: "2024-04-17T09:03:48Z"
generation: 1
managedFields:
- apiVersion: config.openshift.io/v1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.: {}
f:exclude.release.openshift.io/internal-openshift-hosted: {}
f:include.release.openshift.io/self-managed-high-availability: {}
f:include.release.openshift.io/single-node-developer: {}
f:ownerReferences:
.: {}
k:{"uid":"fb8ca3e4-5385-46a5-b3e4-aecc71c3fa51"}: {}
f:spec: {}
manager: cluster-version-operator
operation: Update
time: "2024-04-17T09:03:48Z"
- apiVersion: config.openshift.io/v1
fieldsType: FieldsV1
fieldsV1:
f:status:
.: {}
f:extension: {}
f:relatedObjects: {}
manager: cluster-version-operator
operation: Update
subresource: status
time: "2024-04-17T09:03:48Z"
- apiVersion: config.openshift.io/v1
fieldsType: FieldsV1
fieldsV1:
f:status:
f:conditions: {}
f:versions: {}
manager: cluster-etcd-operator
operation: Update
subresource: status
time: "2024-04-17T14:39:12Z"
name: etcd
ownerReferences:
- apiVersion: config.openshift.io/v1
controller: true
kind: ClusterVersion
name: version
spec: {}
status:
conditions:
- lastTransitionTime: "2024-04-17T14:38:26Z"
message: |-
NodeControllerDegraded: All master nodes are ready
EtcdMembersDegraded: No unhealthy members found
reason: AsExpected
status: "True"
type: Degraded
- lastTransitionTime: "2024-04-17T09:31:58Z"
message: |-
NodeInstallerProgressing: 3 nodes are at revision 7
EtcdMembersProgressing: No unstarted etcd members found
reason: AsExpected
status: "False"
type: Progressing
- lastTransitionTime: "2024-04-17T09:14:10Z"
message: |-
StaticPodsAvailable: 3 nodes are active; 3 nodes are at revision 7
EtcdMembersAvailable: 3 members are available
reason: AsExpected
status: "True"
type: Available
- lastTransitionTime: "2024-04-17T09:12:02Z"
message: All is well
reason: AsExpected
status: "True"
type: Upgradeable
- lastTransitionTime: "2024-04-17T09:12:02Z"
message: The etcd backup controller is starting, and will decide if recent backups
are available or if a backup is required
reason: ControllerStarted
status: Unknown
type: RecentBackup
extension: null
relatedObjects:
- group: operator.openshift.io
name: cluster
resource: etcds
- group: ""
name: openshift-config
resource: namespaces
- group: ""
name: openshift-config-managed
resource: namespaces
- group: ""
name: openshift-etcd-operator
resource: namespaces
- group: ""
name: openshift-etcd
resource: namespaces
versions:
- name: raw-internal
version: 4.14.17
- name: operator
version: 4.14.17
- name: etcd
version: 4.14.17
Loading

0 comments on commit ba1b010

Please sign in to comment.