diff --git a/lxc/completion.go b/lxc/completion.go index d70348c0cea6..f3850b2d85d4 100644 --- a/lxc/completion.go +++ b/lxc/completion.go @@ -359,8 +359,6 @@ func (g *cmdGlobal) cmpInstanceSetKeys(instanceName string) ([]string, cobra.She return nil, cobra.ShellCompDirectiveError } - instanceType := instance.Type - // Fetch all config keys that can be set by a user based on instance type. allInstanceConfigKeys, _ := g.cmpInstanceKeys(instanceName) @@ -377,12 +375,9 @@ func (g *cmdGlobal) cmpInstanceSetKeys(instanceName string) ([]string, cobra.She for configKey := range instance.Config { // We only want to return the intersection between allInstanceConfigKeys and configKeys to avoid returning the full instance config. _, exists := keySet[configKey] - if exists { - if shared.StringHasPrefix(configKey, instancetype.ConfigKeyPrefixesAny...) { - configKeys = append(configKeys, configKey) - } else if instanceType == string(api.InstanceTypeContainer) && shared.StringHasPrefix(configKey, instancetype.ConfigKeyPrefixesContainer...) { - configKeys = append(configKeys, configKey) - } + knownPrefixes := append(instancetype.ConfigKeyPrefixesAny, instancetype.ConfigKeyPrefixesContainer...) + if exists || strings.HasPrefix(configKey, instancetype.ConfigVolatilePrefix) || shared.StringHasPrefix(configKey, knownPrefixes...) { + configKeys = append(configKeys, configKey) } }