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