2025-11-13 19:27:12 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"log"
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
"github.com/Snider/Borg/pkg/datanode"
|
2025-11-14 21:23:11 +00:00
|
|
|
"github.com/Snider/Borg/pkg/tim"
|
2025-11-13 19:27:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
// Create a new DataNode to hold the root filesystem.
|
|
|
|
|
dn := datanode.New()
|
2025-11-14 21:23:11 +00:00
|
|
|
dn.AddData("hello.txt", []byte("Hello from within the TIM!"))
|
2025-11-13 19:27:12 +00:00
|
|
|
|
|
|
|
|
// Create a new TerminalIsolationMatrix from the DataNode.
|
2025-11-14 21:23:11 +00:00
|
|
|
m, err := tim.FromDataNode(dn)
|
2025-11-13 19:27:12 +00:00
|
|
|
if err != nil {
|
2025-11-14 21:23:11 +00:00
|
|
|
log.Fatalf("Failed to create TIM: %v", err)
|
2025-11-13 19:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
2025-11-14 21:23:11 +00:00
|
|
|
// Serialize the TIM to a tarball.
|
2025-11-13 19:27:12 +00:00
|
|
|
tarball, err := m.ToTar()
|
|
|
|
|
if err != nil {
|
2025-11-14 21:23:11 +00:00
|
|
|
log.Fatalf("Failed to serialize TIM to tar: %v", err)
|
2025-11-13 19:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write the tarball to a file.
|
2025-11-14 21:23:11 +00:00
|
|
|
err = os.WriteFile("programmatic.tim", tarball, 0644)
|
2025-11-13 19:27:12 +00:00
|
|
|
if err != nil {
|
2025-11-14 21:23:11 +00:00
|
|
|
log.Fatalf("Failed to write TIM file: %v", err)
|
2025-11-13 19:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
2025-11-14 21:23:11 +00:00
|
|
|
log.Println("Successfully created programmatic.tim")
|
2025-11-13 19:27:12 +00:00
|
|
|
}
|