github.com/YousefHaggyHeroku/pack@v1.5.5/internal/commands/stack/suggest.go (about) 1 package stack 2 3 import ( 4 "bytes" 5 "html/template" 6 "sort" 7 8 "github.com/spf13/cobra" 9 10 "github.com/YousefHaggyHeroku/pack/logging" 11 ) 12 13 type suggestedStack struct { 14 ID string 15 Description string 16 Maintainer string 17 BuildImage string 18 RunImage string 19 } 20 21 var suggestedStacks = []suggestedStack{ 22 { 23 ID: "heroku-18", 24 Description: "The official Heroku stack based on Ubuntu 18.04", 25 Maintainer: "Heroku", 26 BuildImage: "heroku/pack:18-build", 27 RunImage: "heroku/pack:18", 28 }, 29 { 30 ID: "io.buildpacks.stacks.bionic", 31 Description: "A minimal Paketo stack based on Ubuntu 18.04", 32 Maintainer: "Paketo Project", 33 BuildImage: "paketobuildpacks/build:base-cnb", 34 RunImage: "paketobuildpacks/run:base-cnb", 35 }, 36 { 37 ID: "io.buildpacks.stacks.bionic", 38 Description: "A large Paketo stack based on Ubuntu 18.04", 39 Maintainer: "Paketo Project", 40 BuildImage: "paketobuildpacks/build:full-cnb", 41 RunImage: "paketobuildpacks/run:full-cnb", 42 }, 43 { 44 ID: "io.paketo.stacks.tiny", 45 Description: "A tiny Paketo stack based on Ubuntu 18.04, similar to distroless", 46 Maintainer: "Paketo Project", 47 BuildImage: "paketobuildpacks/build:tiny-cnb", 48 RunImage: "paketobuildpacks/run:tiny-cnb", 49 }, 50 } 51 52 func suggest(logger logging.Logger) *cobra.Command { 53 cmd := &cobra.Command{ 54 Use: "suggest", 55 Args: cobra.NoArgs, 56 Short: "Display list of recommended stacks", 57 Example: "pack stacks suggest", 58 Run: func(*cobra.Command, []string) { 59 Suggest(logger) 60 }, 61 } 62 63 return cmd 64 } 65 66 func Suggest(log logging.Logger) { 67 sort.Slice(suggestedStacks, func(i, j int) bool { return suggestedStacks[i].ID < suggestedStacks[j].ID }) 68 tmpl := template.Must(template.New("").Parse(`Stacks maintained by the community: 69 {{- range . }} 70 71 Stack ID: {{ .ID }} 72 Description: {{ .Description }} 73 Maintainer: {{ .Maintainer }} 74 Build Image: {{ .BuildImage }} 75 Run Image: {{ .RunImage }} 76 {{- end }} 77 `)) 78 79 buf := &bytes.Buffer{} 80 tmpl.Execute(buf, suggestedStacks) 81 log.Info(buf.String()) 82 }