get.porter.sh/porter@v1.3.0/pkg/porter/examples/install_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_install() { 12 // Create an instance of the Porter application 13 p := porter.New() 14 15 // Specify any of the command-line arguments to pass to the install command 16 installOpts := porter.NewInstallOptions() 17 // install a bundle with older cnab bundle schema version. It should succeed 18 installOpts.Reference = "ghcr.io/getporter/examples/porter-hello:v0.2.0" 19 20 // Always call validate on the options before executing. There is defaulting 21 // logic in the Validate calls. 22 const installationName = "porter-hello" 23 err := installOpts.Validate(context.Background(), []string{installationName}, p) 24 if err != nil { 25 log.Fatal(err) 26 } 27 28 // porter install porter-hello --reference ghcr.io/getporter/examples/porter-hello:v0.2.0 29 err = p.InstallBundle(context.Background(), installOpts) 30 if err != nil { 31 log.Fatal(err) 32 } 33 34 // Get the bundle's status after installing. 35 showOpts := porter.ShowOptions{} 36 err = showOpts.Validate([]string{installationName}, p.Context) 37 if err != nil { 38 log.Fatal(err) 39 } 40 41 installation, _, err := p.GetInstallation(context.Background(), showOpts) 42 if err != nil { 43 log.Fatal(err) 44 } 45 46 fmt.Println(installation.Status) 47 }