66
77 "github.com/spf13/cobra"
88
9+ "github.com/canonical/lxd/lxd/instance/instancetype"
910 "github.com/canonical/lxd/shared"
1011 "github.com/canonical/lxd/shared/api"
1112)
@@ -357,8 +358,10 @@ func (g *cmdGlobal) cmpInstanceSetKeys(instanceName string) ([]string, cobra.She
357358 return nil , cobra .ShellCompDirectiveError
358359 }
359360
360- // Fetch all config keys that can be set by a user.
361- allInstanceConfigKeys , _ := g .cmpInstanceAllKeys (instanceName )
361+ instanceType := instance .Type
362+
363+ // Fetch all config keys that can be set by a user based on instance type.
364+ allInstanceConfigKeys , _ := g .cmpInstanceKeys (instanceName )
362365
363366 // Convert slice to map[string]struct{} for O(1) lookups.
364367 keySet := make (map [string ]struct {}, len (allInstanceConfigKeys ))
@@ -374,7 +377,11 @@ func (g *cmdGlobal) cmpInstanceSetKeys(instanceName string) ([]string, cobra.She
374377 // We only want to return the intersection between allInstanceConfigKeys and configKeys to avoid returning the full instance config.
375378 _ , exists := keySet [configKey ]
376379 if exists {
377- configKeys = append (configKeys , configKey )
380+ if shared .StringHasPrefix (configKey , instancetype .ConfigKeyPrefixes ... ) {
381+ configKeys = append (configKeys , configKey )
382+ } else if instanceType == string (api .InstanceTypeContainer ) && shared .StringHasPrefix (configKey , instancetype .ConfigKeyPrefixesContainer ... ) {
383+ configKeys = append (configKeys , configKey )
384+ }
378385 }
379386 }
380387
0 commit comments