MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / pkgBuildCmd

Function pkgBuildCmd

src/cmd/linuxkit/pkg_build.go:33–322  ·  view source on GitHub ↗

some logic clarification: pkg build - builds unless is in cache or published in registry pkg build --pull - builds unless is in cache or published in registry; pulls from registry if not in cache pkg build --force - always builds even if

()

Source from the content-addressed store, hash-verified

31// pkg push - equivalent to pkg build --push
32
33func pkgBuildCmd() *cobra.Command {
34 var (
35 force bool
36 pull bool
37 push bool
38 ignoreCache bool
39 docker bool
40 platforms string
41 skipPlatforms string
42 builders string
43 builderImage string
44 builderConfig string
45 builderRestart bool
46 preCacheImages bool
47 release string
48 nobuild bool
49 manifest bool
50 cacheDir = flagOverEnvVarOverDefaultString{def: defaultLinuxkitCache(), envVar: envVarCacheDir}
51 sbomScanner string
52 dockerfile string
53 buildArgFiles []string
54 progress string
55 ssh []string
56 dryRun bool
57 )
58 cmd := &cobra.Command{
59 Use: "build",
60 Short: "build an OCI package from a directory with a yaml configuration file",
61 Long: `Build an OCI package from a directory with a yaml configuration file.
62 'path' specifies the path to the package source directory.
63`,
64 Example: ` linuxkit pkg build [options] pkg/dir/`,
65 Args: cobra.MinimumNArgs(1),
66 RunE: func(cmd *cobra.Command, args []string) error {
67 pkgs, err := pkglib.NewFromConfig(pkglibConfig, args...)
68 if err != nil {
69 return err
70 }
71
72 if nobuild && force {
73 return errors.New("flags -force and -nobuild conflict")
74 }
75 if pull && force {
76 return errors.New("flags -force and -pull conflict")
77 }
78
79 var opts []pkglib.BuildOpt
80 if force {
81 opts = append(opts, pkglib.WithBuildForce())
82 }
83 if ignoreCache {
84 opts = append(opts, pkglib.WithBuildIgnoreCache())
85 }
86 if preCacheImages {
87 opts = append(opts, pkglib.WithPreCacheImages())
88 }
89 if pull {
90 opts = append(opts, pkglib.WithBuildPull())

Callers 1

pkgCmdFunction · 0.85

Calls 9

defaultLinuxkitCacheFunction · 0.85
buildPlatformBuildersMapFunction · 0.85
ProcessBuildArgsMethod · 0.80
ArchesMethod · 0.80
StringMethod · 0.65
OpenMethod · 0.65
TagMethod · 0.65
BuildMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected