diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3f67f4b..c799f3f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -70,11 +70,4 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - fetch-depth: 0 - - name: TruffleHog OSS - uses: trufflesecurity/trufflehog@main - with: - path: ./ - base: ${{ github.event.repository.default_branch }} - head: HEAD - extra_args: --debug --json + fetch-depth: 0 \ No newline at end of file diff --git a/apps/v1alpha1/collaset_types.go b/apps/v1alpha1/collaset_types.go index c0d4e99..2704674 100644 --- a/apps/v1alpha1/collaset_types.go +++ b/apps/v1alpha1/collaset_types.go @@ -28,6 +28,18 @@ const ( CollaSetUpdate CollaSetConditionType = "Update" ) +// PodNamingSuffixPolicy indicates how a new pod name suffix part is generated. +type PodNamingSuffixPolicy string + +const ( + // PodNamingSuffixPolicyPersistentSequence uses persistent sequential numbers as pod name suffix. + PodNamingSuffixPolicyPersistentSequence PodNamingSuffixPolicy = "PersistentSequence" + // PodNamingSuffixPolicyRandom uses collaset name as pod generateName, which is the prefix + // of pod name. Kubernetes then adds a random string as suffix after the generateName. + // This is defaulting policy. + PodNamingSuffixPolicyRandom PodNamingSuffixPolicy = "Random" +) + // PersistentVolumeClaimRetentionPolicyType is a string enumeration of the policies that will determine // which action will be applied on volumes from the VolumeClaimTemplates when the CollaSet is // deleted or scaled down. @@ -107,6 +119,10 @@ type CollaSetSpec struct { // +optional ScaleStrategy ScaleStrategy `json:"scaleStrategy,omitempty"` + // NamigPolicy indicates the strategy detail that will be used for replica naming + // +optional + NamingStrategy *NamingStrategy `json:"namingStrategy,omitempty"` + // Indicate the number of histories to be conserved // If unspecified, defaults to 20 // +optional @@ -144,6 +160,13 @@ type ScaleStrategy struct { OperationDelaySeconds *int32 `json:"operationDelaySeconds,omitempty"` } +type NamingStrategy struct { + // PodNamingSuffixPolicy is a string enumeration that determaines how pod name suffix will be generated. + // A collaset pod name contains two parts to be placed in a string formation %s-%s; the prefix is collaset + // name, and the suffix is determined by PodNamingSuffixPolicy. + PodNamingSuffixPolicy PodNamingSuffixPolicy `json:"podNamingSuffixPolicy,omitempty"` +} + type PersistentVolumeClaimRetentionPolicy struct { // WhenDeleted specifies what happens to PVCs created from CollaSet // VolumeClaimTemplates when the CollaSet is deleted. The default policy diff --git a/apps/v1alpha1/zz_generated.deepcopy.go b/apps/v1alpha1/zz_generated.deepcopy.go index 46e2795..a5f38db 100644 --- a/apps/v1alpha1/zz_generated.deepcopy.go +++ b/apps/v1alpha1/zz_generated.deepcopy.go @@ -244,6 +244,11 @@ func (in *CollaSetSpec) DeepCopyInto(out *CollaSetSpec) { } in.UpdateStrategy.DeepCopyInto(&out.UpdateStrategy) in.ScaleStrategy.DeepCopyInto(&out.ScaleStrategy) + if in.NamingStrategy != nil { + in, out := &in.NamingStrategy, &out.NamingStrategy + *out = new(NamingStrategy) + **out = **in + } return } @@ -388,6 +393,22 @@ func (in *LabelCheckRule) DeepCopy() *LabelCheckRule { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NamingStrategy) DeepCopyInto(out *NamingStrategy) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamingStrategy. +func (in *NamingStrategy) DeepCopy() *NamingStrategy { + if in == nil { + return nil + } + out := new(NamingStrategy) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OperationJob) DeepCopyInto(out *OperationJob) { *out = *in diff --git a/config/crd/apps/apps.kusionstack.io_collasets.yaml b/config/crd/apps/apps.kusionstack.io_collasets.yaml index 274a049..a738915 100644 --- a/config/crd/apps/apps.kusionstack.io_collasets.yaml +++ b/config/crd/apps/apps.kusionstack.io_collasets.yaml @@ -83,6 +83,17 @@ spec: If unspecified, defaults to 20 format: int32 type: integer + namingStrategy: + description: NamigPolicy indicates the strategy detail that will be + used for replica naming + properties: + podNamingSuffixPolicy: + description: |- + PodNamingSuffixPolicy is a string enumeration that determaines how pod name suffix will be generated. + A collaset pod name contains two parts to be placed in a string formation %s-%s; the prefix is collaset + name, and the suffix is determined by PodNamingSuffixPolicy. + type: string + type: object paused: description: |- Indicates that the scaling and updating is paused and will not be processed by the