1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-17 21:08:10 +02:00

chore(deps): Update go version 1.24 (#5277)

* Bump go version 1.23.4->1.24

* Update go version 1.24.0 for github workflows

* Update go version 1.23.4->1.24.0 for docker images

* Replace deprecated cipher.NewCFBDecrypter/NewCFBEncrypter

* Fix go vet error: non-constant format string

* Fix go vet error: non-constant format string

* Update cmd/golangBuild.go

Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>

---------

Co-authored-by: Ivan Nikiforov <ivan.nikiforov@sap.com>
Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
This commit is contained in:
Ivan Nikiforov 2025-02-27 15:11:55 +01:00 committed by GitHub
parent 8be029f023
commit 26e145d300
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
46 changed files with 98 additions and 98 deletions

View File

@ -23,7 +23,7 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: '1.23.4'
go-version: '1.24.0'
- name: Install Groovy
run: sudo apt-get update && sudo apt-get install groovy -y

View File

@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23.4'
go-version: '1.24.0'
- name: Perform update
run: |
git checkout -B gh-action-update-golang-dependencies

View File

@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23.4'
go-version: '1.24.0'
- env:
CGO_ENABLED: 0
run: |

View File

@ -15,7 +15,7 @@ jobs:
- uses: styfle/cancel-workflow-action@0.11.0
- uses: actions/setup-go@v5
with:
go-version: '1.23.4'
go-version: '1.24.0'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
@ -43,7 +43,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.23.4'
go-version: '1.24.0'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
@ -63,7 +63,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.23.4'
go-version: '1.24.0'
- name: checkout
uses: actions/checkout@v4
with:
@ -78,7 +78,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.23.4'
go-version: '1.24.0'
- name: Cache Golang Packages
uses: actions/cache@v3
with:
@ -98,7 +98,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.23.4'
go-version: '1.24.0'
- name: Cache Golang Packages
uses: actions/cache@v3
with:

View File

@ -1,4 +1,4 @@
FROM golang:1.23.4 AS build-env
FROM golang:1.24.0 AS build-env
COPY . /build
WORKDIR /build
@ -11,13 +11,13 @@ RUN go test ./... -tags=unit -cover
RUN export GIT_COMMIT=$(git rev-parse HEAD) && \
export GIT_REPOSITORY=$(git config --get remote.origin.url) && \
CGO_ENABLED=0 go build \
-ldflags \
"-X github.com/SAP/jenkins-library/cmd.GitCommit=${GIT_COMMIT} \
-X github.com/SAP/jenkins-library/pkg/log.LibraryRepository=${GIT_REPOSITORY} \
-X github.com/SAP/jenkins-library/pkg/log.LibraryName=piper-lib-os \
-X github.com/SAP/jenkins-library/pkg/telemetry.LibraryRepository=${GIT_REPOSITORY}" \
-tags release \
-o piper
-ldflags \
"-X github.com/SAP/jenkins-library/cmd.GitCommit=${GIT_COMMIT} \
-X github.com/SAP/jenkins-library/pkg/log.LibraryRepository=${GIT_REPOSITORY} \
-X github.com/SAP/jenkins-library/pkg/log.LibraryName=piper-lib-os \
-X github.com/SAP/jenkins-library/pkg/telemetry.LibraryRepository=${GIT_REPOSITORY}" \
-tags release \
-o piper
# FROM gcr.io/distroless/base:latest
# COPY --from=build-env /build/piper /piper

View File

@ -98,7 +98,7 @@ func startingConfirm(repos []abaputils.Repository, conn abapbuild.Connector, del
if releasePackagesFailed == nil {
releasePackagesFailed = errors.New(errormessage)
} else {
releasePackagesFailed = errors.Wrapf(releasePackagesFailed, errormessage)
releasePackagesFailed = errors.Wrap(releasePackagesFailed, errormessage)
}
} else {
log.Entry().Infof("Packages %s was not assembled in this pipeline run, thus no need to confirm", repo.PackageName)

View File

@ -101,7 +101,7 @@ func cloneSingleRepo(apiManager abaputils.SoftwareComponentApiManagerInterface,
alreadyCloned, activeBranch, errCheckCloned, isByog := api.GetRepository()
if errCheckCloned != nil {
return errors.Wrapf(errCheckCloned, errorString)
return errors.Wrap(errCheckCloned, errorString)
}
if !alreadyCloned {
@ -110,13 +110,13 @@ func cloneSingleRepo(apiManager abaputils.SoftwareComponentApiManagerInterface,
}
errClone := api.Clone()
if errClone != nil {
return errors.Wrapf(errClone, errorString)
return errors.Wrap(errClone, errorString)
}
// set correct filename for archive file
logOutputManager.FileNameStep = "clone"
status, errorPollEntity := abaputils.PollEntity(api, apiManager.GetPollIntervall(), logOutputManager)
if errorPollEntity != nil {
return errors.Wrapf(errorPollEntity, errorString)
return errors.Wrap(errorPollEntity, errorString)
}
if status == "E" {
return errors.New("Clone of " + logString + " failed on the ABAP System")
@ -124,8 +124,8 @@ func cloneSingleRepo(apiManager abaputils.SoftwareComponentApiManagerInterface,
log.Entry().Info("The " + logString + " was cloned successfully")
} else {
abaputils.AddDefaultDashedLine(2)
log.Entry().Infof("%s", "The repository / software component has already been cloned on the ABAP Environment system ")
log.Entry().Infof("%s", "If required, a `checkout branch`, and a `pull` will be performed instead")
log.Entry().Info("The repository / software component has already been cloned on the ABAP Environment system ")
log.Entry().Info("If required, a `checkout branch`, and a `pull` will be performed instead")
abaputils.AddDefaultDashedLine(2)
var returnedError error
if repo.Branch != "" && !(activeBranch == repo.Branch) {

View File

@ -62,7 +62,7 @@ func createTags(backlog []abaputils.CreateTagBacklog, con abaputils.ConnectionDe
if errorOccurred {
message := "At least one tag has not been created"
log.Entry().Errorf(message)
log.Entry().Error(message)
return errors.New(message)
}
return nil
@ -94,7 +94,7 @@ func createSingleTag(item abaputils.CreateTagBacklog, index int, con abaputils.C
createTagError := api.CreateTag(item.Tags[index])
if createTagError != nil {
return errors.Wrapf(err, "Creation of Tag failed on the ABAP system")
return errors.Wrap(err, "Creation of Tag failed on the ABAP system")
}
logOutputManager := abaputils.LogOutputManager{

View File

@ -106,7 +106,7 @@ func handlePull(repo abaputils.Repository, con abaputils.ConnectionDetailsHTTP,
err = api.Pull()
if err != nil {
return errors.Wrapf(err, errorString)
return errors.Wrap(err, errorString)
}
// set correct filename for archive file
@ -114,7 +114,7 @@ func handlePull(repo abaputils.Repository, con abaputils.ConnectionDetailsHTTP,
// Polling the status of the repository import on the ABAP Environment system
status, errorPollEntity := abaputils.PollEntity(api, apiManager.GetPollIntervall(), logOutputManager)
if errorPollEntity != nil {
return errors.Wrapf(errorPollEntity, errorString)
return errors.Wrap(errorPollEntity, errorString)
}
if status == "E" {
return errors.New(errorString)

View File

@ -127,7 +127,7 @@ func checkATCSystemConfigurationFile(config *abapEnvironmentPushATCSystemConfigO
//check if parsedConfigurationJson is not initial or Configuration Name not supplied
if reflect.DeepEqual(parsedConfigurationJson, emptyConfigurationJson) ||
parsedConfigurationJson.ConfName == "" {
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, errors.Errorf("pushing ATC System Configuration failed. Reason: Configured File does not contain required ATC System Configuration attributes (File: " + config.AtcSystemConfigFilePath + ")")
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, errors.Errorf("pushing ATC System Configuration failed. Reason: Configured File does not contain required ATC System Configuration attributes (File: %s)", config.AtcSystemConfigFilePath)
}
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, nil
@ -145,7 +145,7 @@ func readATCSystemConfigurationFile(config *abapEnvironmentPushATCSystemConfigOp
}
if len(filelocation) == 0 {
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, errors.Errorf("pushing ATC System Configuration failed. Reason: Configured Filelocation is empty (File: " + config.AtcSystemConfigFilePath + ")")
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, errors.Errorf("pushing ATC System Configuration failed. Reason: Configured Filelocation is empty (File: %s)", config.AtcSystemConfigFilePath)
}
filename, err = filepath.Abs(filelocation[0])
@ -157,7 +157,7 @@ func readATCSystemConfigurationFile(config *abapEnvironmentPushATCSystemConfigOp
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, err
}
if len(atcSystemConfiguartionJsonFile) == 0 {
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, errors.Errorf("pushing ATC System Configuration failed. Reason: Configured File is empty (File: " + config.AtcSystemConfigFilePath + ")")
return parsedConfigurationJson, atcSystemConfiguartionJsonFile, errors.Errorf("pushing ATC System Configuration failed. Reason: Configured File is empty (File: %s)", config.AtcSystemConfigFilePath)
}
err = json.Unmarshal(atcSystemConfiguartionJsonFile, &parsedConfigurationJson)

View File

@ -62,7 +62,7 @@ func runApiKeyValueMapDownload(config *apiKeyValueMapDownloadOptions, telemetryD
csvFilePath := config.DownloadPath
file, err := os.Create(csvFilePath)
if err != nil {
return errors.Wrapf(err, "Failed to create api key value map CSV file")
return errors.Wrap(err, "Failed to create api key value map CSV file")
}
_, err = io.Copy(file, downloadResp.Body)
if err != nil {

View File

@ -53,7 +53,7 @@ func runApiProxyUpload(config *apiProxyUploadOptions, telemetryData *telemetry.C
header.Add("Accept", "application/zip")
fileContent, readError := fileUtils.FileRead(config.FilePath)
if readError != nil {
return errors.Wrapf(readError, "Error reading file")
return errors.Wrap(readError, "Error reading file")
}
if !strings.Contains(config.FilePath, "zip") {
return errors.New("not valid zip archive")

View File

@ -42,14 +42,14 @@ func (a *artifactVersioningMock) VersioningScheme() string {
func (a *artifactVersioningMock) GetVersion() (string, error) {
if len(a.getVersionError) > 0 {
return "", fmt.Errorf(a.getVersionError)
return "", fmt.Errorf("%s", a.getVersionError)
}
return a.originalVersion, nil
}
func (a *artifactVersioningMock) SetVersion(version string) error {
if len(a.setVersionError) > 0 {
return fmt.Errorf(a.setVersionError)
return fmt.Errorf("%s", a.setVersionError)
}
a.newVersion = version
return nil
@ -92,7 +92,7 @@ func (r *gitRepositoryMock) CommitObject(hash plumbing.Hash) (*object.Commit, er
func (r *gitRepositoryMock) CreateTag(name string, hash plumbing.Hash, opts *git.CreateTagOptions) (*plumbing.Reference, error) {
if len(r.tagError) > 0 {
return nil, fmt.Errorf(r.tagError)
return nil, fmt.Errorf("%s", r.tagError)
}
r.tag = name
r.tagHash = hash
@ -102,7 +102,7 @@ func (r *gitRepositoryMock) CreateTag(name string, hash plumbing.Hash, opts *git
func (r *gitRepositoryMock) CreateRemote(config *gitConfig.RemoteConfig) (*git.Remote, error) {
r.createRemoteCalls++
if len(r.createRemoteError) >= r.createRemoteCalls && len(r.createRemoteError[r.createRemoteCalls-1]) > 0 {
return nil, fmt.Errorf(r.createRemoteError[r.createRemoteCalls-1])
return nil, fmt.Errorf("%s", r.createRemoteError[r.createRemoteCalls-1])
}
r.createRemoteConfigs = append(r.createRemoteConfigs, config)
return nil, nil
@ -111,7 +111,7 @@ func (r *gitRepositoryMock) CreateRemote(config *gitConfig.RemoteConfig) (*git.R
func (r *gitRepositoryMock) DeleteRemote(name string) error {
r.deleteRemoteCalls++
if len(r.deleteRemoteError) >= r.deleteRemoteCalls && len(r.deleteRemoteError[r.deleteRemoteCalls-1]) > 0 {
return fmt.Errorf(r.deleteRemoteError[r.deleteRemoteCalls-1])
return fmt.Errorf("%s", r.deleteRemoteError[r.deleteRemoteCalls-1])
}
r.deleteRemoteNames = append(r.deleteRemoteNames, name)
return nil
@ -119,7 +119,7 @@ func (r *gitRepositoryMock) DeleteRemote(name string) error {
func (r *gitRepositoryMock) Push(o *git.PushOptions) error {
if len(r.pushError) > 0 {
return fmt.Errorf(r.pushError)
return fmt.Errorf("%s", r.pushError)
}
r.pushCalled = true
r.pushOptions = o
@ -128,14 +128,14 @@ func (r *gitRepositoryMock) Push(o *git.PushOptions) error {
func (r *gitRepositoryMock) Remote(name string) (*git.Remote, error) {
if len(r.remoteError) > 0 {
return &git.Remote{}, fmt.Errorf(r.remoteError)
return &git.Remote{}, fmt.Errorf("%s", r.remoteError)
}
return r.remote, nil
}
func (r *gitRepositoryMock) ResolveRevision(rev plumbing.Revision) (*plumbing.Hash, error) {
if len(r.revisionError) > 0 {
return nil, fmt.Errorf(r.revisionError)
return nil, fmt.Errorf("%s", r.revisionError)
}
r.revision = rev.String()
return &r.revisionHash, nil
@ -143,7 +143,7 @@ func (r *gitRepositoryMock) ResolveRevision(rev plumbing.Revision) (*plumbing.Ha
func (r *gitRepositoryMock) Worktree() (*git.Worktree, error) {
if len(r.worktreeError) > 0 {
return nil, fmt.Errorf(r.worktreeError)
return nil, fmt.Errorf("%s", r.worktreeError)
}
return r.worktree, nil
}
@ -159,14 +159,14 @@ type gitWorktreeMock struct {
func (w *gitWorktreeMock) Checkout(opts *git.CheckoutOptions) error {
if len(w.checkoutError) > 0 {
return fmt.Errorf(w.checkoutError)
return fmt.Errorf("%s", w.checkoutError)
}
w.checkoutOpts = opts
return nil
}
func (w *gitWorktreeMock) Commit(msg string, opts *git.CommitOptions) (plumbing.Hash, error) {
if len(w.commitError) > 0 {
return plumbing.Hash{}, fmt.Errorf(w.commitError)
return plumbing.Hash{}, fmt.Errorf("%s", w.commitError)
}
w.commitMsg = msg
w.commitOpts = opts

View File

@ -49,7 +49,7 @@ func ascAppUpload(config ascAppUploadOptions, telemetryData *telemetry.CustomDat
func runAscAppUpload(config *ascAppUploadOptions, telemetryData *telemetry.CustomData, utils ascAppUploadUtils, ascClient asc.System) error {
if len(config.JamfTargetSystem) == 0 {
return errors.Errorf("jamfTargetSystem must be set")
return errors.New("jamfTargetSystem must be set")
}
log.Entry().Infof("Collect data to create new release in ASC")
@ -57,7 +57,7 @@ func runAscAppUpload(config *ascAppUploadOptions, telemetryData *telemetry.Custo
app, err := ascClient.GetAppById(config.AppID)
if err != nil {
log.SetErrorCategory(log.ErrorConfiguration)
return errors.Wrapf(err, "failed to get app information")
return errors.Wrap(err, "failed to get app information")
}
log.Entry().Debugf("Found App with name %v", app.AppName)
@ -68,7 +68,7 @@ func runAscAppUpload(config *ascAppUploadOptions, telemetryData *telemetry.Custo
if err != nil {
log.SetErrorCategory(log.ErrorService)
return errors.Wrapf(err, "failed to create release")
return errors.Wrap(err, "failed to create release")
}
if releaseResponse.Status != "success" {
@ -81,7 +81,7 @@ func runAscAppUpload(config *ascAppUploadOptions, telemetryData *telemetry.Custo
jamfAppInformationResponse, err := ascClient.GetJamfAppInfo(app.BundleId, config.JamfTargetSystem)
if err != nil {
log.SetErrorCategory(log.ErrorService)
return errors.Wrapf(err, "failed to get jamf app info")
return errors.Wrap(err, "failed to get jamf app info")
}
jamfAppId := jamfAppInformationResponse.MobileDeviceApplication.General.Id
@ -97,7 +97,7 @@ func runAscAppUpload(config *ascAppUploadOptions, telemetryData *telemetry.Custo
err = ascClient.UploadIpa(config.FilePath, jamfAppId, config.JamfTargetSystem, app.BundleId, releaseResponse.Data)
if err != nil {
log.SetErrorCategory(log.ErrorService)
return errors.Wrapf(err, "failed to upload ipa")
return errors.Wrap(err, "failed to upload ipa")
}
log.Entry().Infof("Successfully uploaded %v to ASC (AppId %v) & Jamf (Id %v)", config.FilePath, app.AppId, jamfAppId)

View File

@ -72,7 +72,7 @@ func checkIfStepActive(utils piperutils.FileUtils) error {
projectConfig, err := initializeConfig(&pConfig)
if err != nil {
log.Entry().Errorf("Failed to load project config: %v", err)
return errors.Wrapf(err, "Failed to load project config failed")
return errors.Wrap(err, "Failed to load project config failed")
}
stageConfigFile, err := checkStepActiveOptions.openFile(checkStepActiveOptions.stageConfigFile, GeneralConfig.GitHubAccessTokens)

View File

@ -47,7 +47,7 @@ func TestCloudFoundryCreateSpace(t *testing.T) {
s.ShouldFailOnCommand = nil
}()
s.ShouldFailOnCommand = map[string]error{"yes '' | cf login -a https://api.endpoint.com -u testUser -p testPassword ": fmt.Errorf(errorMessage)}
s.ShouldFailOnCommand = map[string]error{"yes '' | cf login -a https://api.endpoint.com -u testUser -p testPassword ": fmt.Errorf("%s", errorMessage)}
e := runCloudFoundryCreateSpace(&config, &telemetryData, cf, &s)
assert.EqualError(t, e, "Error while logging in occured: "+errorMessage)
@ -67,7 +67,7 @@ func TestCloudFoundryCreateSpace(t *testing.T) {
defer cfUtilsMock.Cleanup()
errorMessage := "cf space creation error"
m.ShouldFailOnCommand = map[string]error{"cf create-space testSpace -o testOrg": fmt.Errorf(errorMessage)}
m.ShouldFailOnCommand = map[string]error{"cf create-space testSpace -o testOrg": fmt.Errorf("%s", errorMessage)}
cfUtilsMock.LoginError = errors.New(errorMessage)

View File

@ -44,7 +44,7 @@ func TestCloudFoundryDeleteSpace(t *testing.T) {
s.ShouldFailOnCommand = nil
}()
s.ShouldFailOnCommand = map[string]error{"yes '' | cf login -a https://api.endpoint.com -u testUser -p testPassword ": fmt.Errorf(errorMessage)}
s.ShouldFailOnCommand = map[string]error{"yes '' | cf login -a https://api.endpoint.com -u testUser -p testPassword ": fmt.Errorf("%s", errorMessage)}
e := runCloudFoundryDeleteSpace(&config, &telemetryData, cf, &s)
assert.EqualError(t, e, "Error while logging in occured: "+errorMessage)
@ -63,7 +63,7 @@ func TestCloudFoundryDeleteSpace(t *testing.T) {
errorMessage := "cf space creation error"
m.ShouldFailOnCommand = map[string]error{"cf delete-space testSpace -o testOrg -f": fmt.Errorf(errorMessage)}
m.ShouldFailOnCommand = map[string]error{"cf delete-space testSpace -o testOrg -f": fmt.Errorf("%s", errorMessage)}
gotError := runCloudFoundryDeleteSpace(&config, &telemetryData, cf, &s)
assert.EqualError(t, gotError, "Deletion of cf space has failed: "+errorMessage, "Wrong error message")

View File

@ -483,7 +483,7 @@ func runCnbBuild(config *cnbBuildOptions, telemetry *buildpacks.Telemetry, image
pathType, source, err := config.resolvePath(utils)
if err != nil {
log.SetErrorCategory(log.ErrorBuild)
return errors.Wrapf(err, "could not resolve path")
return errors.Wrap(err, "could not resolve path")
}
target := "/workspace"

View File

@ -448,7 +448,7 @@ func checkForCompliance(scanResults []codeql.CodeqlFindings, config *codeqlExecu
if unaudited > config.VulnerabilityThresholdTotal {
msg := fmt.Sprintf("Your repository %v with ref %v is not compliant. Total unaudited issues are %v which is greater than the VulnerabilityThresholdTotal count %v",
repoInfo.FullUrl, repoInfo.AnalyzedRef, unaudited, config.VulnerabilityThresholdTotal)
return errors.Errorf(msg)
return errors.New(msg)
}
}
}

View File

@ -313,7 +313,7 @@ func mapDetectError(err error, config detectExecuteScanOptions, utils detectUtil
log.Entry().Infof("policy violation(s) found - step will only create data but not fail due to setting failOnSevereVulnerabilities: false")
} else {
// Error code mapping with more human readable text
err = errors.Wrapf(err, exitCodeMapping(utils.GetExitCode()))
err = errors.Wrap(err, exitCodeMapping(utils.GetExitCode()))
}
}
return err
@ -972,7 +972,7 @@ func writePolicyStatusReports(scanReport reporting.ScanReport, config detectExec
htmlReportPath := "piper_detect_policy_violation_report.html"
if err := utils.FileWrite(htmlReportPath, htmlReport, 0o666); err != nil {
log.SetErrorCategory(log.ErrorConfiguration)
return reportPaths, errors.Wrapf(err, "failed to write html report")
return reportPaths, errors.Wrap(err, "failed to write html report")
}
reportPaths = append(reportPaths, piperutils.Path{Name: "BlackDuck Policy Violation Report", Target: htmlReportPath})
@ -984,7 +984,7 @@ func writePolicyStatusReports(scanReport reporting.ScanReport, config detectExec
}
}
if err := utils.FileWrite(filepath.Join(reporting.StepReportDirectory, fmt.Sprintf("detectExecuteScan_policy_%v.json", fmt.Sprintf("%v", time.Now()))), jsonReport, 0o666); err != nil {
return reportPaths, errors.Wrapf(err, "failed to write json report")
return reportPaths, errors.Wrap(err, "failed to write json report")
}
return reportPaths, nil
@ -993,7 +993,7 @@ func writePolicyStatusReports(scanReport reporting.ScanReport, config detectExec
func writeIpPolicyJson(config detectExecuteScanOptions, utils detectUtils, paths []piperutils.Path, sys *blackduckSystem) (error, int) {
components, err := sys.Client.GetComponentsWithLicensePolicyRule(config.ProjectName, getVersionName(config))
if err != nil {
return errors.Wrapf(err, "failed to get License Policy Violations"), 0
return errors.Wrap(err, "failed to get License Policy Violations"), 0
}
violationCount := getActivePolicyViolations(components)

View File

@ -77,7 +77,7 @@ func (c *httpMockClient) SendRequest(method, url string, body io.Reader, header
if c.errorMessageForURL[url] != "" {
response.StatusCode = 400
return &response, fmt.Errorf(c.errorMessageForURL[url])
return &response, fmt.Errorf("%s", c.errorMessageForURL[url])
}
if c.responseBodyForURL[url] != "" {

View File

@ -281,7 +281,7 @@ func runFortifyScan(ctx context.Context, config fortifyExecuteScanOptions, sys f
reports = append(reports, piperutils.Path{Target: fmt.Sprintf("%vtarget/fortify-scan.*", config.ModulePath)})
reports = append(reports, piperutils.Path{Target: fmt.Sprintf("%vtarget/*.fpr", config.ModulePath)})
if err != nil {
return reports, errors.Wrapf(err, "failed to scan project")
return reports, errors.Wrap(err, "failed to scan project")
}
var message string
@ -785,7 +785,7 @@ func autoresolvePipClasspath(executable string, parameters []string, file string
// redirect stdout and create cp file from command output
outfile, err := os.Create(file)
if err != nil {
return "", errors.Wrapf(err, "failed to create classpath file")
return "", errors.Wrap(err, "failed to create classpath file")
}
defer outfile.Close()
utils.Stdout(outfile)

View File

@ -442,7 +442,7 @@ func runGolangciLint(utils golangBuildUtils, golangciLintDir string, failOnError
return fmt.Errorf("running golangci-lint failed: %w", err)
}
log.Entry().Infof("lint report: \n" + outputBuffer.String())
log.Entry().Infof("lint report: \n%s", outputBuffer.String())
log.Entry().Infof("writing lint report to %s", lintSettings["reportOutputPath"])
err = utils.FileWrite(lintSettings["reportOutputPath"], outputBuffer.Bytes(), 0o644)
if err != nil {

View File

@ -59,7 +59,7 @@ func runIntegrationArtifactDownload(config *integrationArtifactDownloadOptions,
contentDisposition := downloadResp.Header.Get("Content-Disposition")
disposition, params, err := mime.ParseMediaType(contentDisposition)
if err != nil {
return errors.Wrapf(err, "failed to read filename from http response headers, Content-Disposition "+disposition)
return errors.Wrapf(err, "failed to read filename from http response headers, Content-Disposition %s", disposition)
}
filename := params["filename"]
@ -71,12 +71,12 @@ func runIntegrationArtifactDownload(config *integrationArtifactDownloadOptions,
workspaceRelativePath := config.DownloadPath
err = os.MkdirAll(workspaceRelativePath, 0755)
if err != nil {
return errors.Wrapf(err, "Failed to create workspace directory")
return errors.Wrap(err, "Failed to create workspace directory")
}
zipFileName := filepath.Join(workspaceRelativePath, filename)
file, err := os.Create(zipFileName)
if err != nil {
return errors.Wrapf(err, "Failed to create integration flow artifact file")
return errors.Wrap(err, "Failed to create integration flow artifact file")
}
if _, err := io.Copy(file, downloadResp.Body); err != nil {
return err

View File

@ -35,13 +35,13 @@ func (c *kanikoMockClient) SendRequest(method, url string, body io.Reader, heade
c.urlsCalled = append(c.urlsCalled, url)
c.requestBody = body
if len(c.errorMessage) > 0 {
return nil, fmt.Errorf(c.errorMessage)
return nil, fmt.Errorf("%s", c.errorMessage)
}
return &http.Response{StatusCode: c.httpStatusCode, Body: io.NopCloser(bytes.NewReader([]byte(c.responseBody)))}, nil
}
func (c *kanikoMockClient) DownloadFile(url, filename string, header http.Header, cookies []*http.Cookie) error {
if len(c.errorMessage) > 0 {
return fmt.Errorf(c.errorMessage)
return fmt.Errorf("%s", c.errorMessage)
}
return nil
}

View File

@ -385,7 +385,7 @@ func correctDockerConfigEnvVar(config *protecodeExecuteScanOptions, utils protec
}
if err != nil {
return errors.Wrapf(err, "failed to create / update docker config json file")
return errors.Wrap(err, "failed to create / update docker config json file")
}
if len(path) > 0 {

View File

@ -58,7 +58,7 @@ func runShellExecute(config *shellExecuteOptions, telemetryData *telemetry.Custo
if strings.Contains(source, "https") {
scriptLocation, err := piperhttp.DownloadExecutable(config.GithubToken, utils, utils, source)
if err != nil {
return errors.Wrapf(err, "script download error")
return errors.Wrap(err, "script download error")
}
source = scriptLocation
}

View File

@ -453,7 +453,7 @@ func loadCertificates(certificateList []string, client piperhttp.Downloader, run
log.Entry().WithField("source", certificate).WithField("target", target).Info("Downloading TLS certificate")
// download certificate
if err := client.DownloadFile(certificate, target, nil, nil); err != nil {
return errors.Wrapf(err, "Download of TLS certificate failed")
return errors.Wrap(err, "Download of TLS certificate failed")
}
// add certificate to keystore
if err := keytool.ImportCert(runner, truststoreFile, target); err != nil {

View File

@ -635,7 +635,7 @@ func checkPolicyViolations(ctx context.Context, config *ScanOptions, scan *ws.Sc
}
}
if err := utils.FileWrite(filepath.Join(reporting.StepReportDirectory, fmt.Sprintf("whitesourceExecuteScan_ip_%v.json", ws.ReportSha(config.ProductName, scan))), jsonReport, 0o666); err != nil {
return policyReport, errors.Wrapf(err, "failed to write json report")
return policyReport, errors.Wrap(err, "failed to write json report")
}
// we do not add the json report to the overall list of reports for now,
// since it is just an intermediary report used as input for later

View File

@ -302,7 +302,7 @@ func printStatus(XsDeployOptions xsDeployOptions, stdout io.Writer) error {
func handleLog(logDir string) error {
if _, e := os.Stat(logDir); !os.IsNotExist(e) {
log.Entry().Warningf(fmt.Sprintf("Here are the logs (%s):", logDir))
log.Entry().Warningf("Here are the logs (%s):", logDir)
logFiles, e := os.ReadDir(logDir)

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/SAP/jenkins-library
go 1.23.4
go 1.24.0
replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16

View File

@ -1,5 +1,5 @@
module github.com/example/golang-app
go 1.23.4
go 1.24.0
require github.com/gorilla/mux v1.8.0

View File

@ -1,3 +1,3 @@
module github.com/example/golang-app
go 1.23.4
go 1.24.0

View File

@ -196,7 +196,7 @@ func HandleHTTPError(resp *http.Response, err error, message string, connectionD
match, _ := regexp.MatchString(".*EOF$", err.Error())
if match {
AddDefaultDashedLine(1)
log.Entry().Infof("%s", "A connection could not be established to the ABAP system. The typical root cause is the network configuration (firewall, IP allowlist, etc.)")
log.Entry().Info("A connection could not be established to the ABAP system. The typical root cause is the network configuration (firewall, IP allowlist, etc.)")
AddDefaultDashedLine(1)
}
@ -247,13 +247,13 @@ func GetErrorDetailsFromResponse(resp *http.Response) (errorString string, error
// AddDefaultDashedLine adds 25 dashes
func AddDefaultDashedLine(j int) {
for i := 1; i <= j; i++ {
log.Entry().Infof(strings.Repeat("-", 25))
log.Entry().Info(strings.Repeat("-", 25))
}
}
// AddDefaultDebugLine adds 25 dashes in debug
func AddDebugDashedLine() {
log.Entry().Debugf(strings.Repeat("-", 25))
log.Entry().Debug(strings.Repeat("-", 25))
}
/*******************************

View File

@ -155,7 +155,7 @@ func calculateLenghts(results []LogResultsV2) (int, int) {
}
func printDashedLine(i int) {
log.Entry().Infof(strings.Repeat("-", i))
log.Entry().Info(strings.Repeat("-", i))
}
func printLog(logOverviewEntry LogResultsV2, api SoftwareComponentApiInterface) {

View File

@ -471,7 +471,7 @@ func handleHTTPError(resp *http.Response, err error, message string, connectionD
match, _ := regexp.MatchString(".*EOF$", err.Error())
if match {
AddDefaultDashedLine(1)
log.Entry().Infof("%s", "A connection could not be established to the ABAP system. The typical root cause is the network configuration (firewall, IP allowlist, etc.)")
log.Entry().Info("A connection could not be established to the ABAP system. The typical root cause is the network configuration (firewall, IP allowlist, etc.)")
AddDefaultDashedLine(1)
}

View File

@ -161,7 +161,7 @@ func (sys *SystemInstance) CreateRelease(ascAppId int, version string, descripti
response, err := sendRequest(sys, http.MethodPost, fmt.Sprintf("api/v1/apps/%v/releases", ascAppId), bytes.NewBuffer(jsonValue), header)
if err != nil {
return createReleaseResponse, errors.Wrapf(err, "creating release")
return createReleaseResponse, errors.Wrap(err, "creating release")
}
json.Unmarshal(response, &createReleaseResponse)

View File

@ -31,7 +31,7 @@ func (c *httpMockClient) SendRequest(method, url string, body io.Reader, header
if c.errorMessageForURL[url] != "" {
response.StatusCode = 400
return &response, fmt.Errorf(c.errorMessageForURL[url])
return &response, fmt.Errorf("%s", c.errorMessageForURL[url])
}
if c.responseBodyForURL[url] != "" {

View File

@ -63,7 +63,7 @@ func CreateBuildSettingsInfo(config *BuildOptions, buildTool string) (string, er
jsonResult, err = json.Marshal(&jsonMap)
if err != nil {
return "", errors.Wrapf(err, "Creating build settings failed with json marshalling")
return "", errors.Wrap(err, "Creating build settings failed with json marshalling")
}
} else {
var settings []BuildOptions
@ -111,7 +111,7 @@ func CreateBuildSettingsInfo(config *BuildOptions, buildTool string) (string, er
return "", nil
}
if err != nil {
return "", errors.Wrapf(err, "Creating build settings failed with json marshalling")
return "", errors.Wrap(err, "Creating build settings failed with json marshalling")
}
}

View File

@ -940,7 +940,7 @@ func (sys *SystemInstance) scanProject(scanConfig map[string]interface{}) (Scan,
jsonValue, err := json.Marshal(scanConfig)
header := http.Header{}
header.Set("Content-Type", "application/json")
sys.logger.Tracef("Starting scan with settings: " + string(jsonValue))
sys.logger.Tracef("Starting scan with settings: %s", string(jsonValue))
data, err := sendRequest(sys, http.MethodPost, "/scans/", bytes.NewBuffer(jsonValue), header, []int{})
if err != nil {

View File

@ -30,7 +30,7 @@ func Decrypt(secret, base64CipherText []byte) ([]byte, error) {
iv := cipherText[:aes.BlockSize]
cipherText = cipherText[aes.BlockSize:]
stream := cipher.NewCFBDecrypter(block, iv)
stream := cipher.NewCTR(block, iv)
stream.XORKeyStream(cipherText, cipherText)
return cipherText, nil
@ -54,7 +54,7 @@ func Encrypt(secret, inBytes []byte) ([]byte, error) {
return nil, fmt.Errorf("failed to init iv: %w", err)
}
stream := cipher.NewCFBEncrypter(block, iv)
stream := cipher.NewCTR(block, iv)
stream.XORKeyStream(cipherText[aes.BlockSize:], inBytes)
return []byte(base64.StdEncoding.EncodeToString(cipherText)), nil

View File

@ -30,7 +30,7 @@ func TestTriggerJob(t *testing.T) {
job := &mocks.Job{}
job.Test(t)
job.
On("Poll", ctx).Return(404, fmt.Errorf(mock.Anything))
On("Poll", ctx).Return(404, fmt.Errorf("%s", mock.Anything))
// test
build, err := TriggerJob(ctx, jenkins, job, jobParameters)
// asserts
@ -49,7 +49,7 @@ func TestTriggerJob(t *testing.T) {
job.
On("Poll", ctx).Return(200, nil).
On("InvokeSimple", ctx, map[string]string{}).
Return(queueID, fmt.Errorf(mock.Anything))
Return(queueID, fmt.Errorf("%s", mock.Anything))
// test
build, err := TriggerJob(ctx, jenkins, job, jobParameters)
// asserts
@ -92,7 +92,7 @@ func TestTriggerJob(t *testing.T) {
Return(&gojenkins.Job{})
jenkins.
On("GetBuildFromQueueID", ctx, mock.Anything, queueID).
Return(nil, fmt.Errorf(mock.Anything))
Return(nil, fmt.Errorf("%s", mock.Anything))
// test
build, err := TriggerJob(ctx, jenkins, job, jobParameters)
// asserts

View File

@ -32,7 +32,7 @@ func (c *DownloadMock) DownloadImage(imageRef, targetDir string) (v1.Image, erro
}
if len(c.ReturnError) > 0 {
return nil, fmt.Errorf(c.ReturnError)
return nil, fmt.Errorf("%s", c.ReturnError)
}
return c.ReturnImage, nil
}
@ -47,7 +47,7 @@ func (c *DownloadMock) DownloadImageContent(imageRef, targetFile string) (v1.Ima
}
if len(c.ReturnError) > 0 {
return nil, fmt.Errorf(c.ReturnError)
return nil, fmt.Errorf("%s", c.ReturnError)
}
return c.ReturnImage, nil
}
@ -61,7 +61,7 @@ func (c *DownloadMock) GetRemoteImageInfo(imageRef string) (v1.Image, error) {
}
if len(c.ReturnError) > 0 {
return nil, fmt.Errorf(c.ReturnError)
return nil, fmt.Errorf("%s", c.ReturnError)
}
return c.RemoteImageInfo, nil

View File

@ -30,12 +30,12 @@ func (u *UnknownOrchestratorConfigProvider) BuildStatus() string {
}
func (u *UnknownOrchestratorConfigProvider) ChangeSets() []ChangeSet {
log.Entry().Infof(unknownOrchestratorWarning)
log.Entry().Info(unknownOrchestratorWarning)
return []ChangeSet{}
}
func (u *UnknownOrchestratorConfigProvider) BuildReason() string {
log.Entry().Infof(unknownOrchestratorWarning)
log.Entry().Info(unknownOrchestratorWarning)
return "n/a"
}

View File

@ -24,7 +24,7 @@ func (m *mavenMockRunner) Evaluate(opts *maven.EvaluateOptions, expression strin
m.opts = opts
m.expression = expression
if len(m.evaluateErrorString) > 0 {
return "", fmt.Errorf(m.evaluateErrorString)
return "", fmt.Errorf("%s", m.evaluateErrorString)
}
return m.stdout, nil
}
@ -32,7 +32,7 @@ func (m *mavenMockRunner) Evaluate(opts *maven.EvaluateOptions, expression strin
func (m *mavenMockRunner) Execute(opts *maven.ExecuteOptions, utils maven.Utils) (string, error) {
m.execOpts = opts
if len(m.executeErrorString) > 0 {
return "", fmt.Errorf(m.executeErrorString)
return "", fmt.Errorf("%s", m.executeErrorString)
}
if opts.ReturnStdout {
return m.stdout, nil

View File

@ -30,7 +30,7 @@ class PiperGoUtils implements Serializable {
if (steps.env.REPOSITORY_UNDER_TEST && steps.env.LIBRARY_VERSION_UNDER_TEST) {
steps.echo("Running in a consumer test, building unit-under-test binary for verification.")
steps.dockerExecute(script: steps, dockerImage: 'golang:1.23.4', dockerOptions: '-u 0', dockerEnvVars: [
steps.dockerExecute(script: steps, dockerImage: 'golang:1.24.0', dockerOptions: '-u 0', dockerEnvVars: [
REPOSITORY_UNDER_TEST: steps.env.REPOSITORY_UNDER_TEST,
LIBRARY_VERSION_UNDER_TEST: steps.env.LIBRARY_VERSION_UNDER_TEST
]) {