Skip to content

Commit b9062e5

Browse files
refactor: fix typos, use kube-api labels (#80)
* use lifecycle labels from kube-api * fix lisence
1 parent 049812e commit b9062e5

3 files changed

Lines changed: 17 additions & 16 deletions

File tree

controller/utils/slow_start.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*
2-
Copyright 2016 The Kubernetes Authors.
32
Copyright 2024-2025 The KusionStack Authors.
43
54
Licensed under the Apache License, Version 2.0 (the "License");

xset/opslifecycle/label_manager.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@
1717
package opslifecycle
1818

1919
import (
20+
appsv1alpha1 "kusionstack.io/kube-api/apps/v1alpha1"
21+
2022
"kusionstack.io/kube-utils/xset/api"
2123
)
2224

2325
// OpsLifecycle default labels
2426
var (
25-
defaultOperatingLabelPrefix = "operating.opslifecycle.kusionstack.io"
26-
defaultOperationTypeLabelPrefix = "operation-type.opslifecycle.kusionstack.io"
27-
defaultOperateLabelPrefix = "operate.opslifecycle.kusionstack.io"
28-
defaultUndoOperationTypeLabelPrefix = "undo-operation-type.opslifecycle.kusionstack.io"
29-
defaultServiceAvailableLabel = "opslifecycle.kusionstack.io/service-available"
30-
defaultPreparingDeleteLabel = "opslifecycle.kusionstack.io/preparing-to-delete"
27+
defaultOperatingLabelPrefix = appsv1alpha1.PodOperatingLabelPrefix
28+
defaultOperationTypeLabelPrefix = appsv1alpha1.PodOperationTypeLabelPrefix
29+
defaultOperateLabelPrefix = appsv1alpha1.PodOperateLabelPrefix
30+
defaultUndoOperationTypeLabelPrefix = appsv1alpha1.PodUndoOperationTypeLabelPrefix
31+
defaultServiceAvailableLabel = appsv1alpha1.PodServiceAvailableLabel
32+
defaultPreparingDeleteLabel = appsv1alpha1.PodPreparingDeleteLabel
3133
)
3234

33-
var defaultLables = map[api.OperationLabelEnum]string{
35+
var defaultLabels = map[api.OperationLabelEnum]string{
3436
api.OperatingLabelPrefix: defaultOperatingLabelPrefix,
3537
api.OperationTypeLabelPrefix: defaultOperationTypeLabelPrefix,
3638
api.OperateLabelPrefix: defaultOperateLabelPrefix,
@@ -46,7 +48,7 @@ type LabelManagerImpl struct {
4648

4749
func NewLabelManager(overwrite map[api.OperationLabelEnum]string) api.LifeCycleLabelManager {
4850
labelKeys := make(map[api.OperationLabelEnum]string)
49-
for k, v := range defaultLables {
51+
for k, v := range defaultLabels {
5052
labelKeys[k] = v
5153
}
5254
if len(overwrite) > 0 {
@@ -55,15 +57,15 @@ func NewLabelManager(overwrite map[api.OperationLabelEnum]string) api.LifeCycleL
5557
}
5658
}
5759

58-
wellKnownLabelPrefilxesWithID := []string{
60+
wellKnownLabelPrefixesWithID := []string{
5961
labelKeys[api.OperatingLabelPrefix],
6062
labelKeys[api.OperationTypeLabelPrefix],
6163
labelKeys[api.UndoOperationTypeLabelPrefix],
6264
labelKeys[api.OperatingLabelPrefix],
6365
}
6466
return &LabelManagerImpl{
6567
labels: labelKeys,
66-
wellKnownLabelPrefixesWithID: wellKnownLabelPrefilxesWithID,
68+
wellKnownLabelPrefixesWithID: wellKnownLabelPrefixesWithID,
6769
}
6870
}
6971

xset/synccontrols/sync_control.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ func NewRealSyncControl(reconcileMixIn *mixin.ReconcilerMixin,
6565
if lifeCycleLabelManager == nil {
6666
lifeCycleLabelManager = opslifecycle.NewLabelManager(nil)
6767
}
68-
scaleInOpsLicecycleAdapter := xsetController.GetScaleInOpsLifecycleAdapter()
69-
if scaleInOpsLicecycleAdapter == nil {
70-
scaleInOpsLicecycleAdapter = &opslifecycle.DefaultScaleInLifecycleAdapter{LabelManager: lifeCycleLabelManager}
68+
scaleInOpsLifecycleAdapter := xsetController.GetScaleInOpsLifecycleAdapter()
69+
if scaleInOpsLifecycleAdapter == nil {
70+
scaleInOpsLifecycleAdapter = &opslifecycle.DefaultScaleInLifecycleAdapter{LabelManager: lifeCycleLabelManager}
7171
}
7272
updateLifecycleAdapter := xsetController.GetUpdateOpsLifecycleAdapter()
7373
if updateLifecycleAdapter == nil {
@@ -86,7 +86,7 @@ func NewRealSyncControl(reconcileMixIn *mixin.ReconcilerMixin,
8686
recorder: reconcileMixIn.Recorder,
8787

8888
opsLifecycleMgr: lifeCycleLabelManager,
89-
scaleInLifecycleAdapter: scaleInOpsLicecycleAdapter,
89+
scaleInLifecycleAdapter: scaleInOpsLifecycleAdapter,
9090
updateLifecycleAdapter: updateLifecycleAdapter,
9191
cacheExpectation: cacheExpectation,
9292
targetGVK: targetGVK,
@@ -101,7 +101,7 @@ func NewRealSyncControl(reconcileMixIn *mixin.ReconcilerMixin,
101101
xsetGVK: xsetGVK,
102102
targetGVK: targetGVK,
103103

104-
scaleInLifecycleAdapter: scaleInOpsLicecycleAdapter,
104+
scaleInLifecycleAdapter: scaleInOpsLifecycleAdapter,
105105
updateLifecycleAdapter: updateLifecycleAdapter,
106106
}
107107
}

0 commit comments

Comments
 (0)