This commit is contained in:
Murat Kabilov 2017-05-24 18:39:04 +02:00
parent 20e343ebc9
commit ac92696d3b
3 changed files with 11 additions and 11 deletions

View File

@ -95,7 +95,7 @@ type PostgresqlList struct {
} }
var alphaRegexp = regexp.MustCompile("^[a-zA-Z]*$") var alphaRegexp = regexp.MustCompile("^[a-zA-Z]*$")
var weekdays = map[string]int{"Sun":0, "Mon":1, "Tue":2, "Wed":3, "Thu":4, "Fri":5, "Sat":6} var weekdays = map[string]int{"Sun": 0, "Mon": 1, "Tue": 2, "Wed": 3, "Thu": 4, "Fri": 5, "Sat": 6}
func ParseTime(s string) (t time.Time, wd time.Weekday, wdProvided bool, err error) { func ParseTime(s string) (t time.Time, wd time.Weekday, wdProvided bool, err error) {
var timeLayout string var timeLayout string
@ -170,7 +170,7 @@ func (m *MaintenanceWindow) UnmarshalJSON(data []byte) error {
return fmt.Errorf("'From' time must be prior to the 'To' time") return fmt.Errorf("'From' time must be prior to the 'To' time")
} }
if (int(got.StartWeekday) + 6) % 7 > (int(got.EndWeekday) + 6) % 7 { if (int(got.StartWeekday)+6)%7 > (int(got.EndWeekday)+6)%7 {
return fmt.Errorf("'From' weekday must be prior to the 'To' weekday") return fmt.Errorf("'From' weekday must be prior to the 'To' weekday")
} }

View File

@ -1,11 +1,11 @@
package spec package spec
import ( import (
"bytes"
"encoding/json"
"reflect" "reflect"
"testing" "testing"
"time" "time"
"encoding/json"
"bytes"
"k8s.io/client-go/pkg/api/unversioned" "k8s.io/client-go/pkg/api/unversioned"
"k8s.io/client-go/pkg/api/v1" "k8s.io/client-go/pkg/api/v1"
@ -178,9 +178,9 @@ var clExp = Postgresql{
PostgresqlParam: PostgresqlParam{ PostgresqlParam: PostgresqlParam{
PgVersion: "9.6", PgVersion: "9.6",
Parameters: map[string]string{ Parameters: map[string]string{
"shared_buffers": "32MB", "shared_buffers": "32MB",
"max_connections": "10", "max_connections": "10",
"log_statement": "all", "log_statement": "all",
}, },
}, },
Volume: Volume{ Volume: Volume{
@ -206,14 +206,14 @@ var clExp = Postgresql{
TeamID: "ACID", TeamID: "ACID",
AllowedSourceRanges: []string{"127.0.0.1/32"}, AllowedSourceRanges: []string{"127.0.0.1/32"},
NumberOfInstances: 2, NumberOfInstances: 2,
Users: map[string]UserFlags{"zalando": UserFlags{"superuser", "createdb"}}, Users: map[string]UserFlags{"zalando": {"superuser", "createdb"}},
MaintenanceWindows: []MaintenanceWindow{MaintenanceWindow{ MaintenanceWindows: []MaintenanceWindow{{
StartWeekday: time.Monday, StartWeekday: time.Monday,
StartTime: mustParseTime("01:00"), StartTime: mustParseTime("01:00"),
EndTime: mustParseTime("06:00"), EndTime: mustParseTime("06:00"),
EndWeekday: time.Sunday, EndWeekday: time.Sunday,
}, },
MaintenanceWindow{ {
StartWeekday: time.Saturday, StartWeekday: time.Saturday,
StartTime: mustParseTime("00:00"), StartTime: mustParseTime("00:00"),
EndTime: mustParseTime("04:00"), EndTime: mustParseTime("04:00"),

View File

@ -1,9 +1,9 @@
package spec package spec
import ( import (
"database/sql"
"fmt" "fmt"
"strings" "strings"
"database/sql"
"k8s.io/client-go/pkg/api/v1" "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/types" "k8s.io/client-go/pkg/types"