Skip to content

Commit

Permalink
fixes go build on windows (#4858)
Browse files Browse the repository at this point in the history
* fixes `go build` on windows
  • Loading branch information
hilmarf authored Mar 7, 2024
1 parent c0e56d2 commit 09cd271
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
10 changes: 1 addition & 9 deletions cmd/cnbBuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"path"
"path/filepath"
"syscall"

"github.com/SAP/jenkins-library/pkg/buildpacks"
"github.com/SAP/jenkins-library/pkg/buildsettings"
Expand All @@ -21,7 +20,6 @@ import (
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/piperutils"
"github.com/SAP/jenkins-library/pkg/syft"

"github.com/SAP/jenkins-library/pkg/telemetry"
"github.com/imdario/mergo"
"github.com/mitchellh/mapstructure"
Expand Down Expand Up @@ -585,13 +583,7 @@ func runCnbBuild(config *cnbBuildOptions, telemetry *buildpacks.Telemetry, image
}

creatorArgs = append(creatorArgs, fmt.Sprintf("%s:%s", containerImage, targetImage.ContainerImageTag))
attr := &syscall.SysProcAttr{
Credential: &syscall.Credential{
Uid: uint32(uid),
Gid: uint32(gid),
NoSetGroups: true,
},
}
attr := getSysProcAttr(uid, gid)

err = utils.RunExecutableWithAttrs(creatorPath, attr, creatorArgs...)
if err != nil {
Expand Down
17 changes: 17 additions & 0 deletions cmd/cnbBuildAttr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//go:build !windows

package cmd

import (
"syscall"
)

func getSysProcAttr(uid int, gid int) *syscall.SysProcAttr {
return &syscall.SysProcAttr{
Credential: &syscall.Credential{
Uid: uint32(uid),
Gid: uint32(gid),
NoSetGroups: true,
},
}
}
11 changes: 11 additions & 0 deletions cmd/cnbBuildAttr_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build windows

package cmd

import (
"syscall"
)

func getSysProcAttr(_ int, _ int) *syscall.SysProcAttr {
return &syscall.SysProcAttr{}
}

0 comments on commit 09cd271

Please sign in to comment.