Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit bb83761

Browse files
author
noah
committed
Fix the name of field
1 parent 46d863b commit bb83761

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

model/extent/config.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ type (
4343
// It is disabled when it is empty.
4444
Review *Review `json:"review,omitempty" yaml:"review"`
4545

46-
FreezeWindows []FreezeWindow `json:"freeze_windows" yaml:"freeze_windows"`
46+
// FrozenWindows is the list of windows to freeze deployments.
47+
FrozenWindows []FrozenWindow `json:"frozen_windows" yaml:"frozen_windows"`
4748
}
4849

4950
Review struct {
5051
Enabled bool `json:"enabled" yaml:"enabled"`
5152
Reviewers []string `json:"reviewers" yaml:"reviewers"`
5253
}
5354

54-
FreezeWindow struct {
55+
FrozenWindow struct {
5556
Start string `json:"start" yaml:"start"`
5657
Duration string `json:"duration" yaml:"duration"`
5758
Location string `json:"location" yaml:"location"`
@@ -184,16 +185,16 @@ func (e *Env) HasReview() bool {
184185
// IsFreezed verifies whether the current time is in a freeze window.
185186
// It returns an error when parsing an expression is failed.
186187
func (e *Env) IsFreezed(t time.Time) (bool, error) {
187-
if len(e.FreezeWindows) == 0 {
188+
if len(e.FrozenWindows) == 0 {
188189
return false, nil
189190
}
190191

191-
for _, w := range e.FreezeWindows {
192+
for _, w := range e.FrozenWindows {
192193
s, err := cronexpr.ParseInLocation(strings.TrimSpace(w.Start), w.Location)
193194
if err != nil {
194195
return false, eutil.NewErrorWithMessage(
195196
eutil.ErrorCodeConfigInvalid,
196-
fmt.Sprintf("The crontab expression of the freeze window is invalid."),
197+
fmt.Sprint("The crontab expression of the freeze window is invalid."),
197198
err,
198199
)
199200
}
@@ -202,7 +203,7 @@ func (e *Env) IsFreezed(t time.Time) (bool, error) {
202203
if err != nil {
203204
return false, eutil.NewErrorWithMessage(
204205
eutil.ErrorCodeConfigInvalid,
205-
fmt.Sprintf("The duration of the freeze window is invalid."),
206+
fmt.Sprint("The duration of the freeze window is invalid."),
206207
err,
207208
)
208209
}

model/extent/config_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ envs:
172172
Envs: []*Env{
173173
{
174174
Name: "dev",
175-
FreezeWindows: []FreezeWindow{
175+
FrozenWindows: []FrozenWindow{
176176
{
177177
Start: "55 23 * * *",
178178
Duration: "10m",
@@ -268,7 +268,7 @@ func TestEnv_IsFreezed(t *testing.T) {
268268
{
269269
t: time.Date(2012, 12, 1, 23, 55, 10, 0, time.UTC),
270270
e: &Env{
271-
FreezeWindows: []FreezeWindow{
271+
FrozenWindows: []FrozenWindow{
272272
{
273273
Start: "55 23 * Dec *",
274274
Duration: "10m",
@@ -280,7 +280,7 @@ func TestEnv_IsFreezed(t *testing.T) {
280280
{
281281
t: time.Date(2012, 1, 1, 0, 3, 0, 0, time.UTC),
282282
e: &Env{
283-
FreezeWindows: []FreezeWindow{
283+
FrozenWindows: []FrozenWindow{
284284
{
285285
Start: "55 23 * Dec *",
286286
Duration: "10m",
@@ -291,7 +291,7 @@ func TestEnv_IsFreezed(t *testing.T) {
291291
},
292292
}
293293
e := &Env{
294-
FreezeWindows: []FreezeWindow{
294+
FrozenWindows: []FrozenWindow{
295295
{
296296
Start: "55 23 * Dec *",
297297
Duration: "10m",
@@ -313,7 +313,7 @@ func TestEnv_IsFreezed(t *testing.T) {
313313

314314
t.Run("Return false when the time is out of the window", func(t *testing.T) {
315315
e := &Env{
316-
FreezeWindows: []FreezeWindow{
316+
FrozenWindows: []FrozenWindow{
317317
{
318318
Start: "55 23 * Dec *",
319319
Duration: "10m",

0 commit comments

Comments
 (0)