-
Notifications
You must be signed in to change notification settings - Fork 154
feat(document_db): enable in beta #3337
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2785106
feat(document_db): enable in beta
Codelax 2b38c6d
add InstanceStatus color
Codelax 2cf3171
sort import
Codelax 34e7e21
merge master
Codelax 7c036e1
enable commands
Codelax a6a2e16
sort imports
Codelax 0670626
goimports
Codelax 1a8e7b8
Merge branch 'master' into feat/document_db_beta
Monitob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package documentdb | ||
|
||
import ( | ||
"github.com/fatih/color" | ||
"github.com/scaleway/scaleway-cli/v2/internal/core" | ||
"github.com/scaleway/scaleway-cli/v2/internal/human" | ||
documentdb "github.com/scaleway/scaleway-sdk-go/api/documentdb/v1beta1" | ||
) | ||
|
||
var ( | ||
instanceStatusMarshalSpecs = human.EnumMarshalSpecs{ | ||
documentdb.InstanceStatusUnknown: &human.EnumMarshalSpec{Attribute: color.Faint, Value: "unknown"}, | ||
documentdb.InstanceStatusReady: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "ready"}, | ||
documentdb.InstanceStatusProvisioning: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "provisioning"}, | ||
documentdb.InstanceStatusConfiguring: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "configuring"}, | ||
documentdb.InstanceStatusDeleting: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "deleting"}, | ||
documentdb.InstanceStatusError: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "error"}, | ||
documentdb.InstanceStatusAutohealing: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "auto-healing"}, | ||
documentdb.InstanceStatusLocked: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "locked"}, | ||
documentdb.InstanceStatusInitializing: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "initialized"}, | ||
documentdb.InstanceStatusDiskFull: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "disk_full"}, | ||
documentdb.InstanceStatusBackuping: &human.EnumMarshalSpec{Attribute: color.FgBlue, Value: "backuping"}, | ||
documentdb.InstanceStatusSnapshotting: &human.EnumMarshalSpec{Attribute: color.FgBlue}, | ||
documentdb.InstanceStatusRestarting: &human.EnumMarshalSpec{Attribute: color.FgBlue}, | ||
} | ||
) | ||
|
||
func GetCommands() *core.Commands { | ||
cmds := GetGeneratedCommands() | ||
|
||
human.RegisterMarshalerFunc(documentdb.InstanceStatus(""), human.EnumMarshalFunc(instanceStatusMarshalSpecs)) | ||
|
||
cmds.MustFind("document-db", "engine", "list").Override(engineListBuilder) | ||
|
||
return cmds | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package documentdb | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/scaleway/scaleway-cli/v2/internal/core" | ||
documentdb "github.com/scaleway/scaleway-sdk-go/api/documentdb/v1beta1" | ||
) | ||
|
||
func engineListBuilder(c *core.Command) *core.Command { | ||
type customEngine struct { | ||
Name string `json:"name"` | ||
EngineType string `json:"engine_type"` | ||
EndOfLife *time.Time `json:"end_of_life"` | ||
} | ||
|
||
c.View = &core.View{ | ||
Fields: []*core.ViewField{ | ||
{ | ||
Label: "Name", | ||
FieldName: "Name", | ||
}, | ||
{ | ||
Label: "Engine Type", | ||
FieldName: "EngineType", | ||
}, | ||
{ | ||
Label: "End of Life", | ||
FieldName: "EndOfLife", | ||
}, | ||
}, | ||
} | ||
|
||
c.AddInterceptors(func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (i interface{}, err error) { | ||
listEngineResp, err := runner(ctx, argsI) | ||
if err != nil { | ||
return listEngineResp, err | ||
} | ||
engineList := listEngineResp.([]*documentdb.DatabaseEngine) | ||
var res []customEngine | ||
for _, engine := range engineList { | ||
for _, version := range engine.Versions { | ||
res = append(res, customEngine{ | ||
Name: version.Name, | ||
EngineType: engine.Name, | ||
EndOfLife: version.EndOfLife, | ||
}) | ||
} | ||
} | ||
|
||
return res, nil | ||
}) | ||
|
||
return c | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.