Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/cli/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,16 @@ Run validation without failing on check errors (informational mode):

var snap *snapshotter.Snapshot

// --no-cluster means "do not touch the cluster". The agent-deploy
// branch below contradicts that (it creates a Job and captures a
// snapshot from the live API), so a snapshot file is the only valid
// data source in that mode. Placed after recipe.LoadFromFile so
// recipe kind-check and auto-hydration still run for CLI coverage.
if snapshotFilePath == "" && cmd.Bool("no-cluster") {
return errors.New(errors.ErrCodeInvalidRequest,
"--no-cluster requires --snapshot (cannot deploy the snapshot-capture agent without cluster access)")
}

if snapshotFilePath != "" {
slog.Info("loading snapshot", "uri", snapshotFilePath)
snap, err = serializer.FromFileWithKubeconfig[snapshotter.Snapshot](snapshotFilePath, kubeconfig)
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func TestValidateCmd_RecipeKindHandling(t *testing.T) {
name: "RecipeMetadata with criteria auto-hydrates",
yamlContent: "kind: RecipeMetadata\napiVersion: aicr.nvidia.com/v1alpha1\nmetadata:\n name: test\nspec:\n criteria:\n service: eks\n accelerator: h100\n intent: training\n",
wantErr: true,
errContain: "kubernetes client",
errContain: "--no-cluster requires --snapshot",
errAbsent: "has no criteria",
},
{
Expand All @@ -292,14 +292,14 @@ func TestValidateCmd_RecipeKindHandling(t *testing.T) {
name: "RecipeResult kind passes kind check",
yamlContent: "kind: RecipeResult\napiVersion: aicr.nvidia.com/v1alpha1\n",
wantErr: true,
errContain: "kubernetes client",
errContain: "--no-cluster requires --snapshot",
errAbsent: "is required",
},
{
name: "empty kind passes kind check",
yamlContent: "apiVersion: aicr.nvidia.com/v1alpha1\n",
wantErr: true,
errContain: "kubernetes client",
errContain: "--no-cluster requires --snapshot",
errAbsent: "is required",
},
}
Expand Down
Loading