Skip to content

Commit 2ffc527

Browse files
committed
fix: append storageversion marker only on exact match
Signed-off-by: Philippe Scorsolini <[email protected]>
1 parent e3d8684 commit 2ffc527

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

apis/apiextensions/v1alpha1/zz_generated.environment_config_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
// +kubebuilder:object:root=true
2727
// +kubebuilder:storageversion
2828
// +genclient
29-
// +kubebuilder:storageversion
3029
// +genclient:nonNamespaced
3130

3231
// An EnvironmentConfig contains user-defined unstructured values for

hack/duplicate_api_type.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ FROM_PACKAGE=$(basename ${FROM_DIR})
2424
TO_PACKAGE=$(basename ${TO_DIR})
2525
TO_PATH="${TO_DIR}/zz_generated.${FROM_FILE}"
2626

27-
if [ "${STORAGE_VERSION}" = "true" ] && grep -q "+kubebuilder:storageversion" ${FROM_PATH}; then
28-
echo "Error: ${FROM_PATH} is a storage version and cannot be duplicated without dropping the storage version marker."
29-
exit 1
30-
fi
31-
3227
sed "s#^package ${FROM_PACKAGE}\$#${DO_NOT_EDIT}\n\npackage ${TO_PACKAGE}#" ${FROM_PATH} > ${TO_PATH}
3328

3429
case $STORAGE_VERSION in
3530
true)
31+
if grep -q "+kubebuilder:storageversion" ${FROM_PATH}; then
32+
echo "Error: ${FROM_PATH} is marked as storage version and cannot be duplicated without dropping the marker."
33+
exit 1
34+
fi
3635
# Add the storageVersion marker before // +genclient
37-
sed -i '\/\/ +genclient/i\/\/ +kubebuilder:storageversion' ${TO_PATH}
36+
sed -i '\/\/ +genclient$/i\/\/ +kubebuilder:storageversion' ${TO_PATH}
3837
echo "Duplicated ${FROM_PATH} (package ${FROM_PACKAGE}) to ${TO_PATH} (package ${TO_PACKAGE})."
3938
;;
4039
false)

0 commit comments

Comments
 (0)