You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7987c78
Browse filesBrowse the repository at this point in the historyBrowse files
## Changes
- Allow snapshot fields directly under `code_source` without requiring
`type` or a nested `snapshot` block.
- Preserve legacy configurations and overrides while normalizing
supported forms to one internal path.
- Hide legacy fields from help and reject mixed forms with actionable
errors.
## Why
The snapshot discriminator and wrapper are redundant now that snapshot
is the only supported code source type. Flattening the configuration
simplifies workload YAML and keeps future snapshot fields on one
implementation path.
## Tests
- `./task checks`
- `go test ./cmd/air`
- `go test ./acceptance -run TestAccept/air/config-help -tail`
- `go vet ./cmd/air`
- Built the PR CLI and successfully ran the AIR hello-world and a
one-GPU Ray Core cookbook example with flattened `code_source`,
including snapshot upload and extraction.
- `./task test` ran 11,580 tests; affected AIR tests passed, but an
unrelated `libs/dyn/jsonloader` assertion fails on changed Go JSON error
text.
- Full lint is blocked by a golangci-lint/Staticcheck `buildir` panic in
dependency package `poll`.
_This PR was written by Codex._
---------
Co-authored-by: Caroline Chen <324939130+caroline-db@users.noreply.github.com>
* Support snapshot fields directly under `code_source` without requiring `type` or a nested `snapshot` block. ([#6927](https://github.com/databricks/cli/pull/6927))
// artifact location is set bundle-wide via workspace.artifact_path, not
131
131
// per-code-source, so a per-source Volume isn't representable here.
132
132
ifsnap.RemoteVolume!=nil {
133
-
returnnil, nil, errors.New("code_source.snapshot.remote_volume is not supported by convert-to-dabs; set workspace.artifact_path in the bundle instead")
133
+
returnnil, nil, errors.New("remote_volume in code_source is not supported by convert-to-dabs; set workspace.artifact_path in the bundle instead")
returnfmt.Errorf("code_source.type must be 'snapshot', got %q", c.Type)
430
+
ifc.Type!=nil&&strings.TrimSpace(*c.Type) =="" {
431
+
returnerrors.New("code_source.type cannot be empty; omit it to use snapshot")
431
432
}
432
-
ifc.Snapshot==nil {
433
-
returnerrors.New("code_source.type='snapshot' requires a snapshot configuration")
433
+
ifc.Type!=nil&&*c.Type!="snapshot" {
434
+
returnfmt.Errorf("code_source.type must be 'snapshot', got %q", *c.Type)
434
435
}
435
-
returnc.Snapshot.validate()
436
+
ifc.Snapshot!=nil&&c.LegacySnapshot!=nil {
437
+
returnerrors.New("code_source cannot combine the nested 'snapshot' block with direct fields; remove the 'snapshot' wrapper and place all fields directly under code_source")
438
+
}
439
+
440
+
snapshot:=c.Snapshot
441
+
prefix:="code_source"
442
+
ifsnapshot==nil {
443
+
snapshot=c.LegacySnapshot
444
+
prefix="code_source.snapshot"
445
+
}
446
+
ifsnapshot==nil {
447
+
returnerrors.New("code_source requires snapshot configuration with root_path")
448
+
}
449
+
iferr:=snapshot.validate(prefix); err!=nil {
450
+
returnerr
451
+
}
452
+
453
+
c.Snapshot=snapshot
454
+
c.LegacySnapshot=nil
455
+
returnnil
436
456
}
437
457
438
458
// snapshotSourceConfig describes a local directory to tar and upload.
439
459
typesnapshotSourceConfigstruct {
440
-
RootPathstring`yaml:"root_path" help:"Root of the code source to archive. A git-pinned subdirectory packages only that subtree." required:"when code_source.snapshot is set"`
460
+
RootPathstring`yaml:"root_path" help:"Root of the code source to archive. A git-pinned subdirectory packages only that subtree." required:"when code_source is set"`
441
461
RemoteVolume*string`yaml:"remote_volume" help:"Volume to upload the archive to. Must start with /Volumes/."`
442
462
Git*gitRef`yaml:"git" help:"Pin the snapshot to a specific git revision."`
443
463
IncludePaths []string`yaml:"include_paths" help:"Restrict the archive to these paths, relative to root_path and without \"..\". Omit to include everything."`
0 commit comments