Skip to content

Commit 4d1950e

Browse files
committed
Added TrimSpace where the split logic is updated
Signed-off-by: chinmaym07 <[email protected]>
1 parent b4c083e commit 4d1950e

File tree

12 files changed

+15
-15
lines changed

12 files changed

+15
-15
lines changed

chaoslib/litmus/aws-ssm-chaos/lib/ssm/aws-ssm-chaos-by-id.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func PrepareAWSSSMChaosByID(experimentsDetails *experimentTypes.ExperimentDetail
5454
return errors.Errorf("no instance id found for chaos injection")
5555
}
5656
//get the instance id or list of instance ids
57-
instanceIDList := strings.Split(experimentsDetails.EC2InstanceID, ",")
57+
instanceIDList := strings.Split(strings.TrimSpace(experimentsDetails.EC2InstanceID), ",")
5858

5959
switch strings.ToLower(experimentsDetails.Sequence) {
6060
case "serial":

chaoslib/litmus/azure-disk-loss/lib/azure-disk-loss.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func PrepareChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients
4848
return errors.Errorf("no volume names found to detach")
4949
}
5050
//get the disk name or list of disk names
51-
diskNameList := strings.Split(experimentsDetails.VirtualDiskNames, ",")
51+
diskNameList := strings.Split(strings.TrimSpace(experimentsDetails.VirtualDiskNames), ",")
5252
instanceNamesWithDiskNames, err := diskStatus.GetInstanceNameForDisks(diskNameList, experimentsDetails.SubscriptionID, experimentsDetails.ResourceGroup)
5353

5454
if err != nil {

chaoslib/litmus/azure-instance-stop/lib/azure-instance-stop.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func PrepareAzureStop(experimentsDetails *experimentTypes.ExperimentDetails, cli
4545
return errors.Errorf("no instance name found to stop")
4646
}
4747
// get the instance name or list of instance names
48-
instanceNameList := strings.Split(experimentsDetails.AzureInstanceName, ",")
48+
instanceNameList := strings.Split(strings.TrimSpace(experimentsDetails.AzureInstanceName), ",")
4949

5050
// watching for the abort signal and revert the chaos
5151
go abortWatcher(experimentsDetails, instanceNameList)

chaoslib/litmus/ebs-loss/lib/ebs-loss-by-id/lib/ebs-loss-by-id.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func PrepareEBSLossByID(experimentsDetails *experimentTypes.ExperimentDetails, c
4848
return errors.Errorf("no volume id found to detach")
4949
}
5050
//get the volume id or list of instance ids
51-
volumeIDList := strings.Split(experimentsDetails.EBSVolumeID, ",")
51+
volumeIDList := strings.Split(strings.TrimSpace(experimentsDetails.EBSVolumeID), ",")
5252
// watching for the abort signal and revert the chaos
5353
go ebsloss.AbortWatcher(experimentsDetails, volumeIDList, abort, chaosDetails)
5454

chaoslib/litmus/ec2-terminate-by-id/lib/ec2-terminate-by-id.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func PrepareEC2TerminateByID(experimentsDetails *experimentTypes.ExperimentDetai
4545
return errors.Errorf("no instance id found to terminate")
4646
}
4747
//get the instance id or list of instance ids
48-
instanceIDList := strings.Split(experimentsDetails.Ec2InstanceID, ",")
48+
instanceIDList := strings.Split(strings.TrimSpace(experimentsDetails.Ec2InstanceID), ",")
4949

5050
// watching for the abort signal and revert the chaos
5151
go abortWatcher(experimentsDetails, instanceIDList, chaosDetails)

chaoslib/litmus/gcp-vm-instance-stop/lib/gcp-vm-instance-stop.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ func PrepareVMStop(computeService *compute.Service, experimentsDetails *experime
4747
return errors.Errorf("no instance name found to stop")
4848
}
4949
// get the instance name or list of instance names
50-
instanceNamesList := strings.Split(experimentsDetails.VMInstanceName, ",")
50+
instanceNamesList := strings.Split(strings.TrimSpace(experimentsDetails.VMInstanceName), ",")
5151
if experimentsDetails.InstanceZone == "" {
5252
return errors.Errorf("no corresponding zones found for the instances")
5353
}
5454
// get the zone name or list of corresponding zones for the instances
55-
instanceZonesList := strings.Split(experimentsDetails.InstanceZone, ",")
55+
instanceZonesList := strings.Split(strings.TrimSpace(experimentsDetails.InstanceZone), ",")
5656

5757
if len(instanceNamesList) != len(instanceZonesList) {
5858
return errors.Errorf("number of instances is not equal to the number of zones")

pkg/cloud/aws/ebs/ebs-volume-state.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func EBSStateCheckByID(volumeIDs, region string) error {
104104
if volumeIDs == "" {
105105
return errors.Errorf("no volumeID provided, please provide a volume to detach")
106106
}
107-
volumeIDList := strings.Split(volumeIDs, ",")
107+
volumeIDList := strings.Split(strings.TrimSpace(volumeIDs), ",")
108108
for _, id := range volumeIDList {
109109
instanceID, _, err := GetVolumeAttachmentDetails(id, "", region)
110110
if err != nil {

pkg/cloud/aws/ec2/ec2-instance-status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func InstanceStatusCheckByID(instanceID, region string) error {
4444
if instanceID == "" {
4545
return errors.Errorf("no instance id found to terminate")
4646
}
47-
instanceIDList := strings.Split(instanceID, ",")
47+
instanceIDList := strings.Split(strings.TrimSpace(instanceID), ",")
4848
log.Infof("[Info]: The instances under chaos(IUC) are: %v", instanceIDList)
4949
return InstanceStatusCheck(instanceIDList, region)
5050
}

pkg/cloud/azure/instance/instance-status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func InstanceStatusCheckByName(azureInstanceNames, scaleSet, subscriptionID, res
7474
if azureInstanceNames == "" {
7575
return errors.Errorf("no instance found to check the status")
7676
}
77-
instanceNameList := strings.Split(azureInstanceNames, ",")
77+
instanceNameList := strings.Split(strings.TrimSpace(azureInstanceNames), ",")
7878
log.Infof("[Info]: The instance under chaos(IUC) are: %v", instanceNameList)
7979
switch scaleSet {
8080
case "enable":

pkg/cloud/gcp/disk-volume-status.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ func DiskVolumeStateCheck(computeService *compute.Service, experimentsDetails *e
107107
return errors.Errorf("no disk name provided, please provide the name of the disk")
108108
}
109109

110-
diskNamesList := strings.Split(experimentsDetails.DiskVolumeNames, ",")
110+
diskNamesList := strings.Split(strings.TrimSpace(experimentsDetails.DiskVolumeNames), ",")
111111
if experimentsDetails.DiskZones == "" {
112112
return errors.Errorf("no zone provided, please provide the zone of the disk")
113113
}
114114

115-
zonesList := strings.Split(experimentsDetails.DiskZones, ",")
115+
zonesList := strings.Split(strings.TrimSpace(experimentsDetails.DiskZones), ",")
116116

117117
if len(diskNamesList) != len(zonesList) {
118118
return errors.Errorf("unequal number of disk names and zones found, please verify the input details")

pkg/cloud/gcp/vm-instance-status.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ func InstanceStatusCheckByName(computeService *compute.Service, managedInstanceG
2929
if instanceNames == "" {
3030
return errors.Errorf("no vm instance name found to stop")
3131
}
32-
instanceNamesList := strings.Split(instanceNames, ",")
32+
instanceNamesList := strings.Split(strings.TrimSpace(instanceNames), ",")
3333

3434
if instanceZones == "" {
3535
return errors.Errorf("no corresponding zones found for the instances")
3636
}
37-
instanceZonesList := strings.Split(instanceZones, ",")
37+
instanceZonesList := strings.Split(strings.TrimSpace(instanceZones), ",")
3838

3939
if managedInstanceGroup != "enable" && managedInstanceGroup != "disable" {
4040
return errors.Errorf("invalid value for MANAGED_INSTANCE_GROUP: %v", managedInstanceGroup)

pkg/cloud/vmware/vm-status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func VMStatusCheck(vcenterServer, vmIds, cookie string) error {
6161
if vmIds == "" {
6262
return errors.Errorf("no vm received, please input the target VMMoids")
6363
}
64-
vmIdList := strings.Split(vmIds, ",")
64+
vmIdList := strings.Split(strings.TrimSpace(vmIds), ",")
6565

6666
for _, vmId := range vmIdList {
6767

0 commit comments

Comments
 (0)