Skip to content

Commit

Permalink
[CHORE] updating helm crds templates
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Takashi <nicolas.takashi@coralogix.com>
  • Loading branch information
nicolastakashi committed Aug 18, 2023
1 parent 9ffee8d commit b3308fc
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 20 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/helm-lint-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: coralogix-operator

on:
pull_request:
paths:
- "charts/coralogix-operator/**"
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
- name: Check if Helm CRDs templates are updated
run: |
make helm-check-crd-version
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,11 @@ $(CRDOC): $(LOCALBIN)

e2e:
kubectl kuttl test

.PHONY: helm-check-crd-version
helm-check-crd-version:
sh scripts/helm-check-crd-version.sh

.PHONY: helm-update-crds
helm-update-crds:
sh scripts/helm-update-crds.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand All @@ -20,10 +21,14 @@ spec:
description: Alert is the Schema for the alerts API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
Expand Down Expand Up @@ -863,9 +868,8 @@ spec:
items:
type: string
type: array
integrationID:
format: int32
type: integer
integrationName:
type: string
notifyOn:
type: string
retriggeringPeriodMinutes:
Expand Down Expand Up @@ -1762,9 +1766,8 @@ spec:
items:
type: string
type: array
integrationID:
format: int32
type: integer
integrationName:
type: string
notifyOn:
type: string
retriggeringPeriodMinutes:
Expand Down Expand Up @@ -1827,4 +1830,4 @@ spec:
served: true
storage: true
subresources:
status: {}
status: {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand All @@ -17,13 +18,18 @@ spec:
- name: v1alpha1
schema:
openAPIV3Schema:
description: RecordingRuleGroupSet is the Schema for the recordingrulegroupsets API
description: RecordingRuleGroupSet is the Schema for the recordingrulegroupsets
API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
Expand All @@ -42,7 +48,9 @@ spec:
format: int64
type: integer
name:
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster Important: Run "make" to regenerate code after modifying this file'
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state
of cluster Important: Run "make" to regenerate code after
modifying this file'
type: string
rules:
items:
Expand All @@ -64,7 +72,8 @@ spec:
- groups
type: object
status:
description: RecordingRuleGroupSetStatus defines the observed state of RecordingRuleGroupSet
description: RecordingRuleGroupSetStatus defines the observed state of
RecordingRuleGroupSet
properties:
groups:
items:
Expand All @@ -78,7 +87,9 @@ spec:
format: int64
type: integer
name:
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster Important: Run "make" to regenerate code after modifying this file'
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state
of cluster Important: Run "make" to regenerate code after
modifying this file'
type: string
rules:
items:
Expand All @@ -104,4 +115,4 @@ spec:
served: true
storage: true
subresources:
status: {}
status: {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand All @@ -20,10 +21,14 @@ spec:
description: RuleGroup is the Schema for the rulegroups API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
Expand Down Expand Up @@ -243,7 +248,9 @@ spec:
hidden:
type: boolean
id:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state of cluster Important: Run "make" to regenerate code after modifying this file'
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
type: string
name:
type: string
Expand Down Expand Up @@ -430,4 +437,4 @@ spec:
served: true
storage: true
subresources:
status: {}
status: {}
31 changes: 31 additions & 0 deletions scripts/helm-check-crd-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# This shell script is going to check if the CRDs on the helm directory is updated or not.

crds_path="charts/coralogix-operator/templates/crds"
bases_path="config/crd/bases"

errors_found=0

# Get a list of YAML files in the two paths
crds_files=$(find "$crds_path" -type f -name "*.yaml")

# Compare the contents of corresponding files
for crd_file in $crds_files; do
base_file="$bases_path/$(basename $crd_file)"

if [ -f "$base_file" ]; then
if ! cmp -s "$crd_file" "$base_file"; then
echo "CRD file $crd_file is outdated, please run make helm-update-crds"
((errors_found++))
fi
else
echo "Base file not found for $crd_file"
((errors_found++))
fi
done

if [ "$errors_found" -gt 0 ]; then
exit 1
fi

echo CRDs are updated
20 changes: 20 additions & 0 deletions scripts/helm-update-crds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# This shell script will update the helm CRDs files

crds_path="charts/coralogix-operator/templates/crds"
bases_path="config/crd/bases"

# Get a list of YAML files in the two paths
crds_files=$(find "$crds_path" -type f -name "*.yaml")

# Replace the contents of corresponding files
for crd_file in $crds_files; do
base_file="$bases_path/$(basename $crd_file)"

if [ -f "$base_file" ]; then
cp "$base_file" "$crd_file"
echo "Replaced CRD file: $crd_file"
else
echo "Base file not found for $crd_file"
fi
done

0 comments on commit b3308fc

Please sign in to comment.