github.com/tagesspiegel/helm-plugin-bootstrap@v0.2.3/internal/cli/bootstrap.go (about)

     1  package cli
     2  
     3  import (
     4  	"fmt"
     5  	"io"
     6  
     7  	"github.com/spf13/cobra"
     8  	"github.com/tagesspiegel/helm-plugin-bootstrap/internal/bootstrap"
     9  	"helm.sh/helm/v3/cmd/helm/require"
    10  )
    11  
    12  const bootstrapDesc = `
    13  This command modifies an existing chart to add additional files for common use cases like PodDisruptionBudget and NetworkPolicy.
    14  
    15  For example, 'helm create foo' was used to create a chart named 'foo':
    16  
    17      foo/
    18      ├── .helmignore   # Contains patterns to ignore when packaging Helm charts.
    19      ├── Chart.yaml    # Information about your chart
    20      ├── values.yaml   # The default values for your templates
    21      ├── charts/       # Charts that this chart depends on
    22      └── templates/    # The template files
    23          └── tests/    # The test files
    24  
    25  'helm bootstrap ./foo' takes a path for an argument. If Chart.yaml, values.yaml or templates folder
    26  do not exist, we will return an error. If the given destination exists and there are files in that directory,
    27  conflicting files will be overwritten, but other files will be left alone. The resulting chart will look like this:
    28  
    29  	foo/
    30  	├── .helmignore   # Contains patterns to ignore when packaging Helm charts.
    31  	├── Chart.yaml    # Information about your chart
    32  	├── values.yaml   # The default values for your templates
    33  	├── charts/       # Charts that this chart depends on
    34  	├── templates/    # The template files
    35  	│   ├── tests/    # The test files
    36  	│   ├── pdb.yaml  # PodDisruptionBudget file
    37  	│   └── networkpolicy.yaml  # NetworkPolicy file
    38  `
    39  
    40  func NewBootstrapCmd(out io.Writer) *cobra.Command {
    41  	flagForce := false
    42  	cmd := &cobra.Command{
    43  		Use:   "bootstrap PATH-TO-CHART",
    44  		Short: "Modify an existing chart to add additional files for common use cases like PodDisruptionBudget and NetworkPolicy",
    45  		Long:  bootstrapDesc,
    46  		Args:  require.ExactArgs(1),
    47  		RunE: func(cmd *cobra.Command, args []string) error {
    48  			chartsFolder := args[0]
    49  			fmt.Fprintf(out, "Bootstraping additional files for chart folder %s\n", chartsFolder)
    50  			return bootstrap.Bootstrap(chartsFolder, flagForce)
    51  		},
    52  	}
    53  	flagForce = *cmd.Flags().BoolP("force", "f", false, "Force overwriting existing files")
    54  	return cmd
    55  }