Skip to content

Commit

Permalink
fix: check if OVF env is empty
Browse files Browse the repository at this point in the history
It seems when you do not supply OVF env vars, the demarshalled XML turns
out with nil values. This commit adds checks for that.

Fixes #3513

Signed-off-by: Jorik Jonker <jorik.jonker@eu.equinix.com>
  • Loading branch information
jonkerj authored and talos-bot committed Apr 20, 2021
1 parent da92049 commit 669a0cb
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -73,6 +73,12 @@ func readConfigFromOvf(extraConfig *rpcvmx.Config, key string) ([]byte, error) {
return nil, fmt.Errorf("failed to unmarshall XML from OVF env: %w", err)
}

if ovfEnv.Property == nil || ovfEnv.Property.Properties == nil { // no data in OVF env
log.Printf("empty OVF env")

return nil, nil
}

log.Printf("searching for property '%s' in OVF", key)

for _, property := range ovfEnv.Property.Properties { // iterate to check if our key is present
Expand Down

0 comments on commit 669a0cb

Please sign in to comment.