Skip to content

Commit

Permalink
Merge pull request #1793 from weaveworks/1710-helm-pipe-details
Browse files Browse the repository at this point in the history
Show Helm Release status info on pipeline details view
  • Loading branch information
jpellizzari authored Nov 1, 2022
2 parents 4fad93f + 093a296 commit 330490c
Show file tree
Hide file tree
Showing 13 changed files with 751 additions and 285 deletions.
26 changes: 26 additions & 0 deletions api/pipelines/pipelines.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,26 @@
}
}
},
"v1Condition": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"status": {
"type": "string"
},
"reason": {
"type": "string"
},
"message": {
"type": "string"
},
"timestamp": {
"type": "string"
}
}
},
"v1Environment": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -283,6 +303,12 @@
},
"lastAppliedRevision": {
"type": "string"
},
"conditions": {
"type": "array",
"items": {
"$ref": "#/definitions/v1Condition"
}
}
}
}
Expand Down
17 changes: 13 additions & 4 deletions api/pipelines/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,20 @@ message AppRef {
string name = 3;
}

message Condition {
string type = 1;
string status = 2;
string reason = 3;
string message = 4;
string timestamp = 5;
}

message WorkloadStatus {
string kind = 1;
string name = 2;
string version = 3;
string lastAppliedRevision = 4;
string kind = 1;
string name = 2;
string version = 3;
string lastAppliedRevision = 4;
repeated Condition conditions = 5;
}

message PipelineTargetStatus {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/pipelines/pipelines.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

328 changes: 221 additions & 107 deletions pkg/api/pipelines/types.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/api/terraform/terraform.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/api/terraform/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions pkg/pipelines/server/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"context"
"fmt"
"time"

helm "github.com/fluxcd/helm-controller/api/v2beta1"
ctrl "github.com/weaveworks/pipeline-controller/api/v1alpha1"
Expand Down Expand Up @@ -112,6 +113,16 @@ func getWorkloadStatus(obj *unstructured.Unstructured) (*pb.WorkloadStatus, erro
ws.Name = hr.Name
ws.Version = hr.Spec.Chart.Spec.Version
ws.LastAppliedRevision = hr.Status.LastAppliedRevision
ws.Conditions = []*pb.Condition{}
for _, c := range hr.Status.Conditions {
ws.Conditions = append(ws.Conditions, &pb.Condition{
Type: c.Type,
Status: string(c.Status),
Reason: c.Reason,
Message: c.Message,
Timestamp: c.LastTransitionTime.Format(time.RFC3339),
})
}
}

return ws, nil
Expand Down
9 changes: 9 additions & 0 deletions ui-cra/src/api/pipelines/types.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ export type AppRef = {
name?: string
}

export type Condition = {
type?: string
status?: string
reason?: string
message?: string
timestamp?: string
}

export type WorkloadStatus = {
kind?: string
name?: string
version?: string
lastAppliedRevision?: string
conditions?: Condition[]
}

export type PipelineTargetStatus = {
Expand Down
30 changes: 30 additions & 0 deletions ui-cra/src/components/Pipelines/PipelineDetails/WorkloadStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Flex, KubeStatusIndicator } from '@weaveworks/weave-gitops';
import styled from 'styled-components';
import { WorkloadStatus as WorkloadStatusType } from '../../../api/pipelines/types.pb';

interface Props {
className?: string;
workload?: WorkloadStatusType;
}

function WorkloadStatus({ className, workload }: Props) {
return (
<div className={className}>
<Flex align>
<div style={{ marginRight: 4 }}>
<KubeStatusIndicator short conditions={workload?.conditions || []} />
</div>
<div>{workload?.name}</div>
</Flex>
</div>
);
}

export default styled(WorkloadStatus).attrs({ className: 'WorkloadStatus' })`
font-size: ${props => props.theme.fontSizes.large};
/* Hack to hide the text; we only want the icon here */
${KubeStatusIndicator} span {
display: none;
}
`;
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* eslint-disable testing-library/no-node-access */
import { act, render, RenderResult, screen } from '@testing-library/react';
import { formatURL } from '@weaveworks/weave-gitops';
import { CoreClientContextProvider, formatURL } from '@weaveworks/weave-gitops';
import PipelineDetails from '..';
import { GetPipelineResponse } from '../../../../api/pipelines/pipelines.pb';
import { PipelinesProvider } from '../../../../contexts/Pipelines';
import {
CoreClientMock,
defaultContexts,
PipelinesClientMock,
withContext,
Expand Down Expand Up @@ -156,14 +157,21 @@ interface MappedWorkload {
describe('PipelineDetails', () => {
let wrap: (el: JSX.Element) => JSX.Element;
let api: PipelinesClientMock;
let core: CoreClientMock;

beforeEach(() => {
api = new PipelinesClientMock();
wrap = withContext([...defaultContexts(), [PipelinesProvider, { api }]]);
core = new CoreClientMock();
wrap = withContext([
...defaultContexts(),
[PipelinesProvider, { api }],
[CoreClientContextProvider, { api: core }],
]);
});
it('renders pipeline details', async () => {
const params = res.pipeline;
api.GetPipelineReturns = res;
core.GetObjectReturns = { object: {} };

await act(async () => {
const c = wrap(
Expand Down Expand Up @@ -230,20 +238,15 @@ describe('PipelineDetails', () => {
);

//Target as a link
const linkToAutomation = target.querySelector('.workloadName > a');
const linkToAutomation = target.querySelector('a');

if (workloads![index].mappedClusterName) {
const href = formatURL('/helm_release/details', {
name: workloads![index].name,
namespace: workloads![index].namespace,
clusterName: workloads![index].mappedClusterName,
});
linkToExists(linkToAutomation, href);
} else {
elementToBeNull(linkToAutomation);
checkTextContentToEqual(
target.querySelector('.workload-name'),
workloads![index].name || '',
);
}
// Workload Last Applied Version
const lastAppliedRevision = target.querySelector(
Expand Down
Loading

0 comments on commit 330490c

Please sign in to comment.