dockerfile

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DFCmd = &cobra.Command{
	Use:     "dockerfile",
	Short:   "perform dockerfile operations",
	Aliases: []string{"df"},
	Long: `
	bsf dockerfile init
	`,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println(styles.HintStyle.Render("hint: use bsf dockerfile with a subcomand"))
		os.Exit(1)
	},
}

DFCmd represents the generate command

View Source
var DGCmd = &cobra.Command{
	Use:     "digests",
	Short:   "Replace Dockerfile image tags with immutable digests",
	Aliases: []string{"dg"},
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) < 1 {
			fmt.Println(styles.HintStyle.Render("hint:", "run `bsf dockerfile digests <Dockerfile>` to replace image tags with digests"))
			os.Exit(1)
		}

		dockerfile := args[0]

		r := replacer.NewContainerImagesReplacer(config.DefaultConfig())

		str, err := r.ParsePath(context.TODO(), dockerfile)
		if err != nil {
			fmt.Println(styles.ErrorStyle.Render("error in parsing Dockerfile contents", err.Error()))
			os.Exit(1)
		}

		if err = processOutput(dockerfile, str.Modified); err != nil {
			fmt.Println(styles.ErrorStyle.Render("error in writing Dockerfile contents", err.Error()))
			os.Exit(1)
		}
	},
}

DGCmd represents the digest command

View Source
var InitCmd = &cobra.Command{
	Use:   "init",
	Short: "Init a Dockerfile into your project",
	Run: func(cmd *cobra.Command, args []string) {

		dfType, err := bsfinit.IoPrompt("Which language is your app in?(Go/Python/Rust)")
		if err != nil {
			fmt.Println(styles.ErrorStyle.Render("error:", err.Error()))
			os.Exit(1)
		}

		isHermetic, err := bsfinit.YesNoPrompt("Would you like a hermetic build? This requires you to vendor your dependencies(Recommended: yes)")
		if err != nil {
			fmt.Println(styles.ErrorStyle.Render("error:", err.Error()))
			os.Exit(1)
		}

		dfFile, err := os.Create("Dockerfile")
		if err != nil {
			fmt.Println(styles.ErrorStyle.Render("error:", err.Error()))
			os.Exit(1)
		}
		defer dfFile.Close()

		err = df.GenerateDF(dfFile, dfType, isHermetic)
		if err != nil {
			fmt.Println(styles.ErrorStyle.Render("error:", err.Error()))
			os.Exit(1)
		}
	},
}

InitCmd represents the init command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL