Skip to content

Refactor: Replace inline string splitting with robust SplitList utility #788

@xnaveenx

Description

@xnaveenx

Description

Following the merge of PR #785, which introduced the stringutils.SplitList utility, this issue tracks the refactoring of existing experiment logic to utilize this new function.

Context

Currently, many experiments use strings.Split(val, ",") directly to parse comma-separated lists (e.g., TARGET_PODS, TARGET_NODES). This approach is fragile and prone to errors when dealing with:

  • Empty strings (returning a slice of length 1 containing an empty string).
  • Trailing commas.
  • Inconsistent spacing.

This was originally highlighted in Issue #555.

Goal

Refactor the codebase to replace fragile inline splitting with the robust stringutils.SplitList utility.

Scope of Changes

The refactor will target comma-separated list parsing in the following areas:

  • Chaos Libraries: chaoslib/litmus/... (e.g., Network Chaos, Node Drain, AWS/Azure/GCP experiments).
  • Cloud Packages: pkg/cloud/... (Cloud provider status checks and helpers).
  • Probes & Utilities: pkg/probe/... and pkg/utils/....

Acceptance Criteria

  • All identified instances of strings.Split for comma-separated lists are replaced with stringutils.SplitList.
  • Import paths are updated to include github.com/litmuschaos/litmus-go/pkg/utils/stringutils.
  • go mod tidy is run to clean up dependencies.
  • Existing tests pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions