Skip to content

Commit

Permalink
Check for pullpolicy=Always as advices
Browse files Browse the repository at this point in the history
  • Loading branch information
sebt3 committed Jun 2, 2024
1 parent de06895 commit 7a0ead8
Show file tree
Hide file tree
Showing 7 changed files with 6,265 additions and 1,542 deletions.
7,584 changes: 6,051 additions & 1,533 deletions data/rabbitmq.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion front/components/generic/AdviceOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const props=withDefaults(defineProps<{model: object[], short: string, to: (strin
showNamespace: false,
showKind: true,
});
const advicelist = props.model.map(o=>o.getcoreadvice.map(p=>{ return {namespace: o.metadata.namespace, source: p.source}})).flat()
const advicelist = props.model.map(o=>o.getcoreAdvice.map(p=>{ return {namespace: o.metadata.namespace, source: p.source}})).flat()
const advices = ref(advicelist.map(p=>p.namespace).filter(onlyUnique).map(namespace=>advicelist.map(p=>p.source).filter(onlyUnique).map(source=>{return {namespace, source, value: advicelist.filter(p=>p.namespace==namespace&&p.source==source).length}})).flat().filter(p=>p.value>0))
const pieChart = defineAsyncComponent(() => import( '@/components/charts/pieChart.vue'));
const stackedBarChart = defineAsyncComponent(() => import( '@/components/charts/stackedBarChart.vue'));
Expand Down
12 changes: 9 additions & 3 deletions front/components/generic/GenericList.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script setup lang="ts">
defineEmits(['refresh','on-delete']);
const props = withDefaults(defineProps<{model: object[], group:string, short:string, parent?:object, useAction?:boolean, useRefresh?: boolean, showNamespace?:boolean, origin?:string}>(),{
const props = withDefaults(defineProps<{model: object[], group:string, short:string, parent?:object, useAction?:boolean, useRefresh?: boolean, showNamespace?:boolean, showAdvices?:boolean, origin?:string}>(),{
useAction: false,
useRefresh: true,
showNamespace: false,
showAdvices: false
});
const { loader } = await import("../../libs/core/importer")
const { colorItem, iconItem, elude, defineAsyncComponent, ref, useItem, itemColumns, itemAllColumns } = await loader(props.group,props.short)
Expand All @@ -28,12 +29,17 @@ const TableHeader = defineAsyncComponent(() => import( '@/components/core/TableH
</template>
<template v-slot:body-cell-Problems="props">
<q-td :props="props">
<q-chip v-if="props.row.getcoreProblem==null" class="glossy" color="positive" text-color="white" icon="done" />
<div v-else class="column">
<div v-if="props.row.getcoreProblem!=null" class="column">
<div class="col" v-for="problem in props.row.getcoreProblem" :key="problem.description">
<q-chip v-bind:key="problem" class="glossy" color="negative" text-color="white" icon="error">{{ elude(problem.description, 40) }}<q-tooltip>{{ problem.description }}</q-tooltip></q-chip>
</div>
</div>
<div v-else-if="showAdvices && props.row.getcoreAdvice!=null" class="column">
<div class="col" v-for="advice in props.row.getcoreAdvice" :key="advice.description">
<q-chip v-bind:key="advice" color="warning" text-color="white" icon="error">{{ elude(advice.description, 40) }}<q-tooltip>{{ advice.description }}</q-tooltip></q-chip>
</div>
</div>
<q-chip v-else class="glossy" color="positive" text-color="white" icon="done" />
</q-td>
</template>
<template v-slot:body-cell-Name="props">
Expand Down
169 changes: 169 additions & 0 deletions front/libs/rabbitmq/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,185 @@ const { i18n } = await import("../i18n")
const { databaseColor, databaseIcon, } = await import('../../routes/custom');
export const rabbitmqIcon = databaseIcon;
export const rabbitmqTitle = 'RabbitMQ';
export const iconSuperStream = databaseIcon;
export const colorSuperStream = databaseColor;
export const descriptionSuperStream = '';
export const shortSuperStream = 'SuperStream';
export const iconBinding = databaseIcon;
export const colorBinding = databaseColor;
export const descriptionBinding = '';
export const shortBinding = 'Binding';
export const iconExchange = databaseIcon;
export const colorExchange = databaseColor;
export const descriptionExchange = '';
export const shortExchange = 'Exchange';
export const iconFederation = databaseIcon;
export const colorFederation = databaseColor;
export const descriptionFederation = '';
export const shortFederation = 'Federation';
export const iconOperatorPolicy = databaseIcon;
export const colorOperatorPolicy = databaseColor;
export const descriptionOperatorPolicy = '';
export const shortOperatorPolicy = 'OperatorPolicy';
export const iconPermission = databaseIcon;
export const colorPermission = databaseColor;
export const descriptionPermission = '';
export const shortPermission = 'Permission';
export const iconPolicy = databaseIcon;
export const colorPolicy = databaseColor;
export const descriptionPolicy = '';
export const shortPolicy = 'Policy';
export const iconQueue = databaseIcon;
export const colorQueue = databaseColor;
export const descriptionQueue = '';
export const shortQueue = 'Queue';
export const iconRabbitmqCluster = databaseIcon;
export const colorRabbitmqCluster = databaseColor;
export const descriptionRabbitmqCluster = '';
export const shortRabbitmqCluster = 'RabbitmqCluster';
export const iconSchemaReplication = databaseIcon;
export const colorSchemaReplication = databaseColor;
export const descriptionSchemaReplication = '';
export const shortSchemaReplication = 'SchemaReplication';
export const iconShovel = databaseIcon;
export const colorShovel = databaseColor;
export const descriptionShovel = '';
export const shortShovel = 'Shovel';
export const iconTopicPermission = databaseIcon;
export const colorTopicPermission = databaseColor;
export const descriptionTopicPermission = '';
export const shortTopicPermission = 'TopicPermission';
export const iconUser = databaseIcon;
export const colorUser = databaseColor;
export const descriptionUser = '';
export const shortUser = 'User';
export const iconVhost = databaseIcon;
export const colorVhost = databaseColor;
export const descriptionVhost = '';
export const shortVhost = 'Vhost';
export const extraSuperStreamColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraBindingColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraExchangeColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraFederationColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraOperatorPolicyColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraPermissionColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraPolicyColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraQueueColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraRabbitmqClusterColumns:Array<QTableColumn> = [
{name: 'Age', label: `${i18n.global.t('meta.age')}`, field: row => timeAgo(row.metadata.creationTimestamp), sortable: true, align: tableColumnAlign.left},
];
export const extraSchemaReplicationColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraShovelColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraTopicPermissionColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraUserColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const extraVhostColumns:Array<QTableColumn> = [
// {name: 'Name', label: 'Name', field: row => row.metadata.name, sortable: true, align: tableColumnAlign.left},
];
export const SuperStreamListExcludes = [
];
export const SuperStreamReadExcludes = [
];
export const SuperStreamSimpleExcludes = [
];
export const BindingListExcludes = [
];
export const BindingReadExcludes = [
];
export const BindingSimpleExcludes = [
];
export const ExchangeListExcludes = [
];
export const ExchangeReadExcludes = [
];
export const ExchangeSimpleExcludes = [
];
export const FederationListExcludes = [
];
export const FederationReadExcludes = [
];
export const FederationSimpleExcludes = [
];
export const OperatorPolicyListExcludes = [
];
export const OperatorPolicyReadExcludes = [
];
export const OperatorPolicySimpleExcludes = [
];
export const PermissionListExcludes = [
];
export const PermissionReadExcludes = [
];
export const PermissionSimpleExcludes = [
];
export const PolicyListExcludes = [
];
export const PolicyReadExcludes = [
];
export const PolicySimpleExcludes = [
];
export const QueueListExcludes = [
];
export const QueueReadExcludes = [
];
export const QueueSimpleExcludes = [
];
export const RabbitmqClusterListExcludes = [
];
export const RabbitmqClusterReadExcludes = [
];
export const RabbitmqClusterSimpleExcludes = [
];
export const SchemaReplicationListExcludes = [
];
export const SchemaReplicationReadExcludes = [
];
export const SchemaReplicationSimpleExcludes = [
];
export const ShovelListExcludes = [
];
export const ShovelReadExcludes = [
];
export const ShovelSimpleExcludes = [
];
export const TopicPermissionListExcludes = [
];
export const TopicPermissionReadExcludes = [
];
export const TopicPermissionSimpleExcludes = [
];
export const UserListExcludes = [
];
export const UserReadExcludes = [
];
export const UserSimpleExcludes = [
];
export const VhostListExcludes = [
];
export const VhostReadExcludes = [
];
export const VhostSimpleExcludes = [
];
4 changes: 2 additions & 2 deletions utils/generator/front/all.pages.advices.vue.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ const GenericList = defineAsyncComponent(() => import( '@/components/gene
:model="result.k8sNamespace.map(n => n.{{ group }}{{ short }}.filter(o=>Array.isArray(o['getcoreAdvice'])&&o['getcoreAdvice'].length>0)).flat()" />
</div>
<div class="col-lg-8">
<GenericList group="{{ group }}" short="{{ short }}" @refresh="refetch()" :useAction="false"
<GenericList group="{{ group }}" short="{{ short }}" @refresh="refetch()" :useAction="false" :showAdvices="true"
v-if="result !== undefined && result['k8sNamespace'] !== undefined && Array.isArray(result['k8sNamespace']) && result['k8sNamespace'].map(n=>n['{{ group }}{{ short }}']).flat().length>0"
:model="result.k8sNamespace.map(n => n.{{ group }}{{ short }}.filter(o=>Array.isArray(o['getcoreAdvice'])&&o['getcoreAdvice'].length>0)).flat()" />
</div>
{{else}}
<div class="row q-mb-sm q-ml-sm" v-if="!loading && !namespaced && result.{{ group }}{{ short }}.filter(o=>Array.isArray(o['getcoreAdvice'])&&o['getcoreAdvice'].length>0).length>0">
<div class="col-lg-4">
<AdviceOverview short="{{ short }}" :to="to{{ group }}{{ short }}List"
<AdviceOverview short="{{ short }}" :to="to{{ group }}{{ short }}List" :showAdvices="true"
:model="result.{{ group }}{{ short }}.filter(o=>Array.isArray(o['getcoreAdvice'])&&o['getcoreAdvice'].length>0)" />
</div>
<div class="col-lg-8">
Expand Down
4 changes: 2 additions & 2 deletions utils/generator/front/grp.pages.advices.vue.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const GenericList = defineAsyncComponent(() => import( '@/components/generi
:model="result.k8sNamespace.map(n => n.{{ group }}{{ short }}.filter(o=>Array.isArray(o['getcoreAdvice'])&&o['getcoreAdvice'].length>0)).flat()" />
</div>
<div class="col-lg-8">
<GenericList group="{{ group }}" short="{{ short }}" @refresh="refetch()" :useAction="false"
<GenericList group="{{ group }}" short="{{ short }}" @refresh="refetch()" :useAction="false" :showAdvices="true"
v-if="result !== undefined && result['k8sNamespace'] !== undefined && Array.isArray(result['k8sNamespace']) && result['k8sNamespace'].map(n=>n['{{ group }}{{ short }}']).flat().length>0"
:model="result.k8sNamespace.map(n => n.{{ group }}{{ short }}.filter(o=>Array.isArray(o['getcoreAdvice'])&&o['getcoreAdvice'].length>0)).flat()" />
</div>
Expand All @@ -109,7 +109,7 @@ const GenericList = defineAsyncComponent(() => import( '@/components/generi
:model="result.{{ group }}{{ short }}.filter(o=>Array.isArray(o['getcoreAdvice'])&&o['getcoreAdvice'].length>0)" />
</div>
<div class="col-lg-8">
<GenericList group="{{ group }}" short="{{ short }}" @refresh="refetch()" :useAction="false"
<GenericList group="{{ group }}" short="{{ short }}" @refresh="refetch()" :useAction="false" :showAdvices="true"
v-if="result !== undefined && Array.isArray(result['{{ group }}{{ short }}']) && result['{{ group }}{{ short }}'].length>0"
:model="result.{{ group }}{{ short }}.filter(o=>Array.isArray(o['getcoreAdvice'])&&o['getcoreAdvice'].length>0)" />
</div>
Expand Down
32 changes: 31 additions & 1 deletion utils/generator/partials/back/advices.ts.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
{{type}}{{targetGroup}}{{targetShort}}: async (parent, args: object) => {
const advices = [] as { source:string, description:string }[]
const advices = [] as { source:string, reason: String, description:string }[]
{{#if (eq 'comment' 'TODO')}}
https://github.com/stackrox/kube-linter/tree/main/pkg/templates
{{/if}}
{{#if (and (eq group 'k8s') (eq short 'Pod'))}}
if (parent['spec'] != undefined && Array.isArray(parent['spec']['containers']) && parent['spec']['containers'].filter(c=>c['imagePullPolicy']!=undefined && c['imagePullPolicy']!='IfNotPresent')) {
advices.unshift(...parent['spec']['containers'].filter(c=>c['imagePullPolicy']!=undefined && c['imagePullPolicy']!='IfNotPresent').map(c=>{ return {
source: `${c['name']}`,
reason: "imagePullPolicy should always be 'IfNotPresent'",
description: `${c['name']} imagePullPolicy is ${c['imagePullPolicy']}`
} }))
}
if (parent['spec'] != undefined && Array.isArray(parent['spec']['initContainers']) && parent['spec']['initContainers'].filter(c=>c['imagePullPolicy']!=undefined && c['imagePullPolicy']!='IfNotPresent')) {
advices.unshift(...parent['spec']['initContainers'].filter(c=>c['imagePullPolicy']!=undefined && c['imagePullPolicy']!='IfNotPresent').map(c=>{ return {
source: `${c['name']}`,
reason: "imagePullPolicy should always be 'IfNotPresent'",
description: `${c['name']} imagePullPolicy is ${c['imagePullPolicy']}`
} }))
}
{{/if}}
{{#if (and (eq group 'k8s') (or (eq short 'Job') (or (or (eq short 'Deployment') (eq short 'ReplicaSet')) (or (eq short 'StatefulSet') (eq short 'DaemonSet')))))}}
if (parent['spec'] != undefined && parent['spec']['template'] != undefined && parent['spec']['template']['spec'] != undefined && Array.isArray(parent['spec']['template']['spec']['containers']) && parent['spec']['template']['spec']['containers'].filter(c=>c['imagePullPolicy']!=undefined && c['imagePullPolicy']!='IfNotPresent')) {
advices.unshift(...parent['spec']['template']['spec']['containers'].filter(c=>c['imagePullPolicy']!=undefined && c['imagePullPolicy']!='IfNotPresent').map(c=>{ return {
source: `${c['name']}`,
reason: "imagePullPolicy should always be 'IfNotPresent'",
description: `${c['name']} imagePullPolicy is ${c['imagePullPolicy']}`
} }))
}
if (parent['spec'] != undefined && parent['spec']['template'] != undefined && parent['spec']['template']['spec'] != undefined && Array.isArray(parent['spec']['template']['spec']['initContainers']) && parent['spec']['template']['spec']['initContainers'].filter(c=>c['imagePullPolicy']!=undefined && c['imagePullPolicy']!='IfNotPresent')) {
advices.unshift(...parent['spec']['template']['spec']['initContainers'].filter(c=>c['imagePullPolicy']!=undefined && c['imagePullPolicy']!='IfNotPresent').map(c=>{ return {
source: `${c['name']}`,
reason: "imagePullPolicy should always be 'IfNotPresent'",
description: `${c['name']} imagePullPolicy is ${c['imagePullPolicy']}`
} }))
}
{{/if}}
if (advices.length>0) return advices
return null
Expand Down

0 comments on commit 7a0ead8

Please sign in to comment.