Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "executor", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { if cmd.Use == "executor" { if err := logging.Configure(logLevel, logFormat, logTimestamp); err != nil { return err } validateFlags() dir := config.KanikoDir if opts.KanikoDir != constants.DefaultKanikoPath { dir = opts.KanikoDir } if err := checkKanikoDir(dir); err != nil { return err } resolveEnvironmentBuildArgs(opts.BuildArgs, os.Getenv) if !opts.NoPush && len(opts.Destinations) == 0 { return errors.New("you must provide --destination, or use --no-push") } if err := cacheFlagsValid(); err != nil { return fmt.Errorf("cache flags invalid: %w", err) } if err := resolveSourceContext(); err != nil { return fmt.Errorf("error resolving source context: %w", err) } if err := resolveDockerfilePath(); err != nil { return fmt.Errorf("error resolving dockerfile path: %w", err) } if err := resolveSecrets(); err != nil { return fmt.Errorf("error resolving secrets: %w", err) } if len(opts.Destinations) == 0 && opts.ImageNameDigestFile != "" { return errors.New("you must provide --destination if setting ImageNameDigestFile") } if len(opts.Destinations) == 0 && opts.ImageNameTagDigestFile != "" { return errors.New("you must provide --destination if setting ImageNameTagDigestFile") } if opts.IgnoreVarRun { logrus.Trace("Adding /var/run to default ignore list") util.AddToDefaultIgnoreList(util.IgnoreListEntry{ Path: "/var/run", PrefixMatchOnly: false, }) } for _, p := range opts.IgnorePaths { util.AddToDefaultIgnoreList(util.IgnoreListEntry{ Path: p, PrefixMatchOnly: false, }) } } return nil }, Run: func(cmd *cobra.Command, args []string) { if !checkContained() { if !force { exit(errors.New("kaniko should only be run inside of a container, run with the --force flag if you are sure you want to continue")) } logrus.Warn("Kaniko is being run outside of a container. This can have dangerous effects on your system") } if !opts.NoPush || opts.CacheRepo != "" { if err := executor.CheckPushPermissions(opts); err != nil { logrus.Warnf("make sure you entered the correct tag name, that you are authenticated correctly, and try again.") _, ok := os.LookupEnv("DOCKER_AUTH_CONFIG") if ok { logrus.Warnf("note that your DOCKER_AUTH_CONFIG env variable can shadow credentials from configfile") logrus.Warnf("see https://github.com/osscontainertools/kaniko/issues/280#issuecomment-3498449955") } exit(fmt.Errorf("error checking push permissions: %w", err)) } } if err := resolveRelativePaths(); err != nil { exit(fmt.Errorf("error resolving relative paths to absolute paths: %w", err)) } if err := os.Chdir("/"); err != nil { exit(fmt.Errorf("error changing to root dir: %w", err)) } image, err := executor.DoBuild(opts) if err != nil { exit(fmt.Errorf("error building image: %w", err)) } if err := executor.DoPush(image, opts); err != nil { exit(fmt.Errorf("error pushing image: %w", err)) } benchmarkFile := os.Getenv("BENCHMARK_FILE") if benchmarkFile != "" && benchmarkFile != "false" { s, err := timing.JSON() if err != nil { logrus.Warnf("Unable to write benchmark file: %s", err) return } if strings.HasPrefix(benchmarkFile, "gs://") { logrus.Info("Uploading to gcs") if err := buildcontext.UploadToBucket(strings.NewReader(s), benchmarkFile); err != nil { logrus.Infof("Unable to upload %s due to %v", benchmarkFile, err) } logrus.Infof("Benchmark file written at %s", benchmarkFile) } else { f, err := os.Create(benchmarkFile) if err != nil { logrus.Warnf("Unable to create benchmarking file %s: %s", benchmarkFile, err) return } defer f.Close() _, err = f.WriteString(s) if err != nil { logrus.Warnf("Unable to write to benchmarking file %s: %s", benchmarkFile, err) return } logrus.Infof("Benchmark file written at %s", benchmarkFile) } } }, }
RootCmd is the kaniko command that is run
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.