@@ -104,7 +104,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
104104}
105105
106106func buildRequest (ctx context.Context , model * inputModel , apiClient * iaas.APIClient ) iaas.ApiGetKeyPairRequest {
107- return apiClient .GetKeyPair (ctx , model .KeyPairName )
107+ return apiClient .DefaultAPI . GetKeyPair (ctx , model .KeyPairName )
108108}
109109
110110func outputResult (p * print.Printer , outputFormat string , showOnlyPublicKey bool , keyPair iaas.Keypair ) error {
@@ -113,7 +113,7 @@ func outputResult(p *print.Printer, outputFormat string, showOnlyPublicKey bool,
113113 details , err := json .MarshalIndent (keyPair , "" , " " )
114114 if showOnlyPublicKey {
115115 onlyPublicKey := map [string ]string {
116- "publicKey" : * keyPair .PublicKey ,
116+ "publicKey" : keyPair .PublicKey ,
117117 }
118118 details , err = json .MarshalIndent (onlyPublicKey , "" , " " )
119119 }
@@ -128,7 +128,7 @@ func outputResult(p *print.Printer, outputFormat string, showOnlyPublicKey bool,
128128 details , err := yaml .MarshalWithOptions (keyPair , yaml .IndentSequence (true ), yaml .UseJSONMarshaler ())
129129 if showOnlyPublicKey {
130130 onlyPublicKey := map [string ]string {
131- "publicKey" : * keyPair .PublicKey ,
131+ "publicKey" : keyPair .PublicKey ,
132132 }
133133 details , err = yaml .MarshalWithOptions (onlyPublicKey , yaml .IndentSequence (true ), yaml .UseJSONMarshaler ())
134134 }
@@ -141,16 +141,16 @@ func outputResult(p *print.Printer, outputFormat string, showOnlyPublicKey bool,
141141 return nil
142142 default :
143143 if showOnlyPublicKey {
144- p .Outputln (* keyPair .PublicKey )
144+ p .Outputln (keyPair .PublicKey )
145145 return nil
146146 }
147147 table := tables .NewTable ()
148148 table .AddRow ("KEY PAIR NAME" , utils .PtrString (keyPair .Name ))
149149 table .AddSeparator ()
150150
151- if keyPair .Labels != nil && len (* keyPair .Labels ) > 0 {
151+ if keyPair .Labels != nil && len (keyPair .Labels ) > 0 {
152152 var labels []string
153- for key , value := range * keyPair .Labels {
153+ for key , value := range keyPair .Labels {
154154 labels = append (labels , fmt .Sprintf ("%s: %s" , key , value ))
155155 }
156156 table .AddRow ("LABELS" , strings .Join (labels , "\n " ))
@@ -160,9 +160,9 @@ func outputResult(p *print.Printer, outputFormat string, showOnlyPublicKey bool,
160160 table .AddRow ("FINGERPRINT" , utils .PtrString (keyPair .Fingerprint ))
161161 table .AddSeparator ()
162162
163- truncatedPublicKey := ""
164- if keyPair .PublicKey != nil {
165- truncatedPublicKey = ( * keyPair . PublicKey ) [:maxLengthPublicKey ] + "..."
163+ truncatedPublicKey := keyPair . PublicKey
164+ if len ( keyPair .PublicKey ) > maxLengthPublicKey {
165+ truncatedPublicKey = truncatedPublicKey [:maxLengthPublicKey ] + "..."
166166 }
167167
168168 table .AddRow ("PUBLIC KEY" , truncatedPublicKey )
0 commit comments