Skip to content

Commit 4fc0165

Browse files
committed
chore: naming for the types for Argo Rollouts
1 parent 00375d8 commit 4fc0165

File tree

6 files changed

+33
-19
lines changed

6 files changed

+33
-19
lines changed

src/supervisor/watchers/handlers/argo-rollout.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { IncomingMessage } from 'http';
22
import { deleteWorkload } from './workload';
33
import { WorkloadKind } from '../../types';
4-
import { FALSY_WORKLOAD_NAME_MARKER, Rollout, RolloutList } from './types';
4+
import {
5+
FALSY_WORKLOAD_NAME_MARKER,
6+
V1alpha1Rollout,
7+
V1alpha1RolloutList,
8+
} from './types';
59
import { paginatedClusterList, paginatedNamespacedList } from './pagination';
610
import { k8sApi } from '../../cluster';
711
import {
@@ -18,12 +22,12 @@ export async function paginatedNamespacedArgoRolloutList(
1822
namespace: string,
1923
): Promise<{
2024
response: IncomingMessage;
21-
body: RolloutList;
25+
body: V1alpha1RolloutList;
2226
}> {
23-
const rolloutList = new RolloutList();
27+
const rolloutList = new V1alpha1RolloutList();
2428
rolloutList.apiVersion = 'argoproj.io/v1alpha1';
2529
rolloutList.kind = 'RolloutList';
26-
rolloutList.items = new Array<Rollout>();
30+
rolloutList.items = new Array<V1alpha1Rollout>();
2731

2832
return await paginatedNamespacedList(
2933
namespace,
@@ -54,12 +58,12 @@ export async function paginatedNamespacedArgoRolloutList(
5458

5559
export async function paginatedClusterArgoRolloutList(): Promise<{
5660
response: IncomingMessage;
57-
body: RolloutList;
61+
body: V1alpha1RolloutList;
5862
}> {
59-
const rolloutList = new RolloutList();
63+
const rolloutList = new V1alpha1RolloutList();
6064
rolloutList.apiVersion = 'argoproj.io/v1';
6165
rolloutList.kind = 'RolloutList';
62-
rolloutList.items = new Array<Rollout>();
66+
rolloutList.items = new Array<V1alpha1Rollout>();
6367

6468
return await paginatedClusterList(
6569
rolloutList,
@@ -84,7 +88,9 @@ export async function paginatedClusterArgoRolloutList(): Promise<{
8488
);
8589
}
8690

87-
export async function ArgoRolloutWatchHandler(rollout: Rollout): Promise<void> {
91+
export async function argoRolloutWatchHandler(
92+
rollout: V1alpha1Rollout,
93+
): Promise<void> {
8894
rollout = trimWorkload(rollout);
8995

9096
if (

src/supervisor/watchers/handlers/informer-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export const workloadWatchMetadata: Readonly<IWorkloadWatchMetadata> = {
152152
namespacedEndpoint:
153153
'/apis/argoproj.io/v1alpha1/watch/namespaces/{namespace}/rollouts',
154154
handlers: {
155-
[DELETE]: rollout.ArgoRolloutWatchHandler,
155+
[DELETE]: rollout.argoRolloutWatchHandler,
156156
},
157157
clusterListFactory: () => () => rollout.paginatedClusterArgoRolloutList(),
158158
namespacedListFactory: (namespace) => () =>

src/supervisor/watchers/handlers/types.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,28 @@ export interface V1DeploymentConfigStatus {
6060
observedGeneration?: number;
6161
}
6262

63-
export class RolloutList implements KubernetesListObject<Rollout> {
63+
export class V1alpha1RolloutList
64+
implements KubernetesListObject<V1alpha1Rollout>
65+
{
6466
'apiVersion'?: string;
65-
'items': Array<Rollout>;
67+
'items': Array<V1alpha1Rollout>;
6668
'kind'?: string;
6769
'metadata'?: V1ListMeta;
6870
}
6971

70-
export interface Rollout extends KubernetesObject {
72+
export interface V1alpha1Rollout extends KubernetesObject {
7173
apiVersion?: string;
7274
kind?: string;
7375
metadata?: V1ObjectMeta;
74-
spec?: RolloutSpec;
75-
status?: RolloutStatus;
76+
spec?: V1alpha1RolloutSpec;
77+
status?: V1alpha1RolloutStatus;
7678
}
7779

78-
export interface RolloutSpec {
80+
export interface V1alpha1RolloutSpec {
7981
template: V1PodTemplateSpec;
8082
}
8183

82-
export interface RolloutStatus {
84+
export interface V1alpha1RolloutStatus {
8385
observedGeneration?: number;
8486
}
8587

src/supervisor/workload-reader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as kubernetesApiWrappers from './kuberenetes-api-wrappers';
44
import { k8sApi } from './cluster';
55
import { IKubeObjectMetadata, WorkloadKind } from './types';
66
import { logger } from '../common/logger';
7-
import { Rollout, V1DeploymentConfig } from './watchers/handlers/types';
7+
import { V1alpha1Rollout, V1DeploymentConfig } from './watchers/handlers/types';
88
import { trimWorkload } from './workload-sanitization';
99

1010
type IKubeObjectMetadataWithoutPodSpec = Omit<IKubeObjectMetadata, 'podSpec'>;
@@ -294,7 +294,7 @@ const argoRolloutReader: IWorkloadReaderFunc = async (
294294
workloadName,
295295
),
296296
);
297-
const rollout: Rollout = trimWorkload(rolloutResult.body);
297+
const rollout: V1alpha1Rollout = trimWorkload(rolloutResult.body);
298298

299299
if (
300300
!rollout.metadata ||

src/transmitter/payload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const workloadKindMap = {
150150
replicationcontroller: 'ReplicationController',
151151
deploymentconfig: 'DeploymentConfig',
152152
pod: 'Pod',
153-
rollout: 'Rollout', // TODO: Verify if supported
153+
rollout: 'Rollout',
154154
};
155155
export function constructRuntimeData(
156156
runtimeResults: IRuntimeImage[],

test/system/kind.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ test('Kubernetes-Monitor with KinD', async (jestDoneCallback) => {
167167
code: 'ECONNRESET',
168168
});
169169

170+
nock(/https\:\/\/127\.0\.0\.1\:\d+/)
171+
.get('/apis/argoproj.io/v1alpha1/rollouts')
172+
.query(true)
173+
.times(1)
174+
.reply(200);
175+
170176
nock('https://kubernetes-upstream.snyk.io')
171177
.post('/api/v1/workload')
172178
.times(1)

0 commit comments

Comments
 (0)