Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iaas-api-go@v1.3.1 #95

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions collector/auto_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ func TestAutoBackupCollector_Collect(t *testing.T) {
Name: "AutoBackup",
DiskID: 201,
MaximumNumberOfArchives: 3,
BackupSpanWeekdays: []types.EBackupSpanWeekday{
types.BackupSpanWeekdays.Sunday,
types.BackupSpanWeekdays.Monday,
types.BackupSpanWeekdays.Tuesday,
BackupSpanWeekdays: []types.EDayOfTheWeek{
types.DaysOfTheWeek.Sunday,
types.DaysOfTheWeek.Monday,
types.DaysOfTheWeek.Tuesday,
},
Tags: types.Tags{"tag1", "tag2"},
Description: "desc",
Expand Down Expand Up @@ -126,10 +126,10 @@ func TestAutoBackupCollector_Collect(t *testing.T) {
Name: "AutoBackup",
DiskID: 201,
MaximumNumberOfArchives: 3,
BackupSpanWeekdays: []types.EBackupSpanWeekday{
types.BackupSpanWeekdays.Sunday,
types.BackupSpanWeekdays.Monday,
types.BackupSpanWeekdays.Tuesday,
BackupSpanWeekdays: []types.EDayOfTheWeek{
types.DaysOfTheWeek.Sunday,
types.DaysOfTheWeek.Monday,
types.DaysOfTheWeek.Tuesday,
},
Tags: types.Tags{"tag1", "tag2"},
Description: "desc",
Expand Down Expand Up @@ -176,10 +176,10 @@ func TestAutoBackupCollector_Collect(t *testing.T) {
Name: "AutoBackup",
DiskID: 201,
MaximumNumberOfArchives: 3,
BackupSpanWeekdays: []types.EBackupSpanWeekday{
types.BackupSpanWeekdays.Sunday,
types.BackupSpanWeekdays.Monday,
types.BackupSpanWeekdays.Tuesday,
BackupSpanWeekdays: []types.EDayOfTheWeek{
types.DaysOfTheWeek.Sunday,
types.DaysOfTheWeek.Monday,
types.DaysOfTheWeek.Tuesday,
},
Tags: types.Tags{"tag1", "tag2"},
Description: "desc",
Expand Down
18 changes: 2 additions & 16 deletions collector/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,15 @@ func flattenStringSlice(values []string) string {
return fmt.Sprintf(",%s,", strings.Join(values, ","))
}

func flattenBackupSpanWeekdays(values []types.EBackupSpanWeekday) string {
func flattenBackupSpanWeekdays(values []types.EDayOfTheWeek) string {
if len(values) == 0 {
return ""
}

// sort
sort.Slice(values, func(i, j int) bool {
return backupSpanWeekdaysOrder[values[i]] < backupSpanWeekdaysOrder[values[j]]
})
types.SortDayOfTheWeekList(values)

var strValues []string
for _, v := range values {
strValues = append(strValues, string(v))
}
return fmt.Sprintf(",%s,", strings.Join(strValues, ","))
}

var backupSpanWeekdaysOrder = map[types.EBackupSpanWeekday]int{
types.BackupSpanWeekdays.Sunday: 0,
types.BackupSpanWeekdays.Monday: 1,
types.BackupSpanWeekdays.Tuesday: 2,
types.BackupSpanWeekdays.Wednesday: 3,
types.BackupSpanWeekdays.Thursday: 4,
types.BackupSpanWeekdays.Friday: 5,
types.BackupSpanWeekdays.Saturday: 6,
}
12 changes: 6 additions & 6 deletions examples/fake/generate-fake-store-json/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ func createAutoBackup(caller iaas.APICaller) {
_, err = backupOp.Create(context.Background(), "is1a", &iaas.AutoBackupCreateRequest{
Name: "example",
DiskID: disk.ID,
BackupSpanWeekdays: []types.EBackupSpanWeekday{
types.BackupSpanWeekdays.Monday,
types.BackupSpanWeekdays.Wednesday,
types.BackupSpanWeekdays.Friday,
BackupSpanWeekdays: []types.EDayOfTheWeek{
types.DaysOfTheWeek.Monday,
types.DaysOfTheWeek.Wednesday,
types.DaysOfTheWeek.Friday,
},
MaximumNumberOfArchives: 5,
Description: "desc",
Expand Down Expand Up @@ -135,8 +135,8 @@ func createDatabase(caller iaas.APICaller) {
BackupSetting: &iaas.DatabaseSettingBackup{
Rotate: 3,
Time: "00:00",
DayOfWeek: []types.EBackupSpanWeekday{
types.BackupSpanWeekdays.Sunday,
DayOfWeek: []types.EDayOfTheWeek{
types.DaysOfTheWeek.Sunday,
},
},
Name: "example",
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/client_model v0.2.0
github.com/sacloud/api-client-go v0.2.1
github.com/sacloud/iaas-api-go v1.2.1
github.com/sacloud/iaas-service-go v1.2.0
github.com/sacloud/iaas-api-go v1.3.1
github.com/sacloud/iaas-service-go v1.3.1
github.com/sacloud/packages-go v0.0.5
github.com/stretchr/testify v1.8.0
)
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ github.com/sacloud/api-client-go v0.2.1 h1:jl02ZG6cM+mcH4eDYg0cxCFFuTOVTOjUCLYL4
github.com/sacloud/api-client-go v0.2.1/go.mod h1:8fmYy5OpT3W8ltV5ZxF8evultNwKpduGN4YKmU9Af7w=
github.com/sacloud/go-http v0.1.2 h1:a84HkeDHxDD1vIA6HiOT72a3fwwJueZBwuGP6zVtEJU=
github.com/sacloud/go-http v0.1.2/go.mod h1:gvWaT8LFBFnSBFVrznOQXC62uad46bHZQM8w+xoH3eE=
github.com/sacloud/iaas-api-go v1.2.1 h1:QuIWelF6KSQLPeDJy4HMNbQND7XQlZyjyRnc8lGiG1I=
github.com/sacloud/iaas-api-go v1.2.1/go.mod h1:+ScynU5gBwq+rA7qw6EppIQwRhXSMkGoRkZlFIj5v+g=
github.com/sacloud/iaas-service-go v1.2.0 h1:cfVAG1IPVV0gRyZ+onPq9qOhsBV8AEAM1A3krU1P2cs=
github.com/sacloud/iaas-service-go v1.2.0/go.mod h1:mi88b6BqTtYqVjSitdVg5qSiyINdhuKdShY+3MFWIwQ=
github.com/sacloud/iaas-api-go v1.3.1 h1:UmP9r4NNd1YucmeTzzJtsFsT9d/RYvJn2tP+HmC4yMk=
github.com/sacloud/iaas-api-go v1.3.1/go.mod h1:CoqpRYBG2NRB5xfqTfZNyh2lVLKyLkE/HV9ISqmbhGc=
github.com/sacloud/iaas-service-go v1.3.1 h1:ltMadQPUGzpSHD3k6XrqWy1XykIgZFseu/AA67qHjAI=
github.com/sacloud/iaas-service-go v1.3.1/go.mod h1:2mkOWoEk8gdHuxShI6RLssw1g4Sd6vc92ErcNaL2vPk=
github.com/sacloud/packages-go v0.0.5 h1:NXTQNyyp/3ugM4CANtLBJLejFESzfWu4GPUURN4NJrA=
github.com/sacloud/packages-go v0.0.5/go.mod h1:XWMBSNHT9YKY3lCh6yJsx1o1RRQQGpuhNqJA6bSHdD4=
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
Expand Down