Skip to content

Commit e29376a

Browse files
ColdsteelRailclaude
andcommitted
refactor: remove HostnamePolicyNone enum value, use nil for "no policy"
The combination of pointer + optional + sentinel value "None" created three states (nil, None, PodName) where only two are meaningful, which is error-prone (comparing *hp == HostnamePolicyNone vs hp == nil). Drop the None enum value and treat nil/empty as "no policy", consistent with CollaSetSpec convention (e.g. NamingStrategy uses pointer-or-nil for "unset"). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d9872bb commit e29376a

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

apps/v1alpha1/collaset_types.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ const (
5757
)
5858

5959
// HostnamePolicyType indicates how the pod's hostname is determined.
60-
// +kubebuilder:validation:Enum=None;PodName
60+
// +kubebuilder:validation:Enum=PodName
6161
type HostnamePolicyType string
6262

6363
const (
64-
// HostnamePolicyNone means no hostname policy is applied.
65-
HostnamePolicyNone HostnamePolicyType = "None"
6664
// HostnamePolicyPodName sets the pod's hostname to the pod name.
6765
// This requires namingStrategy.podNamingSuffixPolicy to be PersistentSequence,
6866
// as the pod name must be deterministic before creation.
@@ -140,6 +138,7 @@ type CollaSetSpec struct {
140138
NamingStrategy *NamingStrategy `json:"namingStrategy,omitempty"`
141139

142140
// HostnamePolicy indicates how the pod's hostname is determined.
141+
// When unset (nil), no hostname policy is applied.
143142
// When set to "PodName", the pod's spec.hostname will be set to the pod name.
144143
// This requires NamingStrategy.PodNamingSuffixPolicy to be PersistentSequence.
145144
// +optional

config/crd/apps/apps.kusionstack.io_collasets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ spec:
8686
hostnamePolicy:
8787
description: |-
8888
HostnamePolicy indicates how the pod's hostname is determined.
89+
When unset (nil), no hostname policy is applied.
8990
When set to "PodName", the pod's spec.hostname will be set to the pod name.
9091
This requires NamingStrategy.PodNamingSuffixPolicy to be PersistentSequence.
9192
enum:
92-
- None
9393
- PodName
9494
type: string
9595
namingStrategy:

0 commit comments

Comments
 (0)