diff --git a/client/lxd_instances.go b/client/lxd_instances.go index f40129160109..cdd10770d590 100644 --- a/client/lxd_instances.go +++ b/client/lxd_instances.go @@ -978,7 +978,11 @@ func (r *ProtocolLXD) CopyInstance(source InstanceServer, instance api.Instance, targetSecrets := map[string]string{} for k, v := range opAPI.Metadata { - targetSecrets[k] = v.(string) + vStr, ok := v.(string) + if !ok { + continue + } + targetSecrets[k] = vStr } // Prepare the source request @@ -1006,7 +1010,11 @@ func (r *ProtocolLXD) CopyInstance(source InstanceServer, instance api.Instance, sourceSecrets := map[string]string{} for k, v := range opAPI.Metadata { - sourceSecrets[k] = v.(string) + vStr, ok := v.(string) + if !ok { + continue + } + sourceSecrets[k] = vStr } // Relay mode migration @@ -1026,7 +1034,11 @@ func (r *ProtocolLXD) CopyInstance(source InstanceServer, instance api.Instance, // Extract the websockets targetSecrets := map[string]string{} for k, v := range targetOpAPI.Metadata { - targetSecrets[k] = v.(string) + vStr, ok := v.(string) + if !ok { + continue + } + targetSecrets[k] = vStr } // Launch the relay @@ -1268,9 +1280,15 @@ func (r *ProtocolLXD) ExecInstance(instanceName string, exec api.InstanceExecPos value, ok := opAPI.Metadata["fds"] if ok { - values := value.(map[string]any) - for k, v := range values { - fds[k] = v.(string) + values, ok := value.(map[string]any) + if ok { + for k, v := range values { + vStr, ok := v.(string) + if !ok { + continue + } + fds[k] = vStr + } } } @@ -1285,7 +1303,11 @@ func (r *ProtocolLXD) ExecInstance(instanceName string, exec api.InstanceExecPos outputs, ok := opAPI.Metadata["output"].(map[string]any) if ok { for k, v := range outputs { - outputFiles[k] = v.(string) + vStr, ok := v.(string) + if !ok { + continue + } + outputFiles[k] = vStr } } @@ -2017,7 +2039,11 @@ func (r *ProtocolLXD) CopyInstanceSnapshot(source InstanceServer, instanceName s targetSecrets := map[string]string{} for k, v := range opAPI.Metadata { - targetSecrets[k] = v.(string) + vStr, ok := v.(string) + if !ok { + continue + } + targetSecrets[k] = vStr } // Prepare the source request @@ -2045,7 +2071,11 @@ func (r *ProtocolLXD) CopyInstanceSnapshot(source InstanceServer, instanceName s sourceSecrets := map[string]string{} for k, v := range opAPI.Metadata { - sourceSecrets[k] = v.(string) + vStr, ok := v.(string) + if !ok { + continue + } + sourceSecrets[k] = vStr } // Relay mode migration @@ -2065,7 +2095,11 @@ func (r *ProtocolLXD) CopyInstanceSnapshot(source InstanceServer, instanceName s // Extract the websockets targetSecrets := map[string]string{} for k, v := range targetOpAPI.Metadata { - targetSecrets[k] = v.(string) + vStr, ok := v.(string) + if !ok { + continue + } + targetSecrets[k] = vStr } // Launch the relay @@ -2621,9 +2655,15 @@ func (r *ProtocolLXD) ConsoleInstance(instanceName string, console api.InstanceC value, ok := opAPI.Metadata["fds"] if ok { - values := value.(map[string]any) - for k, v := range values { - fds[k] = v.(string) + values, ok := value.(map[string]any) + if ok { + for k, v := range values { + vStr, ok := v.(string) + if !ok { + continue + } + fds[k] = vStr + } } } @@ -2713,9 +2753,15 @@ func (r *ProtocolLXD) ConsoleInstanceDynamic(instanceName string, console api.In value, ok := opAPI.Metadata["fds"] if ok { - values := value.(map[string]any) - for k, v := range values { - fds[k] = v.(string) + values, ok := value.(map[string]any) + if ok { + for k, v := range values { + vStr, ok := v.(string) + if !ok { + continue + } + fds[k] = vStr + } } }