@@ -4032,10 +4032,7 @@ func (b *backend) ImportBucket(projectName string, poolVol *backupConfig.Config,
4032
4032
defer revert .Fail ()
4033
4033
4034
4034
// Copy bucket config from backup file if present (so BucketDBCreate can safely modify the copy if needed).
4035
- bucketConfig := make (map [string ]string , len (poolVol .Bucket .Config ))
4036
- for k , v := range poolVol .Bucket .Config {
4037
- bucketConfig [k ] = v
4038
- }
4035
+ bucketConfig := util .CloneMap (poolVol .Bucket .Config )
4039
4036
4040
4037
bucket := & api.StorageBucketsPost {
4041
4038
Name : poolVol .Bucket .Name ,
@@ -5810,10 +5807,7 @@ func (b *backend) ImportCustomVolume(projectName string, poolVol *backupConfig.C
5810
5807
defer revert .Fail ()
5811
5808
5812
5809
// Copy volume config from backup file if present (so VolumeDBCreate can safely modify the copy if needed).
5813
- volumeConfig := make (map [string ]string , len (poolVol .Volume .Config ))
5814
- for k , v := range poolVol .Volume .Config {
5815
- volumeConfig [k ] = v
5816
- }
5810
+ volumeConfig := util .CloneMap (poolVol .Volume .Config )
5817
5811
5818
5812
// Validate config and create database entry for restored storage volume.
5819
5813
err := VolumeDBCreate (b , projectName , poolVol .Volume .Name , poolVol .Volume .Description , drivers .VolumeTypeCustom , false , volumeConfig , poolVol .Volume .CreatedAt , time.Time {}, drivers .ContentType (poolVol .Volume .ContentType ), false , true )
@@ -5829,10 +5823,7 @@ func (b *backend) ImportCustomVolume(projectName string, poolVol *backupConfig.C
5829
5823
5830
5824
// Copy volume config from backup file if present
5831
5825
// (so VolumeDBCreate can safely modify the copy if needed).
5832
- snapVolumeConfig := make (map [string ]string , len (poolVolSnap .Config ))
5833
- for k , v := range poolVolSnap .Config {
5834
- snapVolumeConfig [k ] = v
5835
- }
5826
+ snapVolumeConfig := util .CloneMap (poolVolSnap .Config )
5836
5827
5837
5828
// Validate config and create database entry for restored storage volume.
5838
5829
err = VolumeDBCreate (b , projectName , fullSnapName , poolVolSnap .Description , drivers .VolumeTypeCustom , true , snapVolumeConfig , poolVolSnap .CreatedAt , time.Time {}, drivers .ContentType (poolVolSnap .ContentType ), false , true )
@@ -6881,10 +6872,7 @@ func (b *backend) ImportInstance(inst instance.Instance, poolVol *backupConfig.C
6881
6872
// Copy volume config from backup file config if present,
6882
6873
// so VolumeDBCreate can safely modify the copy if needed.
6883
6874
if poolVol .Volume != nil {
6884
- volumeConfig = make (map [string ]string , len (poolVol .Volume .Config ))
6885
- for k , v := range poolVol .Volume .Config {
6886
- volumeConfig [k ] = v
6887
- }
6875
+ volumeConfig = util .CloneMap (poolVol .Volume .Config )
6888
6876
6889
6877
if ! poolVol .Volume .CreatedAt .IsZero () {
6890
6878
creationDate = poolVol .Volume .CreatedAt
@@ -6906,10 +6894,7 @@ func (b *backend) ImportInstance(inst instance.Instance, poolVol *backupConfig.C
6906
6894
6907
6895
// Copy volume config from backup file if present,
6908
6896
// so VolumeDBCreate can safely modify the copy if needed.
6909
- snapVolumeConfig := make (map [string ]string , len (poolVolSnap .Config ))
6910
- for k , v := range poolVolSnap .Config {
6911
- snapVolumeConfig [k ] = v
6912
- }
6897
+ snapVolumeConfig := util .CloneMap (poolVolSnap .Config )
6913
6898
6914
6899
// Validate config and create database entry for recovered storage volume.
6915
6900
err = VolumeDBCreate (b , inst .Project ().Name , fullSnapName , poolVolSnap .Description , volType , true , snapVolumeConfig , poolVolSnap .CreatedAt , time.Time {}, contentType , false , true )
0 commit comments