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

Commit 784214f

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

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

model/extent/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package extent
22

33
import (
4-
"fmt"
54
"regexp"
65
"strconv"
76
"strings"
@@ -43,15 +42,16 @@ type (
4342
// It is disabled when it is empty.
4443
Review *Review `json:"review,omitempty" yaml:"review"`
4544

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

4949
Review struct {
5050
Enabled bool `json:"enabled" yaml:"enabled"`
5151
Reviewers []string `json:"reviewers" yaml:"reviewers"`
5252
}
5353

54-
FreezeWindow struct {
54+
FrozenWindow struct {
5555
Start string `json:"start" yaml:"start"`
5656
Duration string `json:"duration" yaml:"duration"`
5757
Location string `json:"location" yaml:"location"`
@@ -184,16 +184,16 @@ func (e *Env) HasReview() bool {
184184
// IsFreezed verifies whether the current time is in a freeze window.
185185
// It returns an error when parsing an expression is failed.
186186
func (e *Env) IsFreezed(t time.Time) (bool, error) {
187-
if len(e.FreezeWindows) == 0 {
187+
if len(e.FrozenWindows) == 0 {
188188
return false, nil
189189
}
190190

191-
for _, w := range e.FreezeWindows {
191+
for _, w := range e.FrozenWindows {
192192
s, err := cronexpr.ParseInLocation(strings.TrimSpace(w.Start), w.Location)
193193
if err != nil {
194194
return false, eutil.NewErrorWithMessage(
195195
eutil.ErrorCodeConfigInvalid,
196-
fmt.Sprintf("The crontab expression of the freeze window is invalid."),
196+
"The crontab expression of the freeze window is invalid.",
197197
err,
198198
)
199199
}
@@ -202,7 +202,7 @@ func (e *Env) IsFreezed(t time.Time) (bool, error) {
202202
if err != nil {
203203
return false, eutil.NewErrorWithMessage(
204204
eutil.ErrorCodeConfigInvalid,
205-
fmt.Sprintf("The duration of the freeze window is invalid."),
205+
"The duration of the freeze window is invalid.",
206206
err,
207207
)
208208
}

model/extent/config_test.go

Lines changed: 5 additions & 5 deletions
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)