github.com/pluralsh/plural-cli@v0.9.5/pkg/bundle/stack.go (about)

     1  package bundle
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"github.com/pluralsh/plural-cli/pkg/api"
     8  	"github.com/pluralsh/plural-cli/pkg/utils"
     9  )
    10  
    11  func Stack(client api.Client, name, provider string, refresh bool) error {
    12  	s, err := client.GetStack(name, provider)
    13  	if err != nil {
    14  		return api.GetErrorResponse(err, "GetStack")
    15  	}
    16  
    17  	utils.Highlight("You're attempting to install stack: %s\n>> ", s.Name)
    18  	fmt.Println(s.Description)
    19  	fmt.Println()
    20  
    21  	repos := make([]string, 0)
    22  	for _, r := range s.Bundles {
    23  		repos = append(repos, r.Repository.Name)
    24  	}
    25  
    26  	if !utils.Confirm(fmt.Sprintf("This will install all of {%s}, do you want to proceed?", strings.Join(repos, ", "))) {
    27  		return nil
    28  	}
    29  
    30  	for _, recipe := range s.Bundles {
    31  		if err := doInstall(client, recipe, recipe.Repository.Name, provider, refresh); err != nil {
    32  			return err
    33  		}
    34  	}
    35  
    36  	return nil
    37  }