@@ -843,15 +843,7 @@ func (r *ProtocolLXD) CopyInstance(source InstanceServer, instance api.Instance,
843843
844844 opAPI := op .Get ()
845845
846- targetSecrets := map [string ]string {}
847- for k , v := range opAPI .Metadata {
848- vStr , ok := v .(string )
849- if ! ok {
850- continue
851- }
852-
853- targetSecrets [k ] = vStr
854- }
846+ targetSecrets := operationMetadataSecrets (opAPI .Metadata )
855847
856848 // Prepare the source request
857849 target := api.InstancePostTarget {}
@@ -876,15 +868,7 @@ func (r *ProtocolLXD) CopyInstance(source InstanceServer, instance api.Instance,
876868
877869 opAPI := op .Get ()
878870
879- sourceSecrets := map [string ]string {}
880- for k , v := range opAPI .Metadata {
881- vStr , ok := v .(string )
882- if ! ok {
883- continue
884- }
885-
886- sourceSecrets [k ] = vStr
887- }
871+ sourceSecrets := operationMetadataSecrets (opAPI .Metadata )
888872
889873 // Relay mode migration
890874 if args != nil && args .Mode == "relay" {
@@ -901,15 +885,7 @@ func (r *ProtocolLXD) CopyInstance(source InstanceServer, instance api.Instance,
901885 targetOpAPI := targetOp .Get ()
902886
903887 // Extract the websockets
904- targetSecrets := map [string ]string {}
905- for k , v := range targetOpAPI .Metadata {
906- vStr , ok := v .(string )
907- if ! ok {
908- continue
909- }
910-
911- targetSecrets [k ] = vStr
912- }
888+ targetSecrets := operationMetadataSecrets (targetOpAPI .Metadata )
913889
914890 // Launch the relay
915891 err = r .proxyMigration (targetOp .(* operation ), targetSecrets , source , op .(* operation ), sourceSecrets )
@@ -1961,15 +1937,7 @@ func (r *ProtocolLXD) CopyInstanceSnapshot(source InstanceServer, instanceName s
19611937
19621938 opAPI := op .Get ()
19631939
1964- targetSecrets := map [string ]string {}
1965- for k , v := range opAPI .Metadata {
1966- vStr , ok := v .(string )
1967- if ! ok {
1968- continue
1969- }
1970-
1971- targetSecrets [k ] = vStr
1972- }
1940+ targetSecrets := operationMetadataSecrets (opAPI .Metadata )
19731941
19741942 // Prepare the source request
19751943 target := api.InstancePostTarget {}
@@ -1994,15 +1962,7 @@ func (r *ProtocolLXD) CopyInstanceSnapshot(source InstanceServer, instanceName s
19941962
19951963 opAPI := op .Get ()
19961964
1997- sourceSecrets := map [string ]string {}
1998- for k , v := range opAPI .Metadata {
1999- vStr , ok := v .(string )
2000- if ! ok {
2001- continue
2002- }
2003-
2004- sourceSecrets [k ] = vStr
2005- }
1965+ sourceSecrets := operationMetadataSecrets (opAPI .Metadata )
20061966
20071967 // Relay mode migration
20081968 if args != nil && args .Mode == "relay" {
@@ -2019,15 +1979,7 @@ func (r *ProtocolLXD) CopyInstanceSnapshot(source InstanceServer, instanceName s
20191979 targetOpAPI := targetOp .Get ()
20201980
20211981 // Extract the websockets
2022- targetSecrets := map [string ]string {}
2023- for k , v := range targetOpAPI .Metadata {
2024- vStr , ok := v .(string )
2025- if ! ok {
2026- continue
2027- }
2028-
2029- targetSecrets [k ] = vStr
2030- }
1982+ targetSecrets := operationMetadataSecrets (targetOpAPI .Metadata )
20311983
20321984 // Launch the relay
20331985 err = r .proxyMigration (targetOp .(* operation ), targetSecrets , source , op .(* operation ), sourceSecrets )
0 commit comments