@@ -43,10 +43,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
4343 ),
4444 RunE : func (cmd * cobra.Command , args []string ) error {
4545 ctx := context .Background ()
46- model , err := parseInput (p , cmd , args )
47- if err != nil {
48- return err
49- }
46+ model := parseInput (p , cmd , args )
5047
5148 // Configure API client
5249 apiClient , err := client .ConfigureClient (p )
@@ -63,13 +60,16 @@ func NewCmd(p *print.Printer) *cobra.Command {
6360 }
6461
6562 // Call API
66- req := buildRequest (ctx , model , apiClient )
63+ req := buildRequest (ctx , & model , apiClient )
6764 resp , err := req .Execute ()
6865 if err != nil {
6966 return fmt .Errorf ("update key pair: %w" , err )
7067 }
68+ if resp == nil {
69+ return fmt .Errorf ("response is nil" )
70+ }
7171
72- return outputResult (p , model , resp )
72+ return outputResult (p , model , * resp )
7373 },
7474 }
7575 configureFlags (cmd )
@@ -100,7 +100,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
100100 return req .UpdateKeyPairPayload (payload )
101101}
102102
103- func parseInput (p * print.Printer , cmd * cobra.Command , inputArgs []string ) ( * inputModel , error ) {
103+ func parseInput (p * print.Printer , cmd * cobra.Command , inputArgs []string ) inputModel {
104104 keyPairName := inputArgs [0 ]
105105 globalFlags := globalflags .Parse (p , cmd )
106106
@@ -119,17 +119,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
119119 }
120120 }
121121
122- return & model , nil
122+ return model
123123}
124124
125- func outputResult (p * print.Printer , model * inputModel , keyPair * iaas.Keypair ) error {
126- if model == nil {
127- return fmt .Errorf ("model is nil" )
128- }
129- if keyPair == nil {
130- return fmt .Errorf ("keyPair is nil" )
131- }
132-
125+ func outputResult (p * print.Printer , model inputModel , keyPair iaas.Keypair ) error {
133126 var outputFormat string
134127 if model .GlobalFlagModel != nil {
135128 outputFormat = model .GlobalFlagModel .OutputFormat
0 commit comments