Skip to content

Commit

Permalink
refactor: rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
usernamehw authored and Kingdon Barrett committed Apr 27, 2022
1 parent 6194b25 commit 70ef47a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/views/nodes/sourceNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class SourceNode extends TreeNode {
let revisionOrError = '';

if (this.isReconcileFailed) {
revisionOrError = `${this.findReadyCondition(this.resource.status.conditions)?.reason}`;
revisionOrError = `${this.findReadyOrFirstCondition(this.resource.status.conditions)?.reason}`;
} else {
revisionOrError = shortenRevision(this.resource.status.artifact?.revision);
}
Expand All @@ -56,7 +56,7 @@ export class SourceNode extends TreeNode {

// show status in hover when source fetching failed
if (this.isReconcileFailed) {
const readyCondition = this.findReadyCondition(source.status.conditions);
const readyCondition = this.findReadyOrFirstCondition(source.status.conditions);
createMarkdownHr(markdown);
createMarkdownError('Status message', readyCondition?.message, markdown);
createMarkdownError('Status reason', readyCondition?.reason, markdown);
Expand All @@ -71,7 +71,7 @@ export class SourceNode extends TreeNode {
*
* @param conditions "status.conditions" of the source
*/
findReadyCondition(conditions?: DeploymentCondition[]): DeploymentCondition | undefined {
findReadyOrFirstCondition(conditions?: DeploymentCondition[]): DeploymentCondition | undefined {
return conditions?.find(condition => condition.type === 'Ready') || conditions?.[0];
}

Expand All @@ -80,7 +80,7 @@ export class SourceNode extends TreeNode {
* @param source target source
*/
updateStatus(source: GitRepository | HelmRepository | Bucket): void {
if (this.findReadyCondition(source.status.conditions)?.status === 'True') {
if (this.findReadyOrFirstCondition(source.status.conditions)?.status === 'True') {
this.setIcon(TreeNodeIcon.Success);
this.isReconcileFailed = false;
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/views/nodes/workloadNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class WorkloadNode extends TreeNode {
*
* @param conditions "status.conditions" of the workload
*/
findReadyCondition(conditions?: DeploymentCondition | DeploymentCondition[]): DeploymentCondition | undefined {
findReadyOrFirstCondition(conditions?: DeploymentCondition | DeploymentCondition[]): DeploymentCondition | undefined {
if (Array.isArray(conditions)) {
return conditions.find(condition => condition.type === 'Ready') || conditions[0];
} else {
Expand All @@ -44,7 +44,7 @@ export class WorkloadNode extends TreeNode {
* @param workload target resource
*/
updateStatus(workload: Kustomize | HelmRelease): void {
const condition = this.findReadyCondition(workload.status.conditions);
const condition = this.findReadyOrFirstCondition(workload.status.conditions);

if (condition?.status === 'True') {
this.isReconcileFailed = false;
Expand Down Expand Up @@ -75,7 +75,7 @@ export class WorkloadNode extends TreeNode {

// show status in hover when source fetching failed
if (this.isReconcileFailed) {
const readyCondition = this.findReadyCondition(workload.status.conditions);
const readyCondition = this.findReadyOrFirstCondition(workload.status.conditions);
createMarkdownHr(markdown);
createMarkdownError('Status message', readyCondition?.message, markdown);
createMarkdownError('Status reason', readyCondition?.reason, markdown);
Expand Down

0 comments on commit 70ef47a

Please sign in to comment.