Skip to content

Commit

Permalink
feat: add action - K8S_ATTRIBUTES
Browse files Browse the repository at this point in the history
  • Loading branch information
BenElferink committed Feb 10, 2025
1 parent 3c9a51b commit 7becedf
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@odigos/ui-components": "^0.0.59",
"@odigos/ui-icons": "^0.0.12",
"@odigos/ui-theme": "^0.0.16",
"@odigos/ui-utils": "^0.0.22",
"@odigos/ui-utils": "^0.0.24",
"@xyflow/react": "^12.4.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand Down
5 changes: 5 additions & 0 deletions src/@types/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ export interface ActionFormData {
signals: Action['spec']['signals']
disabled: Action['spec']['disabled']

collectContainerAttributes: Action['spec']['collectContainerAttributes']
collectWorkloadId: Action['spec']['collectWorkloadId']
collectClusterId: Action['spec']['collectClusterId']
labelsAttributes: Action['spec']['labelsAttributes']
annotationsAttributes: Action['spec']['annotationsAttributes']
clusterAttributes: Action['spec']['clusterAttributes']
attributeNamesToDelete: Action['spec']['attributeNamesToDelete']
renames: Action['spec']['renames']
Expand Down
2 changes: 2 additions & 0 deletions src/containers/action-form/custom-fields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { type FC } from 'react'
import { PiiMasking } from './pii-masking'
import { ACTION_TYPE } from '@odigos/ui-utils'
import { ErrorSampler } from './error-sampler'
import { K8sAttributes } from './k8s-attributes'
import { LatencySampler } from './latency-sampler'
import { AddClusterInfo } from './add-cluster-info'
import { DeleteAttributes } from './delete-attributes'
Expand All @@ -16,6 +17,7 @@ interface CustomFieldsProps extends CustomFieldProps<ActionFormData> {
type ComponentType = FC<CustomFieldProps<ActionFormData>> | null

const componentsMap: Record<ACTION_TYPE, ComponentType> = {
[ACTION_TYPE.K8S_ATTRIBUTES]: K8sAttributes,
[ACTION_TYPE.ADD_CLUSTER_INFO]: AddClusterInfo,
[ACTION_TYPE.DELETE_ATTRIBUTES]: DeleteAttributes,
[ACTION_TYPE.RENAME_ATTRIBUTES]: RenameAttributes,
Expand Down
70 changes: 70 additions & 0 deletions src/containers/action-form/custom-fields/k8s-attributes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React, { type FC } from 'react'
import { Checkbox, InputTable } from '@odigos/ui-components'
import type { ActionFormData, CustomFieldProps } from '../../../@types'

type K8sAttributesProps = CustomFieldProps<ActionFormData>

const K8sAttributes: FC<K8sAttributesProps> = ({ value, setValue, formErrors }) => {
return (
<>
<Checkbox
title='Collect Container Attributes'
value={value['collectContainerAttributes'] || false}
onChange={(bool) => setValue('collectContainerAttributes', bool)}
errorMessage={formErrors['collectContainerAttributes']}
/>
<Checkbox
title='Collect Workload ID'
value={value['collectWorkloadId'] || false}
onChange={(bool) => setValue('collectWorkloadId', bool)}
errorMessage={formErrors['collectWorkloadId']}
/>
<Checkbox
title='Collect Cluster ID'
value={value['collectClusterId'] || false}
onChange={(bool) => setValue('collectClusterId', bool)}
errorMessage={formErrors['collectClusterId']}
/>
<InputTable
columns={[
{
title: 'Label Key',
keyName: 'labelKey',
placeholder: 'app.kubernetes.io/name',
required: true,
},
{
title: 'Attribute Key',
keyName: 'attributeKey',
placeholder: 'app.kubernetes.name',
required: true,
},
]}
value={value['labelsAttributes'] || []}
onChange={(arr) => setValue('labelsAttributes', arr)}
errorMessage={formErrors['labelsAttributes']}
/>
<InputTable
columns={[
{
title: 'Annotation Key',
keyName: 'annotationKey',
placeholder: 'kubectl.kubernetes.io/restartedAt',
required: true,
},
{
title: 'Attribute Key',
keyName: 'attributeKey',
placeholder: 'kubectl.kubernetes.restartedAt',
required: true,
},
]}
value={value['annotationsAttributes'] || []}
onChange={(arr) => setValue('annotationsAttributes', arr)}
errorMessage={formErrors['annotationsAttributes']}
/>
</>
)
}

export { K8sAttributes, type K8sAttributesProps }
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,18 @@
react-dom "^19.0.0"
styled-components "^6.1.15"

"@odigos/ui-utils@^0.0.24":
version "0.0.24"
resolved "https://registry.yarnpkg.com/@odigos/ui-utils/-/ui-utils-0.0.24.tgz#be44bd58a51372fc9e6a8f9b303edf4be424b930"
integrity sha512-N43dbdHI6F/HGY6RkjbBYhaYheiBuPa8iIA1cr9W4rEh+IO7Iz7KURQyUNXjEk1lDxxvU9UjOrfS+adkKU9FbQ==
dependencies:
"@odigos/ui-icons" "^0.0.12"
"@odigos/ui-theme" "^0.0.16"
javascript-time-ago "^2.5.11"
react "^19.0.0"
react-dom "^19.0.0"
styled-components "^6.1.15"

"@rollup/plugin-commonjs@^28.0.2":
version "28.0.2"
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-28.0.2.tgz#193d7a86470f112b56927c1d821ee45951a819ea"
Expand Down

0 comments on commit 7becedf

Please sign in to comment.