Skip to content

refactor(cli): replace runValidation positional parameters with config struct #264

@nvidiajeff

Description

@nvidiajeff

Summary

Replace the 19 positional parameters of runValidation in pkg/cli/validate.go with a flat validationConfig struct to improve readability and extensibility.

Raised by @mchmarny in #250 (comment).

Current state

runValidation has 19 positional parameters (e.g., as of pkg/cli/validate.go:154-171):

// Example — current signature (may have changed since this issue was filed)
func runValidation(
    ctx context.Context,
    rec *recipe.RecipeResult,
    snap *snapshotter.Snapshot,
    phases []validator.ValidationPhaseName,
    recipeSource, snapshotSource, output string,
    outFormat serializer.Format,
    failOnError bool,
    validationNamespace string,
    resumeRunID string,
    validatorImage string,
    cleanup bool,
    imagePullSecrets []string,
    noCluster bool,
    evidenceDir string,
    evidenceResultPath string,
    tolerations []corev1.Toleration,
    nodeSelector map[string]string,
) error

Proposed change

Extract parameters into a single flat config struct, following the same pattern used by bundleCmdOptions (15 fields) and validateAgentConfig (14 fields) in this codebase. Field categories are conveyed through ordering and comments, not nested sub-structs.

// Example — proposed structure (field list may need updating at implementation time)
type validationConfig struct {
    // Input
    recipeSource   string
    snapshotSource string
    phases         []validator.ValidationPhaseName
    resumeRunID    string

    // Output
    output    string
    outFormat serializer.Format

    // Validator deployment
    validationNamespace string
    validatorImage      string
    cleanup             bool
    imagePullSecrets    []string
    noCluster           bool

    // Scheduling (propagated to validation phase Jobs)
    tolerations  []corev1.Toleration
    nodeSelector map[string]string

    // Behavior
    failOnError bool

    // Evidence
    evidenceDir        string
    evidenceResultPath string
}

func runValidation(ctx context.Context, rec *recipe.RecipeResult, snap *snapshotter.Snapshot, cfg validationConfig) error

Scope

This is a contained refactor within pkg/cli/validate.go — the struct, runValidation, and both of its call sites are in the same file.

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions