github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/cmd/cnbBuild_generated.go (about)

     1  // Code generated by piper's step-generator. DO NOT EDIT.
     2  
     3  package cmd
     4  
     5  import (
     6  	"fmt"
     7  	"os"
     8  	"path/filepath"
     9  	"reflect"
    10  	"strings"
    11  	"time"
    12  
    13  	"github.com/SAP/jenkins-library/pkg/config"
    14  	"github.com/SAP/jenkins-library/pkg/gcs"
    15  	"github.com/SAP/jenkins-library/pkg/log"
    16  	"github.com/SAP/jenkins-library/pkg/piperenv"
    17  	"github.com/SAP/jenkins-library/pkg/splunk"
    18  	"github.com/SAP/jenkins-library/pkg/telemetry"
    19  	"github.com/SAP/jenkins-library/pkg/validation"
    20  	"github.com/bmatcuk/doublestar"
    21  	"github.com/spf13/cobra"
    22  )
    23  
    24  type cnbBuildOptions struct {
    25  	ContainerImageName        string                   `json:"containerImageName,omitempty"`
    26  	ContainerImageAlias       string                   `json:"containerImageAlias,omitempty"`
    27  	ContainerImageTag         string                   `json:"containerImageTag,omitempty"`
    28  	ContainerRegistryURL      string                   `json:"containerRegistryUrl,omitempty"`
    29  	Buildpacks                []string                 `json:"buildpacks,omitempty"`
    30  	PreBuildpacks             []string                 `json:"preBuildpacks,omitempty"`
    31  	PostBuildpacks            []string                 `json:"postBuildpacks,omitempty"`
    32  	BuildEnvVars              map[string]interface{}   `json:"buildEnvVars,omitempty"`
    33  	Path                      string                   `json:"path,omitempty"`
    34  	ProjectDescriptor         string                   `json:"projectDescriptor,omitempty"`
    35  	DockerConfigJSON          string                   `json:"dockerConfigJSON,omitempty"`
    36  	DockerConfigJSONCPE       string                   `json:"dockerConfigJSONCPE,omitempty"`
    37  	CustomTLSCertificateLinks []string                 `json:"customTlsCertificateLinks,omitempty"`
    38  	AdditionalTags            []string                 `json:"additionalTags,omitempty"`
    39  	Bindings                  map[string]interface{}   `json:"bindings,omitempty"`
    40  	MultipleImages            []map[string]interface{} `json:"multipleImages,omitempty"`
    41  	PreserveFiles             []string                 `json:"preserveFiles,omitempty"`
    42  	BuildSettingsInfo         string                   `json:"buildSettingsInfo,omitempty"`
    43  	CreateBOM                 bool                     `json:"createBOM,omitempty"`
    44  	SyftDownloadURL           string                   `json:"syftDownloadUrl,omitempty"`
    45  	RunImage                  string                   `json:"runImage,omitempty"`
    46  	DefaultProcess            string                   `json:"defaultProcess,omitempty"`
    47  }
    48  
    49  type cnbBuildCommonPipelineEnvironment struct {
    50  	container struct {
    51  		registryURL   string
    52  		imageDigest   string
    53  		imageNameTag  string
    54  		imageNames    []string
    55  		imageNameTags []string
    56  		imageDigests  []string
    57  	}
    58  	custom struct {
    59  		buildSettingsInfo string
    60  	}
    61  }
    62  
    63  func (p *cnbBuildCommonPipelineEnvironment) persist(path, resourceName string) {
    64  	content := []struct {
    65  		category string
    66  		name     string
    67  		value    interface{}
    68  	}{
    69  		{category: "container", name: "registryUrl", value: p.container.registryURL},
    70  		{category: "container", name: "imageDigest", value: p.container.imageDigest},
    71  		{category: "container", name: "imageNameTag", value: p.container.imageNameTag},
    72  		{category: "container", name: "imageNames", value: p.container.imageNames},
    73  		{category: "container", name: "imageNameTags", value: p.container.imageNameTags},
    74  		{category: "container", name: "imageDigests", value: p.container.imageDigests},
    75  		{category: "custom", name: "buildSettingsInfo", value: p.custom.buildSettingsInfo},
    76  	}
    77  
    78  	errCount := 0
    79  	for _, param := range content {
    80  		err := piperenv.SetResourceParameter(path, resourceName, filepath.Join(param.category, param.name), param.value)
    81  		if err != nil {
    82  			log.Entry().WithError(err).Error("Error persisting piper environment.")
    83  			errCount++
    84  		}
    85  	}
    86  	if errCount > 0 {
    87  		log.Entry().Error("failed to persist Piper environment")
    88  	}
    89  }
    90  
    91  type cnbBuildReports struct {
    92  }
    93  
    94  func (p *cnbBuildReports) persist(stepConfig cnbBuildOptions, gcpJsonKeyFilePath string, gcsBucketId string, gcsFolderPath string, gcsSubFolder string) {
    95  	if gcsBucketId == "" {
    96  		log.Entry().Info("persisting reports to GCS is disabled, because gcsBucketId is empty")
    97  		return
    98  	}
    99  	log.Entry().Info("Uploading reports to Google Cloud Storage...")
   100  	content := []gcs.ReportOutputParam{
   101  		{FilePattern: "**/bom-*.xml", ParamRef: "", StepResultType: "sbom"},
   102  	}
   103  	envVars := []gcs.EnvVar{
   104  		{Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: gcpJsonKeyFilePath, Modified: false},
   105  	}
   106  	gcsClient, err := gcs.NewClient(gcs.WithEnvVars(envVars))
   107  	if err != nil {
   108  		log.Entry().Errorf("creation of GCS client failed: %v", err)
   109  		return
   110  	}
   111  	defer gcsClient.Close()
   112  	structVal := reflect.ValueOf(&stepConfig).Elem()
   113  	inputParameters := map[string]string{}
   114  	for i := 0; i < structVal.NumField(); i++ {
   115  		field := structVal.Type().Field(i)
   116  		if field.Type.String() == "string" {
   117  			paramName := strings.Split(field.Tag.Get("json"), ",")
   118  			paramValue, _ := structVal.Field(i).Interface().(string)
   119  			inputParameters[paramName[0]] = paramValue
   120  		}
   121  	}
   122  	if err := gcs.PersistReportsToGCS(gcsClient, content, inputParameters, gcsFolderPath, gcsBucketId, gcsSubFolder, doublestar.Glob, os.Stat); err != nil {
   123  		log.Entry().Errorf("failed to persist reports: %v", err)
   124  	}
   125  }
   126  
   127  // CnbBuildCommand Executes Cloud Native Buildpacks.
   128  func CnbBuildCommand() *cobra.Command {
   129  	const STEP_NAME = "cnbBuild"
   130  
   131  	metadata := cnbBuildMetadata()
   132  	var stepConfig cnbBuildOptions
   133  	var startTime time.Time
   134  	var commonPipelineEnvironment cnbBuildCommonPipelineEnvironment
   135  	var reports cnbBuildReports
   136  	var logCollector *log.CollectorHook
   137  	var splunkClient *splunk.Splunk
   138  	telemetryClient := &telemetry.Telemetry{}
   139  
   140  	var createCnbBuildCmd = &cobra.Command{
   141  		Use:   STEP_NAME,
   142  		Short: "Executes Cloud Native Buildpacks.",
   143  		Long: `Executes a Cloud Native Buildpacks build for creating Docker image(s).
   144  **Important:** Please note, that the cnbBuild step is in **beta** state, and there could be breaking changes before we remove the beta notice.`,
   145  		PreRunE: func(cmd *cobra.Command, _ []string) error {
   146  			startTime = time.Now()
   147  			log.SetStepName(STEP_NAME)
   148  			log.SetVerbose(GeneralConfig.Verbose)
   149  
   150  			GeneralConfig.GitHubAccessTokens = ResolveAccessTokens(GeneralConfig.GitHubTokens)
   151  
   152  			path, _ := os.Getwd()
   153  			fatalHook := &log.FatalHook{CorrelationID: GeneralConfig.CorrelationID, Path: path}
   154  			log.RegisterHook(fatalHook)
   155  
   156  			err := PrepareConfig(cmd, &metadata, STEP_NAME, &stepConfig, config.OpenPiperFile)
   157  			if err != nil {
   158  				log.SetErrorCategory(log.ErrorConfiguration)
   159  				return err
   160  			}
   161  			log.RegisterSecret(stepConfig.DockerConfigJSON)
   162  			log.RegisterSecret(stepConfig.DockerConfigJSONCPE)
   163  
   164  			if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 {
   165  				sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID)
   166  				log.RegisterHook(&sentryHook)
   167  			}
   168  
   169  			if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 {
   170  				splunkClient = &splunk.Splunk{}
   171  				logCollector = &log.CollectorHook{CorrelationID: GeneralConfig.CorrelationID}
   172  				log.RegisterHook(logCollector)
   173  			}
   174  
   175  			if err = log.RegisterANSHookIfConfigured(GeneralConfig.CorrelationID); err != nil {
   176  				log.Entry().WithError(err).Warn("failed to set up SAP Alert Notification Service log hook")
   177  			}
   178  
   179  			validation, err := validation.New(validation.WithJSONNamesForStructFields(), validation.WithPredefinedErrorMessages())
   180  			if err != nil {
   181  				return err
   182  			}
   183  			if err = validation.ValidateStruct(stepConfig); err != nil {
   184  				log.SetErrorCategory(log.ErrorConfiguration)
   185  				return err
   186  			}
   187  
   188  			return nil
   189  		},
   190  		Run: func(_ *cobra.Command, _ []string) {
   191  			stepTelemetryData := telemetry.CustomData{}
   192  			stepTelemetryData.ErrorCode = "1"
   193  			handler := func() {
   194  				commonPipelineEnvironment.persist(GeneralConfig.EnvRootPath, "commonPipelineEnvironment")
   195  				reports.persist(stepConfig, GeneralConfig.GCPJsonKeyFilePath, GeneralConfig.GCSBucketId, GeneralConfig.GCSFolderPath, GeneralConfig.GCSSubFolder)
   196  				config.RemoveVaultSecretFiles()
   197  				stepTelemetryData.Duration = fmt.Sprintf("%v", time.Since(startTime).Milliseconds())
   198  				stepTelemetryData.ErrorCategory = log.GetErrorCategory().String()
   199  				stepTelemetryData.PiperCommitHash = GitCommit
   200  				telemetryClient.SetData(&stepTelemetryData)
   201  				telemetryClient.Send()
   202  				if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 {
   203  					splunkClient.Initialize(GeneralConfig.CorrelationID,
   204  						GeneralConfig.HookConfig.SplunkConfig.Dsn,
   205  						GeneralConfig.HookConfig.SplunkConfig.Token,
   206  						GeneralConfig.HookConfig.SplunkConfig.Index,
   207  						GeneralConfig.HookConfig.SplunkConfig.SendLogs)
   208  					splunkClient.Send(telemetryClient.GetData(), logCollector)
   209  				}
   210  				if len(GeneralConfig.HookConfig.SplunkConfig.ProdCriblEndpoint) > 0 {
   211  					splunkClient.Initialize(GeneralConfig.CorrelationID,
   212  						GeneralConfig.HookConfig.SplunkConfig.ProdCriblEndpoint,
   213  						GeneralConfig.HookConfig.SplunkConfig.ProdCriblToken,
   214  						GeneralConfig.HookConfig.SplunkConfig.ProdCriblIndex,
   215  						GeneralConfig.HookConfig.SplunkConfig.SendLogs)
   216  					splunkClient.Send(telemetryClient.GetData(), logCollector)
   217  				}
   218  			}
   219  			log.DeferExitHandler(handler)
   220  			defer handler()
   221  			telemetryClient.Initialize(GeneralConfig.NoTelemetry, STEP_NAME)
   222  			cnbBuild(stepConfig, &stepTelemetryData, &commonPipelineEnvironment)
   223  			stepTelemetryData.ErrorCode = "0"
   224  			log.Entry().Info("SUCCESS")
   225  		},
   226  	}
   227  
   228  	addCnbBuildFlags(createCnbBuildCmd, &stepConfig)
   229  	return createCnbBuildCmd
   230  }
   231  
   232  func addCnbBuildFlags(cmd *cobra.Command, stepConfig *cnbBuildOptions) {
   233  	cmd.Flags().StringVar(&stepConfig.ContainerImageName, "containerImageName", os.Getenv("PIPER_containerImageName"), "Name of the container which will be built\n`cnbBuild` step will try to identify a containerImageName using the following precedence:\n\n  1. `containerImageName` parameter.\n  2. `project.id` field of a `project.toml` file.\n  3. `git/repository` parameter of the `commonPipelineEnvironment`.\n  4. `github/repository` parameter of the `commonPipelineEnvironment`.\n\nIf none of the above was found - an error will be raised.\n")
   234  	cmd.Flags().StringVar(&stepConfig.ContainerImageAlias, "containerImageAlias", os.Getenv("PIPER_containerImageAlias"), "Logical name used for this image.\n")
   235  	cmd.Flags().StringVar(&stepConfig.ContainerImageTag, "containerImageTag", os.Getenv("PIPER_containerImageTag"), "Tag of the container which will be built")
   236  	cmd.Flags().StringVar(&stepConfig.ContainerRegistryURL, "containerRegistryUrl", os.Getenv("PIPER_containerRegistryUrl"), "Container registry where the image should be pushed to.\n\n**Note**: `containerRegistryUrl` should include only the domain. If you want to publish an image under `docker.io/example/my-image`, you must set `containerRegistryUrl: \"docker.io\"` and `containerImageName: \"example/my-image\"`.\n")
   237  	cmd.Flags().StringSliceVar(&stepConfig.Buildpacks, "buildpacks", []string{}, "List of custom buildpacks to use in the form of `$HOSTNAME/$REPO[:$TAG]`. When this property is specified, buildpacks which are part of the builder will be ignored.")
   238  	cmd.Flags().StringSliceVar(&stepConfig.PreBuildpacks, "preBuildpacks", []string{}, "Buildpacks to prepend to the groups in the builder's order.")
   239  	cmd.Flags().StringSliceVar(&stepConfig.PostBuildpacks, "postBuildpacks", []string{}, "Buildpacks to append to the groups in the builder's order.")
   240  
   241  	cmd.Flags().StringVar(&stepConfig.Path, "path", os.Getenv("PIPER_path"), "Glob that should either point to a directory with your sources or one artifact in zip format.\nThis property determines the input to the buildpack.\n")
   242  	cmd.Flags().StringVar(&stepConfig.ProjectDescriptor, "projectDescriptor", `project.toml`, "Relative path to the project.toml file.\nSee [buildpacks.io](https://buildpacks.io/docs/reference/config/project-descriptor/) for the reference.\nParameters passed to the cnbBuild step will take precedence over the parameters set in the project.toml file, except the `env` block.\nEnvironment variables declared in a project descriptor file, will be merged with the `buildEnvVars` property, with the `buildEnvVars` having a precedence.\n\n*Note*: The project descriptor path should be relative to what is set in the [path](#path) property. If the `path` property is pointing to a zip archive (e.g. jar file), project descriptor path will be relative to the root of the workspace.\n\n*Note*: Inline buildpacks (see [specification](https://buildpacks.io/docs/reference/config/project-descriptor/#build-_table-optional_)) are not supported yet.\n")
   243  	cmd.Flags().StringVar(&stepConfig.DockerConfigJSON, "dockerConfigJSON", os.Getenv("PIPER_dockerConfigJSON"), "Path to the file `.docker/config.json` - this is typically provided by your CI/CD system. You can find more details about the Docker credentials in the [Docker documentation](https://docs.docker.com/engine/reference/commandline/login/).")
   244  	cmd.Flags().StringVar(&stepConfig.DockerConfigJSONCPE, "dockerConfigJSONCPE", os.Getenv("PIPER_dockerConfigJSONCPE"), "This property is intended only for reading the `dockerConfigJSON` from the Common Pipeline Environment. If you want to provide your own credentials, please refer to the [dockerConfigJSON](#dockerConfigJSON) property. If both properties are set, the config files will be merged, with the [dockerConfigJSON](#dockerConfigJSON) having higher priority.")
   245  	cmd.Flags().StringSliceVar(&stepConfig.CustomTLSCertificateLinks, "customTlsCertificateLinks", []string{}, "List containing download links of custom TLS certificates. This is required to ensure trusted connections to registries with custom certificates.")
   246  	cmd.Flags().StringSliceVar(&stepConfig.AdditionalTags, "additionalTags", []string{}, "List of tags which will be pushed to the registry (additionally to the provided `containerImageTag`), e.g. \"latest\".")
   247  
   248  	cmd.Flags().StringSliceVar(&stepConfig.PreserveFiles, "preserveFiles", []string{}, "List of globs, for keeping build results in the Jenkins workspace.\n\n*Note*: globs will be calculated relative to the [path](#path) property.\n")
   249  	cmd.Flags().StringVar(&stepConfig.BuildSettingsInfo, "buildSettingsInfo", os.Getenv("PIPER_buildSettingsInfo"), "Build settings info is typically filled by the step automatically to create information about the build settings that were used during the mta build. This information is typically used for compliance related processes.")
   250  	cmd.Flags().BoolVar(&stepConfig.CreateBOM, "createBOM", false, "Creates the bill of materials (BOM) using Syft and stores it in a file in CycloneDX 1.4 format.")
   251  	cmd.Flags().StringVar(&stepConfig.SyftDownloadURL, "syftDownloadUrl", `https://github.com/anchore/syft/releases/download/v0.62.3/syft_0.62.3_linux_amd64.tar.gz`, "Specifies the download url of the Syft Linux amd64 tar binary file. This can be found at https://github.com/anchore/syft/releases/.")
   252  	cmd.Flags().StringVar(&stepConfig.RunImage, "runImage", os.Getenv("PIPER_runImage"), "Base image from which application images are built. Will be defaulted to the image provided by the builder.")
   253  	cmd.Flags().StringVar(&stepConfig.DefaultProcess, "defaultProcess", os.Getenv("PIPER_defaultProcess"), "Process that should be started by default. See https://buildpacks.io/docs/app-developer-guide/run-an-app/")
   254  
   255  	cmd.MarkFlagRequired("containerImageTag")
   256  	cmd.MarkFlagRequired("containerRegistryUrl")
   257  }
   258  
   259  // retrieve step metadata
   260  func cnbBuildMetadata() config.StepData {
   261  	var theMetaData = config.StepData{
   262  		Metadata: config.StepMetadata{
   263  			Name:        "cnbBuild",
   264  			Aliases:     []config.Alias{},
   265  			Description: "Executes Cloud Native Buildpacks.",
   266  		},
   267  		Spec: config.StepSpec{
   268  			Inputs: config.StepInputs{
   269  				Secrets: []config.StepSecrets{
   270  					{Name: "dockerConfigJsonCredentialsId", Description: "Jenkins 'Secret file' credentials ID containing Docker config.json (with registry credential(s)) in the following format:\n\n```json\n{\n  \"auths\": {\n    \"$server\": {\n      \"auth\": \"base64($username + ':' + $password)\"\n    }\n  }\n}\n```\n\nExample:\n\n```json\n{\n  \"auths\": {\n    \"example.com\": {\n      \"auth\": \"dXNlcm5hbWU6cGFzc3dvcmQ=\"\n    }\n  }\n}\n```\n", Type: "jenkins"},
   271  				},
   272  				Parameters: []config.StepParameters{
   273  					{
   274  						Name:        "containerImageName",
   275  						ResourceRef: []config.ResourceReference{},
   276  						Scope:       []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
   277  						Type:        "string",
   278  						Mandatory:   false,
   279  						Aliases:     []config.Alias{{Name: "dockerImageName"}},
   280  						Default:     os.Getenv("PIPER_containerImageName"),
   281  					},
   282  					{
   283  						Name:        "containerImageAlias",
   284  						ResourceRef: []config.ResourceReference{},
   285  						Scope:       []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
   286  						Type:        "string",
   287  						Mandatory:   false,
   288  						Aliases:     []config.Alias{},
   289  						Default:     os.Getenv("PIPER_containerImageAlias"),
   290  					},
   291  					{
   292  						Name: "containerImageTag",
   293  						ResourceRef: []config.ResourceReference{
   294  							{
   295  								Name:  "commonPipelineEnvironment",
   296  								Param: "artifactVersion",
   297  							},
   298  
   299  							{
   300  								Name:  "commonPipelineEnvironment",
   301  								Param: "git/commitId",
   302  							},
   303  						},
   304  						Scope:     []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
   305  						Type:      "string",
   306  						Mandatory: true,
   307  						Aliases:   []config.Alias{{Name: "artifactVersion"}},
   308  						Default:   os.Getenv("PIPER_containerImageTag"),
   309  					},
   310  					{
   311  						Name: "containerRegistryUrl",
   312  						ResourceRef: []config.ResourceReference{
   313  							{
   314  								Name:  "commonPipelineEnvironment",
   315  								Param: "container/registryUrl",
   316  							},
   317  						},
   318  						Scope:     []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
   319  						Type:      "string",
   320  						Mandatory: true,
   321  						Aliases:   []config.Alias{{Name: "dockerRegistryUrl"}},
   322  						Default:   os.Getenv("PIPER_containerRegistryUrl"),
   323  					},
   324  					{
   325  						Name: "buildpacks",
   326  						ResourceRef: []config.ResourceReference{
   327  							{
   328  								Name:  "commonPipelineEnvironment",
   329  								Param: "container/buildpacks",
   330  							},
   331  						},
   332  						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"},
   333  						Type:      "[]string",
   334  						Mandatory: false,
   335  						Aliases:   []config.Alias{},
   336  						Default:   []string{},
   337  					},
   338  					{
   339  						Name: "preBuildpacks",
   340  						ResourceRef: []config.ResourceReference{
   341  							{
   342  								Name:  "commonPipelineEnvironment",
   343  								Param: "container/preBuildpacks",
   344  							},
   345  						},
   346  						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"},
   347  						Type:      "[]string",
   348  						Mandatory: false,
   349  						Aliases:   []config.Alias{},
   350  						Default:   []string{},
   351  					},
   352  					{
   353  						Name: "postBuildpacks",
   354  						ResourceRef: []config.ResourceReference{
   355  							{
   356  								Name:  "commonPipelineEnvironment",
   357  								Param: "container/postBuildpacks",
   358  							},
   359  						},
   360  						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"},
   361  						Type:      "[]string",
   362  						Mandatory: false,
   363  						Aliases:   []config.Alias{},
   364  						Default:   []string{},
   365  					},
   366  					{
   367  						Name:        "buildEnvVars",
   368  						ResourceRef: []config.ResourceReference{},
   369  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   370  						Type:        "map[string]interface{}",
   371  						Mandatory:   false,
   372  						Aliases:     []config.Alias{},
   373  					},
   374  					{
   375  						Name:        "path",
   376  						ResourceRef: []config.ResourceReference{},
   377  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   378  						Type:        "string",
   379  						Mandatory:   false,
   380  						Aliases:     []config.Alias{},
   381  						Default:     os.Getenv("PIPER_path"),
   382  					},
   383  					{
   384  						Name:        "projectDescriptor",
   385  						ResourceRef: []config.ResourceReference{},
   386  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   387  						Type:        "string",
   388  						Mandatory:   false,
   389  						Aliases:     []config.Alias{},
   390  						Default:     `project.toml`,
   391  					},
   392  					{
   393  						Name: "dockerConfigJSON",
   394  						ResourceRef: []config.ResourceReference{
   395  							{
   396  								Name: "dockerConfigJsonCredentialsId",
   397  								Type: "secret",
   398  							},
   399  
   400  							{
   401  								Name:    "dockerConfigFileVaultSecretName",
   402  								Type:    "vaultSecretFile",
   403  								Default: "docker-config",
   404  							},
   405  						},
   406  						Scope:     []string{"PARAMETERS"},
   407  						Type:      "string",
   408  						Mandatory: false,
   409  						Aliases:   []config.Alias{},
   410  						Default:   os.Getenv("PIPER_dockerConfigJSON"),
   411  					},
   412  					{
   413  						Name: "dockerConfigJSONCPE",
   414  						ResourceRef: []config.ResourceReference{
   415  							{
   416  								Name:  "commonPipelineEnvironment",
   417  								Param: "custom/dockerConfigJSON",
   418  							},
   419  						},
   420  						Scope:     []string{},
   421  						Type:      "string",
   422  						Mandatory: false,
   423  						Aliases:   []config.Alias{},
   424  						Default:   os.Getenv("PIPER_dockerConfigJSONCPE"),
   425  					},
   426  					{
   427  						Name:        "customTlsCertificateLinks",
   428  						ResourceRef: []config.ResourceReference{},
   429  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   430  						Type:        "[]string",
   431  						Mandatory:   false,
   432  						Aliases:     []config.Alias{},
   433  						Default:     []string{},
   434  					},
   435  					{
   436  						Name:        "additionalTags",
   437  						ResourceRef: []config.ResourceReference{},
   438  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   439  						Type:        "[]string",
   440  						Mandatory:   false,
   441  						Aliases:     []config.Alias{},
   442  						Default:     []string{},
   443  					},
   444  					{
   445  						Name:        "bindings",
   446  						ResourceRef: []config.ResourceReference{},
   447  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   448  						Type:        "map[string]interface{}",
   449  						Mandatory:   false,
   450  						Aliases:     []config.Alias{},
   451  					},
   452  					{
   453  						Name:        "multipleImages",
   454  						ResourceRef: []config.ResourceReference{},
   455  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   456  						Type:        "[]map[string]interface{}",
   457  						Mandatory:   false,
   458  						Aliases:     []config.Alias{{Name: "images"}},
   459  					},
   460  					{
   461  						Name:        "preserveFiles",
   462  						ResourceRef: []config.ResourceReference{},
   463  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   464  						Type:        "[]string",
   465  						Mandatory:   false,
   466  						Aliases:     []config.Alias{},
   467  						Default:     []string{},
   468  					},
   469  					{
   470  						Name: "buildSettingsInfo",
   471  						ResourceRef: []config.ResourceReference{
   472  							{
   473  								Name:  "commonPipelineEnvironment",
   474  								Param: "custom/buildSettingsInfo",
   475  							},
   476  						},
   477  						Scope:     []string{"STEPS", "STAGES", "PARAMETERS"},
   478  						Type:      "string",
   479  						Mandatory: false,
   480  						Aliases:   []config.Alias{},
   481  						Default:   os.Getenv("PIPER_buildSettingsInfo"),
   482  					},
   483  					{
   484  						Name:        "createBOM",
   485  						ResourceRef: []config.ResourceReference{},
   486  						Scope:       []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
   487  						Type:        "bool",
   488  						Mandatory:   false,
   489  						Aliases:     []config.Alias{},
   490  						Default:     false,
   491  					},
   492  					{
   493  						Name:        "syftDownloadUrl",
   494  						ResourceRef: []config.ResourceReference{},
   495  						Scope:       []string{"PARAMETERS", "STEPS"},
   496  						Type:        "string",
   497  						Mandatory:   false,
   498  						Aliases:     []config.Alias{},
   499  						Default:     `https://github.com/anchore/syft/releases/download/v0.62.3/syft_0.62.3_linux_amd64.tar.gz`,
   500  					},
   501  					{
   502  						Name:        "runImage",
   503  						ResourceRef: []config.ResourceReference{},
   504  						Scope:       []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
   505  						Type:        "string",
   506  						Mandatory:   false,
   507  						Aliases:     []config.Alias{},
   508  						Default:     os.Getenv("PIPER_runImage"),
   509  					},
   510  					{
   511  						Name:        "defaultProcess",
   512  						ResourceRef: []config.ResourceReference{},
   513  						Scope:       []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
   514  						Type:        "string",
   515  						Mandatory:   false,
   516  						Aliases:     []config.Alias{},
   517  						Default:     os.Getenv("PIPER_defaultProcess"),
   518  					},
   519  				},
   520  			},
   521  			Containers: []config.Container{
   522  				{Image: "paketobuildpacks/builder:base"},
   523  			},
   524  			Outputs: config.StepOutputs{
   525  				Resources: []config.StepResources{
   526  					{
   527  						Name: "commonPipelineEnvironment",
   528  						Type: "piperEnvironment",
   529  						Parameters: []map[string]interface{}{
   530  							{"name": "container/registryUrl"},
   531  							{"name": "container/imageDigest"},
   532  							{"name": "container/imageNameTag"},
   533  							{"name": "container/imageNames", "type": "[]string"},
   534  							{"name": "container/imageNameTags", "type": "[]string"},
   535  							{"name": "container/imageDigests", "type": "[]string"},
   536  							{"name": "custom/buildSettingsInfo"},
   537  						},
   538  					},
   539  					{
   540  						Name: "reports",
   541  						Type: "reports",
   542  						Parameters: []map[string]interface{}{
   543  							{"filePattern": "**/bom-*.xml", "type": "sbom"},
   544  						},
   545  					},
   546  				},
   547  			},
   548  		},
   549  	}
   550  	return theMetaData
   551  }