Skip to content

Commit

Permalink
Added TrimSpace where the split logic is updated
Browse files Browse the repository at this point in the history
Signed-off-by: chinmaym07 <[email protected]>
  • Loading branch information
chinmaym07 committed Oct 8, 2022
1 parent b4c083e commit 4d1950e
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func PrepareAWSSSMChaosByID(experimentsDetails *experimentTypes.ExperimentDetail
return errors.Errorf("no instance id found for chaos injection")
}
//get the instance id or list of instance ids
instanceIDList := strings.Split(experimentsDetails.EC2InstanceID, ",")
instanceIDList := strings.Split(strings.TrimSpace(experimentsDetails.EC2InstanceID), ",")

switch strings.ToLower(experimentsDetails.Sequence) {
case "serial":
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/litmus/azure-disk-loss/lib/azure-disk-loss.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func PrepareChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients
return errors.Errorf("no volume names found to detach")
}
//get the disk name or list of disk names
diskNameList := strings.Split(experimentsDetails.VirtualDiskNames, ",")
diskNameList := strings.Split(strings.TrimSpace(experimentsDetails.VirtualDiskNames), ",")
instanceNamesWithDiskNames, err := diskStatus.GetInstanceNameForDisks(diskNameList, experimentsDetails.SubscriptionID, experimentsDetails.ResourceGroup)

if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func PrepareAzureStop(experimentsDetails *experimentTypes.ExperimentDetails, cli
return errors.Errorf("no instance name found to stop")
}
// get the instance name or list of instance names
instanceNameList := strings.Split(experimentsDetails.AzureInstanceName, ",")
instanceNameList := strings.Split(strings.TrimSpace(experimentsDetails.AzureInstanceName), ",")

// watching for the abort signal and revert the chaos
go abortWatcher(experimentsDetails, instanceNameList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func PrepareEBSLossByID(experimentsDetails *experimentTypes.ExperimentDetails, c
return errors.Errorf("no volume id found to detach")
}
//get the volume id or list of instance ids
volumeIDList := strings.Split(experimentsDetails.EBSVolumeID, ",")
volumeIDList := strings.Split(strings.TrimSpace(experimentsDetails.EBSVolumeID), ",")
// watching for the abort signal and revert the chaos
go ebsloss.AbortWatcher(experimentsDetails, volumeIDList, abort, chaosDetails)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func PrepareEC2TerminateByID(experimentsDetails *experimentTypes.ExperimentDetai
return errors.Errorf("no instance id found to terminate")
}
//get the instance id or list of instance ids
instanceIDList := strings.Split(experimentsDetails.Ec2InstanceID, ",")
instanceIDList := strings.Split(strings.TrimSpace(experimentsDetails.Ec2InstanceID), ",")

// watching for the abort signal and revert the chaos
go abortWatcher(experimentsDetails, instanceIDList, chaosDetails)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func PrepareVMStop(computeService *compute.Service, experimentsDetails *experime
return errors.Errorf("no instance name found to stop")
}
// get the instance name or list of instance names
instanceNamesList := strings.Split(experimentsDetails.VMInstanceName, ",")
instanceNamesList := strings.Split(strings.TrimSpace(experimentsDetails.VMInstanceName), ",")
if experimentsDetails.InstanceZone == "" {
return errors.Errorf("no corresponding zones found for the instances")
}
// get the zone name or list of corresponding zones for the instances
instanceZonesList := strings.Split(experimentsDetails.InstanceZone, ",")
instanceZonesList := strings.Split(strings.TrimSpace(experimentsDetails.InstanceZone), ",")

if len(instanceNamesList) != len(instanceZonesList) {
return errors.Errorf("number of instances is not equal to the number of zones")
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/aws/ebs/ebs-volume-state.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func EBSStateCheckByID(volumeIDs, region string) error {
if volumeIDs == "" {
return errors.Errorf("no volumeID provided, please provide a volume to detach")
}
volumeIDList := strings.Split(volumeIDs, ",")
volumeIDList := strings.Split(strings.TrimSpace(volumeIDs), ",")
for _, id := range volumeIDList {
instanceID, _, err := GetVolumeAttachmentDetails(id, "", region)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/aws/ec2/ec2-instance-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func InstanceStatusCheckByID(instanceID, region string) error {
if instanceID == "" {
return errors.Errorf("no instance id found to terminate")
}
instanceIDList := strings.Split(instanceID, ",")
instanceIDList := strings.Split(strings.TrimSpace(instanceID), ",")
log.Infof("[Info]: The instances under chaos(IUC) are: %v", instanceIDList)
return InstanceStatusCheck(instanceIDList, region)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/azure/instance/instance-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func InstanceStatusCheckByName(azureInstanceNames, scaleSet, subscriptionID, res
if azureInstanceNames == "" {
return errors.Errorf("no instance found to check the status")
}
instanceNameList := strings.Split(azureInstanceNames, ",")
instanceNameList := strings.Split(strings.TrimSpace(azureInstanceNames), ",")
log.Infof("[Info]: The instance under chaos(IUC) are: %v", instanceNameList)
switch scaleSet {
case "enable":
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/gcp/disk-volume-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ func DiskVolumeStateCheck(computeService *compute.Service, experimentsDetails *e
return errors.Errorf("no disk name provided, please provide the name of the disk")
}

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

zonesList := strings.Split(experimentsDetails.DiskZones, ",")
zonesList := strings.Split(strings.TrimSpace(experimentsDetails.DiskZones), ",")

if len(diskNamesList) != len(zonesList) {
return errors.Errorf("unequal number of disk names and zones found, please verify the input details")
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/gcp/vm-instance-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func InstanceStatusCheckByName(computeService *compute.Service, managedInstanceG
if instanceNames == "" {
return errors.Errorf("no vm instance name found to stop")
}
instanceNamesList := strings.Split(instanceNames, ",")
instanceNamesList := strings.Split(strings.TrimSpace(instanceNames), ",")

if instanceZones == "" {
return errors.Errorf("no corresponding zones found for the instances")
}
instanceZonesList := strings.Split(instanceZones, ",")
instanceZonesList := strings.Split(strings.TrimSpace(instanceZones), ",")

if managedInstanceGroup != "enable" && managedInstanceGroup != "disable" {
return errors.Errorf("invalid value for MANAGED_INSTANCE_GROUP: %v", managedInstanceGroup)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/vmware/vm-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func VMStatusCheck(vcenterServer, vmIds, cookie string) error {
if vmIds == "" {
return errors.Errorf("no vm received, please input the target VMMoids")
}
vmIdList := strings.Split(vmIds, ",")
vmIdList := strings.Split(strings.TrimSpace(vmIds), ",")

for _, vmId := range vmIdList {

Expand Down

0 comments on commit 4d1950e

Please sign in to comment.