66
77 "github.com/stackitcloud/stackit-cli/internal/pkg/types"
88
9+ "github.com/spf13/cobra"
10+ mariadb "github.com/stackitcloud/stackit-sdk-go/services/mariadb/v1api"
11+
912 "github.com/stackitcloud/stackit-cli/internal/pkg/args"
1013 "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
1114 "github.com/stackitcloud/stackit-cli/internal/pkg/examples"
@@ -14,10 +17,6 @@ import (
1417 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
1518 "github.com/stackitcloud/stackit-cli/internal/pkg/services/mariadb/client"
1619 mariadbUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/mariadb/utils"
17- "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
18-
19- "github.com/spf13/cobra"
20- "github.com/stackitcloud/stackit-sdk-go/services/mariadb"
2120)
2221
2322const (
@@ -58,7 +57,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
5857 return err
5958 }
6059
61- instanceLabel , err := mariadbUtils .GetInstanceName (ctx , apiClient , model .ProjectId , model .InstanceId )
60+ instanceLabel , err := mariadbUtils .GetInstanceName (ctx , apiClient . DefaultAPI , model .ProjectId , model .InstanceId )
6261 if err != nil {
6362 params .Printer .Debug (print .ErrorLevel , "get instance name: %v" , err )
6463 instanceLabel = model .InstanceId
@@ -109,7 +108,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
109108}
110109
111110func buildRequest (ctx context.Context , model * inputModel , apiClient * mariadb.APIClient ) mariadb.ApiCreateCredentialsRequest {
112- req := apiClient .CreateCredentials (ctx , model .ProjectId , model .InstanceId )
111+ req := apiClient .DefaultAPI . CreateCredentials (ctx , model .ProjectId , model .InstanceId )
113112 return req
114113}
115114
@@ -118,26 +117,26 @@ func outputResult(p *print.Printer, outputFormat string, showPassword bool, inst
118117 return fmt .Errorf ("response is nil" )
119118 }
120119
121- if ! showPassword && resp .HasRaw () && resp . Raw . Credentials != nil {
122- resp .Raw .Credentials .Password = utils . Ptr ( "hidden" )
120+ if ! showPassword && resp .HasRaw () {
121+ resp .Raw .Credentials .Password = "hidden"
123122 }
124123
125124 return p .OutputResult (outputFormat , resp , func () error {
126- p .Outputf ("Created credentials for instance %q. Credentials ID: %s\n \n " , instanceLabel , utils . PtrString ( resp .Id ) )
125+ p .Outputf ("Created credentials for instance %q. Credentials ID: %s\n \n " , instanceLabel , resp .Id )
127126 // The username field cannot be set by the user, so we only display it if it's not returned empty
128- if resp .HasRaw () && resp . Raw . Credentials != nil {
129- if username := resp .Raw .Credentials .Username ; username != nil && * username != "" {
130- p .Outputf ("Username: %s\n " , * username )
127+ if resp .HasRaw () {
128+ if resp .Raw .Credentials .Username != "" {
129+ p .Outputf ("Username: %s\n " , resp . Raw . Credentials . Username )
131130 }
132131 if ! showPassword {
133132 p .Outputf ("Password: <hidden>\n " )
134133 } else {
135- p .Outputf ("Password: %s\n " , utils . PtrString ( resp .Raw .Credentials .Password ) )
134+ p .Outputf ("Password: %s\n " , resp .Raw .Credentials .Password )
136135 }
137- p .Outputf ("Host: %s\n " , utils . PtrString ( resp .Raw .Credentials .Host ) )
138- p .Outputf ("Port: %s \n " , utils . PtrString ( resp .Raw .Credentials .Port ) )
136+ p .Outputf ("Host: %s\n " , resp .Raw .Credentials .Host )
137+ p .Outputf ("Port: %d \n " , resp .Raw .Credentials .Port )
139138 }
140- p .Outputf ("URI: %s\n " , utils . PtrString ( resp .Uri ) )
139+ p .Outputf ("URI: %s\n " , resp .Uri )
141140 return nil
142141 })
143142}
0 commit comments