Skip to content

Commit

Permalink
rename PodTransitionRuleRuleDefinition to PodTransitionRuleDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
Eikykun committed Sep 25, 2023
1 parent a918dd1 commit b31fd50
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 51 deletions.
6 changes: 3 additions & 3 deletions apis/apps/v1alpha1/ruleset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type PodTransitionRuleRule struct {
// +optional
Filter *PodTransitionRuleRuleFilter `json:"filter,omitempty"`

// PodTransitionRuleRuleDefinition describes the detail of the rule.
PodTransitionRuleRuleDefinition `json:",inline"`
// PodTransitionRuleDefinition describes the detail of the rule.
PodTransitionRuleDefinition `json:",inline"`
}

type PodTransitionRuleRuleFilter struct {
Expand All @@ -60,7 +60,7 @@ type PodTransitionRuleRuleFilter struct {
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
}

type PodTransitionRuleRuleDefinition struct {
type PodTransitionRuleDefinition struct {

// AvailablePolicy is the rule to check if the max unavailable number is reached by current resource updated.
// +optional
Expand Down
62 changes: 31 additions & 31 deletions apis/apps/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestPodTransitionRule(t *testing.T) {
{
Stage: &stage,
Name: "serviceAvailable",
PodTransitionRuleRuleDefinition: appsv1alpha1.PodTransitionRuleRuleDefinition{
PodTransitionRuleDefinition: appsv1alpha1.PodTransitionRuleDefinition{
AvailablePolicy: &appsv1alpha1.AvailableRule{
MaxUnavailableValue: &istr,
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/controllers/podtransitionrule/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (p *Processor) Process(targets map[string]*corev1.Pod) *ProcessResult {
if p.podTransitionRule.Spec.Rules[i].Disabled || needSkip(&p.podTransitionRule.Spec.Rules[i]) {
continue
}
if p.podTransitionRule.Spec.Rules[i].Stage == nil && register.GetRuleStage(&p.podTransitionRule.Spec.Rules[i].PodTransitionRuleRuleDefinition) == p.stage {
if p.podTransitionRule.Spec.Rules[i].Stage == nil && register.GetRuleStage(&p.podTransitionRule.Spec.Rules[i].PodTransitionRuleDefinition) == p.stage {
effectiveRules = append(effectiveRules, &p.podTransitionRule.Spec.Rules[i])
}
if p.podTransitionRule.Spec.Rules[i].Stage != nil && *p.podTransitionRule.Spec.Rules[i].Stage == p.stage {
Expand Down Expand Up @@ -203,8 +203,8 @@ var (
)

func needSkip(rule *appsv1alpha1.PodTransitionRuleRule) bool {
typRule := reflect.TypeOf(rule.PodTransitionRuleRuleDefinition)
valRule := reflect.ValueOf(rule.PodTransitionRuleRuleDefinition)
typRule := reflect.TypeOf(rule.PodTransitionRuleDefinition)
valRule := reflect.ValueOf(rule.PodTransitionRuleDefinition)
fCount := valRule.NumField()
for i := 0; i < fCount; i++ {
if valRule.Field(i).IsNil() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (
{
Name: "test-webhook",
Stage: &stage,
PodTransitionRuleRuleDefinition: appsv1alpha1.PodTransitionRuleRuleDefinition{
PodTransitionRuleDefinition: appsv1alpha1.PodTransitionRuleDefinition{
Webhook: &appsv1alpha1.PodTransitionRuleRuleWebhook{
ClientConfig: appsv1alpha1.ClientConfig{
URL: "http://127.0.0.1:8888",
Expand Down
6 changes: 3 additions & 3 deletions pkg/controllers/podtransitionrule/register/rule_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ var (
ruleStage = map[string]string{}
)

func InitDefaultRuleStage(ruleDef *appsv1alpha1.PodTransitionRuleRuleDefinition, stage string) {
func InitDefaultRuleStage(ruleDef *appsv1alpha1.PodTransitionRuleDefinition, stage string) {
ruleStage[GetRuleType(ruleDef)] = stage
}

func GetRuleStage(ruleDef *appsv1alpha1.PodTransitionRuleRuleDefinition) string {
func GetRuleStage(ruleDef *appsv1alpha1.PodTransitionRuleDefinition) string {
stage := ruleStage[GetRuleType(ruleDef)]
if stage == "" && len(defaultCache.GetStages()) > 0 {
stage = defaultCache.GetStages()[0]
}
return stage
}

func GetRuleType(ruleDef *appsv1alpha1.PodTransitionRuleRuleDefinition) string {
func GetRuleType(ruleDef *appsv1alpha1.PodTransitionRuleDefinition) string {
typRule := reflect.TypeOf(*ruleDef)
valRule := reflect.ValueOf(*ruleDef)
fCount := valRule.NumField()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

func TestStage(t *testing.T) {
g := gomega.NewGomegaWithT(t)
def := appsv1alpha1.PodTransitionRuleRuleDefinition{
def := appsv1alpha1.PodTransitionRuleDefinition{
AvailablePolicy: &appsv1alpha1.AvailableRule{},
}
InitDefaultRuleStage(&def, "test-stage")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ var _ = Describe("PodTransitionRule Validating", func() {
},
Rules: []appsv1alpha1.PodTransitionRuleRule{
{
Name: "",
PodTransitionRuleRuleDefinition: appsv1alpha1.PodTransitionRuleRuleDefinition{},
Name: "",
PodTransitionRuleDefinition: appsv1alpha1.PodTransitionRuleDefinition{},
},
},
}
Expand All @@ -73,7 +73,7 @@ var _ = Describe("PodTransitionRule Validating", func() {
Rules: []appsv1alpha1.PodTransitionRuleRule{
{
Name: "webhook",
PodTransitionRuleRuleDefinition: appsv1alpha1.PodTransitionRuleRuleDefinition{
PodTransitionRuleDefinition: appsv1alpha1.PodTransitionRuleDefinition{
Webhook: &appsv1alpha1.PodTransitionRuleRuleWebhook{},
},
},
Expand All @@ -87,7 +87,7 @@ var _ = Describe("PodTransitionRule Validating", func() {
Rules: []appsv1alpha1.PodTransitionRuleRule{
{
Name: "webhook",
PodTransitionRuleRuleDefinition: appsv1alpha1.PodTransitionRuleRuleDefinition{
PodTransitionRuleDefinition: appsv1alpha1.PodTransitionRuleDefinition{
Webhook: &appsv1alpha1.PodTransitionRuleRuleWebhook{
ClientConfig: appsv1alpha1.ClientConfig{
URL: "https://github.com",
Expand All @@ -107,7 +107,7 @@ var _ = Describe("PodTransitionRule Validating", func() {
Rules: []appsv1alpha1.PodTransitionRuleRule{
{
Name: "available",
PodTransitionRuleRuleDefinition: appsv1alpha1.PodTransitionRuleRuleDefinition{
PodTransitionRuleDefinition: appsv1alpha1.PodTransitionRuleDefinition{
AvailablePolicy: &appsv1alpha1.AvailableRule{},
},
},
Expand All @@ -122,7 +122,7 @@ var _ = Describe("PodTransitionRule Validating", func() {
Rules: []appsv1alpha1.PodTransitionRuleRule{
{
Name: "available",
PodTransitionRuleRuleDefinition: appsv1alpha1.PodTransitionRuleRuleDefinition{
PodTransitionRuleDefinition: appsv1alpha1.PodTransitionRuleDefinition{
AvailablePolicy: &appsv1alpha1.AvailableRule{
MaxUnavailableValue: &istr,
},
Expand All @@ -140,7 +140,7 @@ var _ = Describe("PodTransitionRule Validating", func() {
Rules: []appsv1alpha1.PodTransitionRuleRule{
{
Name: "label",
PodTransitionRuleRuleDefinition: appsv1alpha1.PodTransitionRuleRuleDefinition{
PodTransitionRuleDefinition: appsv1alpha1.PodTransitionRuleDefinition{
LabelCheck: &appsv1alpha1.LabelCheckRule{},
},
},
Expand All @@ -154,7 +154,7 @@ var _ = Describe("PodTransitionRule Validating", func() {
Rules: []appsv1alpha1.PodTransitionRuleRule{
{
Name: "label",
PodTransitionRuleRuleDefinition: appsv1alpha1.PodTransitionRuleRuleDefinition{
PodTransitionRuleDefinition: appsv1alpha1.PodTransitionRuleDefinition{
LabelCheck: &appsv1alpha1.LabelCheckRule{
Requires: &metav1.LabelSelector{
MatchLabels: map[string]string{"test": "test"},
Expand Down

0 comments on commit b31fd50

Please sign in to comment.