@@ -133,40 +133,40 @@ func outputResult(p *print.Printer, outputFormat string, quotas *iaas.QuotaList)
133133 table := tables .NewTable ()
134134 table .SetHeader ("NAME" , "LIMIT" , "CURRENT USAGE" , "PERCENT" )
135135 if val := quotas .BackupGigabytes ; val != nil {
136- table .AddRow ("Total size in GiB of backups [GiB]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
136+ table .AddRow ("Total size in GiB of backups [GiB]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
137137 }
138138 if val := quotas .Backups ; val != nil {
139- table .AddRow ("Number of backups [Count]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
139+ table .AddRow ("Number of backups [Count]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
140140 }
141141 if val := quotas .Gigabytes ; val != nil {
142- table .AddRow ("Total size in GiB of volumes and snapshots [GiB]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
142+ table .AddRow ("Total size in GiB of volumes and snapshots [GiB]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
143143 }
144144 if val := quotas .Networks ; val != nil {
145- table .AddRow ("Number of networks [Count]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
145+ table .AddRow ("Number of networks [Count]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
146146 }
147147 if val := quotas .Nics ; val != nil {
148- table .AddRow ("Number of network interfaces (nics) [Count]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
148+ table .AddRow ("Number of network interfaces (nics) [Count]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
149149 }
150150 if val := quotas .PublicIps ; val != nil {
151- table .AddRow ("Number of public IP addresses [Count]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
151+ table .AddRow ("Number of public IP addresses [Count]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
152152 }
153153 if val := quotas .Ram ; val != nil {
154- table .AddRow ("Amount of server RAM in MiB [MiB]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
154+ table .AddRow ("Amount of server RAM in MiB [MiB]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
155155 }
156156 if val := quotas .SecurityGroupRules ; val != nil {
157- table .AddRow ("Number of security group rules [Count]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
157+ table .AddRow ("Number of security group rules [Count]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
158158 }
159159 if val := quotas .SecurityGroups ; val != nil {
160- table .AddRow ("Number of security groups [Count]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
160+ table .AddRow ("Number of security groups [Count]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
161161 }
162162 if val := quotas .Snapshots ; val != nil {
163- table .AddRow ("Number of snapshots [Count]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
163+ table .AddRow ("Number of snapshots [Count]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
164164 }
165165 if val := quotas .Vcpu ; val != nil {
166- table .AddRow ("Number of server cores (vcpu) [Count]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
166+ table .AddRow ("Number of server cores (vcpu) [Count]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
167167 }
168168 if val := quotas .Volumes ; val != nil {
169- table .AddRow ("Number of volumes [Count]" , conv (val .GetLimit ()) , conv (val .GetUsage () ), percentage (val ))
169+ table .AddRow ("Number of volumes [Count]" , conv (val .Limit ) , conv (val .Usage ), percentage (val ))
170170 }
171171 err := table .Display (p )
172172 if err != nil {
@@ -185,11 +185,13 @@ func conv(n *int64) string {
185185}
186186
187187func percentage (val interface {
188- GetLimit () * int64
189- GetUsage () * int64
188+ GetLimitOk () ( int64 , bool )
189+ GetUsageOk () ( int64 , bool )
190190}) string {
191- if a , b := val .GetLimit (), val .GetUsage (); a != nil && b != nil {
192- return fmt .Sprintf ("%3.1f%%" , 100.0 / float64 (* a )* float64 (* b ))
191+ a , aOk := val .GetLimitOk ()
192+ b , bOk := val .GetUsageOk ()
193+ if aOk && bOk {
194+ return fmt .Sprintf ("%3.1f%%" , 100.0 / float64 (a )* float64 (b ))
193195 }
194196 return "n/a"
195197}
0 commit comments