Comments (5)
Just wanted to give a quick update on this question. Currently there is a release of the Paketo Git buildpack that allows user to configure a custom git credential manager using a service binding. Feel free to check that buildpack out and give it a test drive and see if this works out for you.
from go-mod-vendor.
With the merging of paketo-buildpacks/go#558 I believe that this workflow should now be supported! I am going to close this issue for now but if you have any further feedback feel free to either open a new issue or reopen this one!
from go-mod-vendor.
Hi!
Thanks for bringing it up, @kvedurmu !
@matthewmcnew had suggested using using service bindings for providing the credentials, so I came up with a little patch to this buildpack that allowed me to copy a .netrc
injected via bindings to $HOME/.netrc
where git
could then read the creds to use in its transport (https)
diff --git a/build.go b/build.go
index 4736fbe..81f8977 100644
--- a/build.go
+++ b/build.go
@@ -1,6 +1,11 @@
package gomodvendor
import (
+ "fmt"
+ "io"
+ "os"
+ "path/filepath"
+
"github.com/paketo-buildpacks/packit"
)
@@ -10,10 +15,38 @@ type BuildProcess interface {
Execute(path, workingDir string) error
}
+func cp(src, dst string) error {
+ in, err := os.Open(src)
+ if err != nil {
+ return fmt.Errorf("open: %w", err)
+ }
+ defer in.Close()
+
+ out, err := os.Create(dst)
+ if err != nil {
+ return fmt.Errorf("create: %w", err)
+ }
+ defer out.Close()
+
+ if _, err = io.Copy(out, in); err != nil {
+ return fmt.Errorf("copy: %w", err)
+ }
+
+ return nil
+}
+
+const netrcFromBinding = "/platform/bindings/netrc/secret/.netrc"
+
func Build(buildProcess BuildProcess, logs LogEmitter) packit.BuildFunc {
return func(context packit.BuildContext) (packit.BuildResult, error) {
logs.Title("%s %s", context.BuildpackInfo.Name, context.BuildpackInfo.Version)
+ if _, err := os.Stat(netrcFromBinding); !os.IsNotExist(err) {
+ if err := cp(netrcFromBinding, filepath.Join(os.Getenv("HOME"), ".netrc")); err != nil {
+ return packit.BuildResult{}, fmt.Errorf("cp: %w", err)
+ }
+ }
+
ok, err := buildProcess.ShouldRun(context.WorkingDir)
if err != nil {
return packit.BuildResult{}, err
which then works great with kpack
s use of service bindings:
#@ load("@ytt:data", "data")
---
kind: Build
apiVersion: kpack.io/v1alpha1
metadata:
name: build
spec:
tags: ['harbor.internal.unicorns.com/my/thing']
serviceAccount: controllers-creds
bindings:
- name: netrc
metadataRef:
name: netrc-metadata
secretRef:
name: bindings-netrc
builder:
image: harbor.internal.unicorns.com/my/builder-with-patched-go-mod@sha256:12345
source:
git:
url: 'https://gitlab.internal.unicorns.com/my/project'
revision: a-revision
---
apiVersion: v1
kind: Secret
metadata:
name: bindings-netrc
type: Opaque
stringData:
.netrc: |-
machine gitlab.internal.unicorns.com
#@ "login" + data.values.git.username
#@ "password" + data.values.git.token
---
apiVersion: v1
kind: ConfigMap
metadata:
name: netrc-metadata
data:
kind: go
provider: sample
happy to help in any form!
from go-mod-vendor.
I'm interested in seeing this happen as well! Any chance there'll be any movement on this?
from go-mod-vendor.
This would be useful for me! I'm currently trying to pull in a private dependency and had to resort to vendoring in the dependency manually for the time being.
from go-mod-vendor.
Related Issues (20)
- Use new io.paketo.stacks.tiny ID to indicate "tiny" HOT 3
- Rename to go-mod-vendor
- Cannot build vendored go mod apps HOT 1
- Don't create an empty `mod-cache` layer
- Require Go version specified in go.mod as a minimum version
- Buildpack should run to set BP_GO_VERSION for go-dist buildpack HOT 1
- Should go-mod-vendor provide a dependency for downstream buildpacks? HOT 3
- Use GOMODCACHE environment variable instead of setting GOPATH
- SBOM generation includes all dependencies in working dir, not just Go ones. HOT 1
- Refactor proposal: simplify detect logic when go.mod file does not exist. HOT 1
- Failure: Go get update workflow HOT 1
- Failure: Create Draft Release workflow HOT 3
- `go mod graph` can run for a long time slowing down rebuilds HOT 1
- Failure: Approve bot PR workflow HOT 5
- Failure: Update GitHub config workflow HOT 1
- Discussion: go 1.21+ toolchain version
- Failure: Push Buildpackage workflow HOT 1
- Failure: Publish draft releases
- Go Proxy Configuration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-mod-vendor.