Add public local bundle writer
This commit is contained in:
@@ -38,3 +38,36 @@ func ExampleBuildManifest() {
|
||||
// report.txt
|
||||
// 7
|
||||
}
|
||||
|
||||
func ExampleWriteBundle() {
|
||||
sourceRoot, err := os.MkdirTemp("", "distributor-source-*")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer os.RemoveAll(sourceRoot)
|
||||
outputRoot := filepath.Join(os.TempDir(), "distributor-bundle-example")
|
||||
defer os.RemoveAll(outputRoot)
|
||||
|
||||
if err := os.WriteFile(filepath.Join(sourceRoot, "report.txt"), []byte("report\n"), 0o600); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
manifest, err := bundle.WriteBundle(bundle.WriteBundleOptions{
|
||||
Root: outputRoot,
|
||||
ID: "reports.example",
|
||||
Created: time.Date(2026, 5, 30, 11, 10, 0, 0, time.UTC),
|
||||
Files: []bundle.BundleFile{
|
||||
{SourcePath: filepath.Join(sourceRoot, "report.txt"), Path: "report.txt"},
|
||||
},
|
||||
Overwrite: true,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println(manifest.ID)
|
||||
fmt.Println(manifest.Files[0].Path)
|
||||
// Output:
|
||||
// reports.example
|
||||
// report.txt
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user