Task Description
Implement the oc bundle validate [PATH] CLI command using TDD (red-to-green approach).
TDD Cycle
RED Phase - Write Failing Tests
Create comprehensive tests in cmd/bundle_test.go:
TestBundleValidateCommand_ValidBundle - validates valid bundle, exits 0
TestBundleValidateCommand_InvalidBundle - validates invalid bundle, exits 1
TestBundleValidateCommand_DefaultPath - uses current directory when no PATH arg
TestBundleValidateCommand_ArchivePath - validates .tar.gz archive path
TestBundleValidateCommand_NonExistentPath - handles non-existent path gracefully
TestBundleValidateCommand_FormattedOutput - errors formatted with styles package
GREEN Phase - Implement to Pass
Add to cmd/bundle.go:
bundleValidateCmd cobra.Command with:
- Use: "validate [PATH]"
- Short: "Validate bundle structure and manifest"
- Args: cobra.MaximumNArgs(1)
- RunE: runBundleValidate
runBundleValidate(cmd *cobra.Command, args []string) error function:
- Resolve path (default to "." if no arg)
- Use
bundle.ResolveToLocal() for directory/archive normalization
- Call
bundle.ValidateBundle() from T1
- Print errors with
styles.Error(), warnings with styles.Warning()
- Exit code 0 on valid, 1 on validation errors, 2 on system errors
Acceptance Criteria
Task Description
Implement the
oc bundle validate [PATH]CLI command using TDD (red-to-green approach).TDD Cycle
RED Phase - Write Failing Tests
Create comprehensive tests in
cmd/bundle_test.go:TestBundleValidateCommand_ValidBundle- validates valid bundle, exits 0TestBundleValidateCommand_InvalidBundle- validates invalid bundle, exits 1TestBundleValidateCommand_DefaultPath- uses current directory when no PATH argTestBundleValidateCommand_ArchivePath- validates.tar.gzarchive pathTestBundleValidateCommand_NonExistentPath- handles non-existent path gracefullyTestBundleValidateCommand_FormattedOutput- errors formatted with styles packageGREEN Phase - Implement to Pass
Add to
cmd/bundle.go:bundleValidateCmdcobra.Command with:runBundleValidate(cmd *cobra.Command, args []string) errorfunction:bundle.ResolveToLocal()for directory/archive normalizationbundle.ValidateBundle()from T1styles.Error(), warnings withstyles.Warning()Acceptance Criteria
.tar.gzarchivescmd/bundle.go