Skip to content

Commit 4ee0f0e

Browse files
authored
handle nil pointer exception (#514)
1 parent 767ed65 commit 4ee0f0e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

internal/cmd/beta/network/describe/describe.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,12 @@ func outputResult(p *print.Printer, outputFormat string, network *iaas.Network)
146146
table.AddSeparator()
147147
table.AddRow("STATE", *network.State)
148148
table.AddSeparator()
149-
table.AddRow("PUBLIC IP", *network.PublicIp)
150-
table.AddSeparator()
149+
150+
if network.PublicIp != nil {
151+
table.AddRow("PUBLIC IP", *network.PublicIp)
152+
table.AddSeparator()
153+
}
154+
151155
if len(ipv4nameservers) > 0 {
152156
table.AddRow("IPv4 NAME SERVERS", strings.Join(ipv4nameservers, ", "))
153157
}

internal/cmd/beta/network/list/list.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ func outputResult(p *print.Printer, outputFormat string, networks []iaas.Network
154154
table.SetHeader("ID", "Name", "Status", "Public IP")
155155

156156
for _, network := range networks {
157-
table.AddRow(*network.NetworkId, *network.Name, *network.State, *network.PublicIp)
157+
publicIp := ""
158+
if network.PublicIp != nil {
159+
publicIp = *network.PublicIp
160+
}
161+
162+
table.AddRow(*network.NetworkId, *network.Name, *network.State, publicIp)
158163
table.AddSeparator()
159164
}
160165

0 commit comments

Comments
 (0)