mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
command: nil-check for instance state when showing state
This commit is contained in:
parent
879cb2f8e6
commit
edbdad8fdb
@ -92,7 +92,10 @@ func formatStateModuleExpand(
|
|||||||
|
|
||||||
rs := m.Resources[k]
|
rs := m.Resources[k]
|
||||||
is := rs.Primary
|
is := rs.Primary
|
||||||
id := is.ID
|
var id string
|
||||||
|
if is != nil {
|
||||||
|
id = is.ID
|
||||||
|
}
|
||||||
if id == "" {
|
if id == "" {
|
||||||
id = "<not created>"
|
id = "<not created>"
|
||||||
}
|
}
|
||||||
@ -105,6 +108,7 @@ func formatStateModuleExpand(
|
|||||||
buf.WriteString(fmt.Sprintf("%s:%s\n", name, taintStr))
|
buf.WriteString(fmt.Sprintf("%s:%s\n", name, taintStr))
|
||||||
buf.WriteString(fmt.Sprintf(" id = %s\n", id))
|
buf.WriteString(fmt.Sprintf(" id = %s\n", id))
|
||||||
|
|
||||||
|
if is != nil {
|
||||||
// Sort the attributes
|
// Sort the attributes
|
||||||
attrKeys := make([]string, 0, len(is.Attributes))
|
attrKeys := make([]string, 0, len(is.Attributes))
|
||||||
for ak, _ := range is.Attributes {
|
for ak, _ := range is.Attributes {
|
||||||
@ -123,6 +127,7 @@ func formatStateModuleExpand(
|
|||||||
buf.WriteString(fmt.Sprintf(" %s = %s\n", ak, av))
|
buf.WriteString(fmt.Sprintf(" %s = %s\n", ak, av))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buf.WriteString("[reset]\n")
|
buf.WriteString("[reset]\n")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user