github.com/jaylevin/jenkins-library@v1.230.4/cmd/golangBuild_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 golangBuildOptions struct {
    25  	BuildFlags                   []string `json:"buildFlags,omitempty"`
    26  	BuildSettingsInfo            string   `json:"buildSettingsInfo,omitempty"`
    27  	CgoEnabled                   bool     `json:"cgoEnabled,omitempty"`
    28  	CoverageFormat               string   `json:"coverageFormat,omitempty" validate:"possible-values=cobertura html"`
    29  	CreateBOM                    bool     `json:"createBOM,omitempty"`
    30  	CustomTLSCertificateLinks    []string `json:"customTlsCertificateLinks,omitempty"`
    31  	ExcludeGeneratedFromCoverage bool     `json:"excludeGeneratedFromCoverage,omitempty"`
    32  	LdflagsTemplate              string   `json:"ldflagsTemplate,omitempty"`
    33  	Output                       string   `json:"output,omitempty"`
    34  	Packages                     []string `json:"packages,omitempty"`
    35  	Publish                      bool     `json:"publish,omitempty"`
    36  	TargetRepositoryPassword     string   `json:"targetRepositoryPassword,omitempty"`
    37  	TargetRepositoryUser         string   `json:"targetRepositoryUser,omitempty"`
    38  	TargetRepositoryURL          string   `json:"targetRepositoryURL,omitempty"`
    39  	ReportCoverage               bool     `json:"reportCoverage,omitempty"`
    40  	RunTests                     bool     `json:"runTests,omitempty"`
    41  	RunIntegrationTests          bool     `json:"runIntegrationTests,omitempty"`
    42  	TargetArchitectures          []string `json:"targetArchitectures,omitempty"`
    43  	TestOptions                  []string `json:"testOptions,omitempty"`
    44  	TestResultFormat             string   `json:"testResultFormat,omitempty" validate:"possible-values=junit standard"`
    45  	PrivateModules               string   `json:"privateModules,omitempty"`
    46  	PrivateModulesGitToken       string   `json:"privateModulesGitToken,omitempty"`
    47  	ArtifactVersion              string   `json:"artifactVersion,omitempty"`
    48  }
    49  
    50  type golangBuildCommonPipelineEnvironment struct {
    51  	custom struct {
    52  		buildSettingsInfo string
    53  		artifacts         piperenv.Artifacts
    54  	}
    55  }
    56  
    57  func (p *golangBuildCommonPipelineEnvironment) persist(path, resourceName string) {
    58  	content := []struct {
    59  		category string
    60  		name     string
    61  		value    interface{}
    62  	}{
    63  		{category: "custom", name: "buildSettingsInfo", value: p.custom.buildSettingsInfo},
    64  		{category: "custom", name: "artifacts", value: p.custom.artifacts},
    65  	}
    66  
    67  	errCount := 0
    68  	for _, param := range content {
    69  		err := piperenv.SetResourceParameter(path, resourceName, filepath.Join(param.category, param.name), param.value)
    70  		if err != nil {
    71  			log.Entry().WithError(err).Error("Error persisting piper environment.")
    72  			errCount++
    73  		}
    74  	}
    75  	if errCount > 0 {
    76  		log.Entry().Error("failed to persist Piper environment")
    77  	}
    78  }
    79  
    80  type golangBuildReports struct {
    81  }
    82  
    83  func (p *golangBuildReports) persist(stepConfig golangBuildOptions, gcpJsonKeyFilePath string, gcsBucketId string, gcsFolderPath string, gcsSubFolder string) {
    84  	if gcsBucketId == "" {
    85  		log.Entry().Info("persisting reports to GCS is disabled, because gcsBucketId is empty")
    86  		return
    87  	}
    88  	log.Entry().Info("Uploading reports to Google Cloud Storage...")
    89  	content := []gcs.ReportOutputParam{
    90  		{FilePattern: "**/bom.xml", ParamRef: "", StepResultType: "sbom"},
    91  		{FilePattern: "**/TEST-*.xml", ParamRef: "", StepResultType: "junit"},
    92  		{FilePattern: "**/cobertura-coverage.xml", ParamRef: "", StepResultType: "cobertura-coverage"},
    93  	}
    94  	envVars := []gcs.EnvVar{
    95  		{Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: gcpJsonKeyFilePath, Modified: false},
    96  	}
    97  	gcsClient, err := gcs.NewClient(gcs.WithEnvVars(envVars))
    98  	if err != nil {
    99  		log.Entry().Errorf("creation of GCS client failed: %v", err)
   100  		return
   101  	}
   102  	defer gcsClient.Close()
   103  	structVal := reflect.ValueOf(&stepConfig).Elem()
   104  	inputParameters := map[string]string{}
   105  	for i := 0; i < structVal.NumField(); i++ {
   106  		field := structVal.Type().Field(i)
   107  		if field.Type.String() == "string" {
   108  			paramName := strings.Split(field.Tag.Get("json"), ",")
   109  			paramValue, _ := structVal.Field(i).Interface().(string)
   110  			inputParameters[paramName[0]] = paramValue
   111  		}
   112  	}
   113  	if err := gcs.PersistReportsToGCS(gcsClient, content, inputParameters, gcsFolderPath, gcsBucketId, gcsSubFolder, doublestar.Glob, os.Stat); err != nil {
   114  		log.Entry().Errorf("failed to persist reports: %v", err)
   115  	}
   116  }
   117  
   118  // GolangBuildCommand This step will execute a golang build.
   119  func GolangBuildCommand() *cobra.Command {
   120  	const STEP_NAME = "golangBuild"
   121  
   122  	metadata := golangBuildMetadata()
   123  	var stepConfig golangBuildOptions
   124  	var startTime time.Time
   125  	var commonPipelineEnvironment golangBuildCommonPipelineEnvironment
   126  	var reports golangBuildReports
   127  	var logCollector *log.CollectorHook
   128  	var splunkClient *splunk.Splunk
   129  	telemetryClient := &telemetry.Telemetry{}
   130  
   131  	var createGolangBuildCmd = &cobra.Command{
   132  		Use:   STEP_NAME,
   133  		Short: "This step will execute a golang build.",
   134  		Long: `This step will build a golang project.
   135  It will also execute golang-based tests using [gotestsum](https://github.com/gotestyourself/gotestsum) and with that allows for reporting test results and test coverage.
   136  
   137  Besides execution of the default tests the step allows for running an additional integration test run using ` + "`" + `-tags=integration` + "`" + ` using pattern ` + "`" + `./...` + "`" + `
   138  
   139  If the build is successful the resulting artifact can be uploaded to e.g. a binary repository automatically.`,
   140  		PreRunE: func(cmd *cobra.Command, _ []string) error {
   141  			startTime = time.Now()
   142  			log.SetStepName(STEP_NAME)
   143  			log.SetVerbose(GeneralConfig.Verbose)
   144  
   145  			GeneralConfig.GitHubAccessTokens = ResolveAccessTokens(GeneralConfig.GitHubTokens)
   146  
   147  			path, _ := os.Getwd()
   148  			fatalHook := &log.FatalHook{CorrelationID: GeneralConfig.CorrelationID, Path: path}
   149  			log.RegisterHook(fatalHook)
   150  
   151  			err := PrepareConfig(cmd, &metadata, STEP_NAME, &stepConfig, config.OpenPiperFile)
   152  			if err != nil {
   153  				log.SetErrorCategory(log.ErrorConfiguration)
   154  				return err
   155  			}
   156  			log.RegisterSecret(stepConfig.TargetRepositoryPassword)
   157  			log.RegisterSecret(stepConfig.TargetRepositoryUser)
   158  			log.RegisterSecret(stepConfig.PrivateModulesGitToken)
   159  
   160  			if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 {
   161  				sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID)
   162  				log.RegisterHook(&sentryHook)
   163  			}
   164  
   165  			if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 {
   166  				splunkClient = &splunk.Splunk{}
   167  				logCollector = &log.CollectorHook{CorrelationID: GeneralConfig.CorrelationID}
   168  				log.RegisterHook(logCollector)
   169  			}
   170  
   171  			validation, err := validation.New(validation.WithJSONNamesForStructFields(), validation.WithPredefinedErrorMessages())
   172  			if err != nil {
   173  				return err
   174  			}
   175  			if err = validation.ValidateStruct(stepConfig); err != nil {
   176  				log.SetErrorCategory(log.ErrorConfiguration)
   177  				return err
   178  			}
   179  
   180  			return nil
   181  		},
   182  		Run: func(_ *cobra.Command, _ []string) {
   183  			stepTelemetryData := telemetry.CustomData{}
   184  			stepTelemetryData.ErrorCode = "1"
   185  			handler := func() {
   186  				commonPipelineEnvironment.persist(GeneralConfig.EnvRootPath, "commonPipelineEnvironment")
   187  				reports.persist(stepConfig, GeneralConfig.GCPJsonKeyFilePath, GeneralConfig.GCSBucketId, GeneralConfig.GCSFolderPath, GeneralConfig.GCSSubFolder)
   188  				config.RemoveVaultSecretFiles()
   189  				stepTelemetryData.Duration = fmt.Sprintf("%v", time.Since(startTime).Milliseconds())
   190  				stepTelemetryData.ErrorCategory = log.GetErrorCategory().String()
   191  				stepTelemetryData.PiperCommitHash = GitCommit
   192  				telemetryClient.SetData(&stepTelemetryData)
   193  				telemetryClient.Send()
   194  				if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 {
   195  					splunkClient.Send(telemetryClient.GetData(), logCollector)
   196  				}
   197  			}
   198  			log.DeferExitHandler(handler)
   199  			defer handler()
   200  			telemetryClient.Initialize(GeneralConfig.NoTelemetry, STEP_NAME)
   201  			if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 {
   202  				splunkClient.Initialize(GeneralConfig.CorrelationID,
   203  					GeneralConfig.HookConfig.SplunkConfig.Dsn,
   204  					GeneralConfig.HookConfig.SplunkConfig.Token,
   205  					GeneralConfig.HookConfig.SplunkConfig.Index,
   206  					GeneralConfig.HookConfig.SplunkConfig.SendLogs)
   207  			}
   208  			golangBuild(stepConfig, &stepTelemetryData, &commonPipelineEnvironment)
   209  			stepTelemetryData.ErrorCode = "0"
   210  			log.Entry().Info("SUCCESS")
   211  		},
   212  	}
   213  
   214  	addGolangBuildFlags(createGolangBuildCmd, &stepConfig)
   215  	return createGolangBuildCmd
   216  }
   217  
   218  func addGolangBuildFlags(cmd *cobra.Command, stepConfig *golangBuildOptions) {
   219  	cmd.Flags().StringSliceVar(&stepConfig.BuildFlags, "buildFlags", []string{}, "Defines list of build flags to be used.")
   220  	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 maven build . This information is typically used for compliance related processes.")
   221  	cmd.Flags().BoolVar(&stepConfig.CgoEnabled, "cgoEnabled", false, "If active: enables the creation of Go packages that call C code.")
   222  	cmd.Flags().StringVar(&stepConfig.CoverageFormat, "coverageFormat", `html`, "Defines the format of the coverage repository.")
   223  	cmd.Flags().BoolVar(&stepConfig.CreateBOM, "createBOM", false, "Creates the bill of materials (BOM) using CycloneDX plugin. It requires Go 1.17 or newer.")
   224  	cmd.Flags().StringSliceVar(&stepConfig.CustomTLSCertificateLinks, "customTlsCertificateLinks", []string{}, "List of download links to custom TLS certificates. This is required to ensure trusted connections to instances with repositories (like nexus) when publish flag is set to true.")
   225  	cmd.Flags().BoolVar(&stepConfig.ExcludeGeneratedFromCoverage, "excludeGeneratedFromCoverage", true, "Defines if generated files should be excluded, according to [https://golang.org/s/generatedcode](https://golang.org/s/generatedcode).")
   226  	cmd.Flags().StringVar(&stepConfig.LdflagsTemplate, "ldflagsTemplate", os.Getenv("PIPER_ldflagsTemplate"), "Defines the content of -ldflags option in a golang template format.")
   227  	cmd.Flags().StringVar(&stepConfig.Output, "output", os.Getenv("PIPER_output"), "Defines the build result or output directory as per `go build` documentation.")
   228  	cmd.Flags().StringSliceVar(&stepConfig.Packages, "packages", []string{}, "List of packages to be build as per `go build` documentation.")
   229  	cmd.Flags().BoolVar(&stepConfig.Publish, "publish", false, "Configures the build to publish artifacts to a repository.")
   230  	cmd.Flags().StringVar(&stepConfig.TargetRepositoryPassword, "targetRepositoryPassword", os.Getenv("PIPER_targetRepositoryPassword"), "Password for the target repository where the compiled binaries shall be uploaded - typically provided by the CI/CD environment.")
   231  	cmd.Flags().StringVar(&stepConfig.TargetRepositoryUser, "targetRepositoryUser", os.Getenv("PIPER_targetRepositoryUser"), "Username for the target repository where the compiled binaries shall be uploaded - typically provided by the CI/CD environment.")
   232  	cmd.Flags().StringVar(&stepConfig.TargetRepositoryURL, "targetRepositoryURL", os.Getenv("PIPER_targetRepositoryURL"), "URL of the target repository where the compiled binaries shall be uploaded - typically provided by the CI/CD environment.")
   233  	cmd.Flags().BoolVar(&stepConfig.ReportCoverage, "reportCoverage", true, "Defines if a coverage report should be created.")
   234  	cmd.Flags().BoolVar(&stepConfig.RunTests, "runTests", true, "Activates execution of tests using [gotestsum](https://github.com/gotestyourself/gotestsum).")
   235  	cmd.Flags().BoolVar(&stepConfig.RunIntegrationTests, "runIntegrationTests", false, "Activates execution of a second test run using tag `integration`.")
   236  	cmd.Flags().StringSliceVar(&stepConfig.TargetArchitectures, "targetArchitectures", []string{`linux,amd64`}, "Defines the target architectures for which the build should run using OS and architecture separated by a comma.")
   237  	cmd.Flags().StringSliceVar(&stepConfig.TestOptions, "testOptions", []string{}, "Options to pass to test as per `go test` documentation (comprises e.g. flags, packages).")
   238  	cmd.Flags().StringVar(&stepConfig.TestResultFormat, "testResultFormat", `junit`, "Defines the output format of the test results.")
   239  	cmd.Flags().StringVar(&stepConfig.PrivateModules, "privateModules", os.Getenv("PIPER_privateModules"), "Tells go which modules shall be considered to be private (by setting [GOPRIVATE](https://pkg.go.dev/cmd/go#hdr-Configuration_for_downloading_non_public_code)).")
   240  	cmd.Flags().StringVar(&stepConfig.PrivateModulesGitToken, "privateModulesGitToken", os.Getenv("PIPER_privateModulesGitToken"), "GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line.")
   241  	cmd.Flags().StringVar(&stepConfig.ArtifactVersion, "artifactVersion", os.Getenv("PIPER_artifactVersion"), "Version of the artifact to be built.")
   242  
   243  	cmd.MarkFlagRequired("targetArchitectures")
   244  }
   245  
   246  // retrieve step metadata
   247  func golangBuildMetadata() config.StepData {
   248  	var theMetaData = config.StepData{
   249  		Metadata: config.StepMetadata{
   250  			Name:        "golangBuild",
   251  			Aliases:     []config.Alias{},
   252  			Description: "This step will execute a golang build.",
   253  		},
   254  		Spec: config.StepSpec{
   255  			Inputs: config.StepInputs{
   256  				Secrets: []config.StepSecrets{
   257  					{Name: "golangPrivateModulesGitTokenCredentialsId", Description: "Jenkins 'Username with password' credentials ID containing username/password for http access to your git repos where your go private modules are stored.", Type: "jenkins"},
   258  				},
   259  				Parameters: []config.StepParameters{
   260  					{
   261  						Name:        "buildFlags",
   262  						ResourceRef: []config.ResourceReference{},
   263  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   264  						Type:        "[]string",
   265  						Mandatory:   false,
   266  						Aliases:     []config.Alias{},
   267  						Default:     []string{},
   268  					},
   269  					{
   270  						Name: "buildSettingsInfo",
   271  						ResourceRef: []config.ResourceReference{
   272  							{
   273  								Name:  "commonPipelineEnvironment",
   274  								Param: "custom/buildSettingsInfo",
   275  							},
   276  						},
   277  						Scope:     []string{"STEPS", "STAGES", "PARAMETERS"},
   278  						Type:      "string",
   279  						Mandatory: false,
   280  						Aliases:   []config.Alias{},
   281  						Default:   os.Getenv("PIPER_buildSettingsInfo"),
   282  					},
   283  					{
   284  						Name:        "cgoEnabled",
   285  						ResourceRef: []config.ResourceReference{},
   286  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   287  						Type:        "bool",
   288  						Mandatory:   false,
   289  						Aliases:     []config.Alias{},
   290  						Default:     false,
   291  					},
   292  					{
   293  						Name:        "coverageFormat",
   294  						ResourceRef: []config.ResourceReference{},
   295  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   296  						Type:        "string",
   297  						Mandatory:   false,
   298  						Aliases:     []config.Alias{},
   299  						Default:     `html`,
   300  					},
   301  					{
   302  						Name:        "createBOM",
   303  						ResourceRef: []config.ResourceReference{},
   304  						Scope:       []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
   305  						Type:        "bool",
   306  						Mandatory:   false,
   307  						Aliases:     []config.Alias{},
   308  						Default:     false,
   309  					},
   310  					{
   311  						Name:        "customTlsCertificateLinks",
   312  						ResourceRef: []config.ResourceReference{},
   313  						Scope:       []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
   314  						Type:        "[]string",
   315  						Mandatory:   false,
   316  						Aliases:     []config.Alias{},
   317  						Default:     []string{},
   318  					},
   319  					{
   320  						Name:        "excludeGeneratedFromCoverage",
   321  						ResourceRef: []config.ResourceReference{},
   322  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   323  						Type:        "bool",
   324  						Mandatory:   false,
   325  						Aliases:     []config.Alias{},
   326  						Default:     true,
   327  					},
   328  					{
   329  						Name:        "ldflagsTemplate",
   330  						ResourceRef: []config.ResourceReference{},
   331  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   332  						Type:        "string",
   333  						Mandatory:   false,
   334  						Aliases:     []config.Alias{},
   335  						Default:     os.Getenv("PIPER_ldflagsTemplate"),
   336  					},
   337  					{
   338  						Name:        "output",
   339  						ResourceRef: []config.ResourceReference{},
   340  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   341  						Type:        "string",
   342  						Mandatory:   false,
   343  						Aliases:     []config.Alias{},
   344  						Default:     os.Getenv("PIPER_output"),
   345  					},
   346  					{
   347  						Name:        "packages",
   348  						ResourceRef: []config.ResourceReference{},
   349  						Scope:       []string{"PARAMETERS", "STAGES", "STEPS"},
   350  						Type:        "[]string",
   351  						Mandatory:   false,
   352  						Aliases:     []config.Alias{},
   353  						Default:     []string{},
   354  					},
   355  					{
   356  						Name:        "publish",
   357  						ResourceRef: []config.ResourceReference{},
   358  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   359  						Type:        "bool",
   360  						Mandatory:   false,
   361  						Aliases:     []config.Alias{},
   362  						Default:     false,
   363  					},
   364  					{
   365  						Name: "targetRepositoryPassword",
   366  						ResourceRef: []config.ResourceReference{
   367  							{
   368  								Name:  "commonPipelineEnvironment",
   369  								Param: "custom/rawRepositoryPassword",
   370  							},
   371  
   372  							{
   373  								Name:  "commonPipelineEnvironment",
   374  								Param: "custom/repositoryPassword",
   375  							},
   376  						},
   377  						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"},
   378  						Type:      "string",
   379  						Mandatory: false,
   380  						Aliases:   []config.Alias{},
   381  						Default:   os.Getenv("PIPER_targetRepositoryPassword"),
   382  					},
   383  					{
   384  						Name: "targetRepositoryUser",
   385  						ResourceRef: []config.ResourceReference{
   386  							{
   387  								Name:  "commonPipelineEnvironment",
   388  								Param: "custom/rawRepositoryUsername",
   389  							},
   390  
   391  							{
   392  								Name:  "commonPipelineEnvironment",
   393  								Param: "custom/repositoryUsername",
   394  							},
   395  						},
   396  						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"},
   397  						Type:      "string",
   398  						Mandatory: false,
   399  						Aliases:   []config.Alias{},
   400  						Default:   os.Getenv("PIPER_targetRepositoryUser"),
   401  					},
   402  					{
   403  						Name: "targetRepositoryURL",
   404  						ResourceRef: []config.ResourceReference{
   405  							{
   406  								Name:  "commonPipelineEnvironment",
   407  								Param: "custom/rawRepositoryURL",
   408  							},
   409  
   410  							{
   411  								Name:  "commonPipelineEnvironment",
   412  								Param: "custom/repositoryUrl",
   413  							},
   414  						},
   415  						Scope:     []string{"PARAMETERS", "STAGES", "STEPS"},
   416  						Type:      "string",
   417  						Mandatory: false,
   418  						Aliases:   []config.Alias{},
   419  						Default:   os.Getenv("PIPER_targetRepositoryURL"),
   420  					},
   421  					{
   422  						Name:        "reportCoverage",
   423  						ResourceRef: []config.ResourceReference{},
   424  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   425  						Type:        "bool",
   426  						Mandatory:   false,
   427  						Aliases:     []config.Alias{},
   428  						Default:     true,
   429  					},
   430  					{
   431  						Name:        "runTests",
   432  						ResourceRef: []config.ResourceReference{},
   433  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   434  						Type:        "bool",
   435  						Mandatory:   false,
   436  						Aliases:     []config.Alias{},
   437  						Default:     true,
   438  					},
   439  					{
   440  						Name:        "runIntegrationTests",
   441  						ResourceRef: []config.ResourceReference{},
   442  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   443  						Type:        "bool",
   444  						Mandatory:   false,
   445  						Aliases:     []config.Alias{},
   446  						Default:     false,
   447  					},
   448  					{
   449  						Name:        "targetArchitectures",
   450  						ResourceRef: []config.ResourceReference{},
   451  						Scope:       []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"},
   452  						Type:        "[]string",
   453  						Mandatory:   true,
   454  						Aliases:     []config.Alias{},
   455  						Default:     []string{`linux,amd64`},
   456  					},
   457  					{
   458  						Name:        "testOptions",
   459  						ResourceRef: []config.ResourceReference{},
   460  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   461  						Type:        "[]string",
   462  						Mandatory:   false,
   463  						Aliases:     []config.Alias{},
   464  						Default:     []string{},
   465  					},
   466  					{
   467  						Name:        "testResultFormat",
   468  						ResourceRef: []config.ResourceReference{},
   469  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   470  						Type:        "string",
   471  						Mandatory:   false,
   472  						Aliases:     []config.Alias{},
   473  						Default:     `junit`,
   474  					},
   475  					{
   476  						Name:        "privateModules",
   477  						ResourceRef: []config.ResourceReference{},
   478  						Scope:       []string{"STEPS", "STAGES", "PARAMETERS"},
   479  						Type:        "string",
   480  						Mandatory:   false,
   481  						Aliases:     []config.Alias{},
   482  						Default:     os.Getenv("PIPER_privateModules"),
   483  					},
   484  					{
   485  						Name: "privateModulesGitToken",
   486  						ResourceRef: []config.ResourceReference{
   487  							{
   488  								Name:  "golangPrivateModulesGitTokenCredentialsId",
   489  								Param: "password",
   490  								Type:  "secret",
   491  							},
   492  
   493  							{
   494  								Name:    "golangPrivateModulesGitTokenVaultSecret",
   495  								Type:    "vaultSecret",
   496  								Default: "golang",
   497  							},
   498  						},
   499  						Scope:     []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
   500  						Type:      "string",
   501  						Mandatory: false,
   502  						Aliases:   []config.Alias{},
   503  						Default:   os.Getenv("PIPER_privateModulesGitToken"),
   504  					},
   505  					{
   506  						Name: "artifactVersion",
   507  						ResourceRef: []config.ResourceReference{
   508  							{
   509  								Name:  "commonPipelineEnvironment",
   510  								Param: "artifactVersion",
   511  							},
   512  						},
   513  						Scope:     []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
   514  						Type:      "string",
   515  						Mandatory: false,
   516  						Aliases:   []config.Alias{},
   517  						Default:   os.Getenv("PIPER_artifactVersion"),
   518  					},
   519  				},
   520  			},
   521  			Containers: []config.Container{
   522  				{Name: "golang", Image: "golang:1", Options: []config.Option{{Name: "-u", Value: "0"}}},
   523  			},
   524  			Outputs: config.StepOutputs{
   525  				Resources: []config.StepResources{
   526  					{
   527  						Name: "commonPipelineEnvironment",
   528  						Type: "piperEnvironment",
   529  						Parameters: []map[string]interface{}{
   530  							{"name": "custom/buildSettingsInfo"},
   531  							{"name": "custom/artifacts", "type": "piperenv.Artifacts"},
   532  						},
   533  					},
   534  					{
   535  						Name: "reports",
   536  						Type: "reports",
   537  						Parameters: []map[string]interface{}{
   538  							{"filePattern": "**/bom.xml", "type": "sbom"},
   539  							{"filePattern": "**/TEST-*.xml", "type": "junit"},
   540  							{"filePattern": "**/cobertura-coverage.xml", "type": "cobertura-coverage"},
   541  						},
   542  					},
   543  				},
   544  			},
   545  		},
   546  	}
   547  	return theMetaData
   548  }