I want to install a private go module without using ssh key, PAT token or github OAuth token. This private github repo belongs to me and I can successfully checkout in the repo using service connection in ADO pipeline, but i am not able to install the repo as a go module as it is asking for github authentication. Clusterfleet is the private module that needs to be installed.
Is there any way to do it?
resources:
- repository: Clusterfleet
type: github
endpoint: "Falcon (1)"
name: webxt-microsoft/clusterfleet
ref: refs/tags/v0.2.7
I tried making a local clusterfleet package and force the pipeline to use the local package with go.work file.
- script: |
# Set GOPATH to include the pipeline workspace
export GOPATH=$(Pipeline.Workspace)/go
echo "##vso[task.setvariable variable=GOPATH]$GOPATH"
# Add the Clusterfleet module to GOPATH
mkdir -p $GOPATH/src/github.com/webxt-microsoft
ln -s $(Build.SourcesDirectory)/clusterfleet $GOPATH/src/github.com/webxt-microsoft/clusterfleet
# Set GOPRIVATE to include github.com/webxt-microsoft
go env -w GOPRIVATE=github.com/webxt-microsoft
# Update Go module cache
cd $GOPATH/src/github.com/webxt-microsoft/clusterfleet
go mod download
displayName: 'Setup Clusterfleet module'
- script: |
echo "Creating go.work file"
cat << EOF > $(Pipeline.Workspace)/go.work
go 1.21
use (
$(GOPATH)/src/github.com/webxt-microsoft/clusterfleet
)
EOF
cat $(Pipeline.Workspace)/go.work
displayName: 'Create go.work file'
But it is not working and throws the following error:
go: github.com/webxt-microsoft/falconfleet/cmd/apiserverproxy/app/run imports github.com/webxt-microsoft/clusterfleet/pkg/client/clientset/versioned: reading github.com/webxt-microsoft/clusterfleet/go.mod at revision v0.2.7: git ls-remote -q origin in /mnt/vss/_work/1/go/pkg/mod/cache/vcs/cdbe37fa44eec61731b059b590c47e1b60a2c549f9a741905e85b859212d994b: exit status 128: fatal: could not read Username for 'https://github.com': terminal prompts disabled Confirm the import path was entered correctly. If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
Replacing the remote path to local path of the module worked for me.
go mod edit -replace github.com/webxt-microsoft/clusterfleet=../clusterfleet