get.porter.sh/porter@v1.3.0/pkg/porter/examples/pull_example_test.go (about) 1 package examples_test 2 3 import ( 4 "context" 5 "fmt" 6 "log" 7 8 "get.porter.sh/porter/pkg/porter" 9 ) 10 11 func ExamplePorter_pullBundle() { 12 ctx := context.Background() 13 // Create an instance of the Porter application 14 p := porter.New() 15 16 // Specify which bundle to pull and any additional flags such as --force (repull) or --insecure-registry 17 pullOpts := porter.BundlePullOptions{} 18 pullOpts.Reference = "ghcr.io/getporter/examples/porter-hello:v0.2.0" 19 // This doesn't have a validate function, otherwise we would call it now 20 21 // Pull a bundle to Porter's cache, ~/.porter/cache 22 // This isn't exposed as a command in Porter's CLI 23 cachedBundle, err := p.PullBundle(ctx, pullOpts) 24 if err != nil { 25 log.Fatal(err) 26 } 27 28 // Print the path to the bundle.json in Proter's cache 29 fmt.Println(cachedBundle.BundlePath) 30 }