Issues With Go Scaffolding And A Private Repository


#1

I’m trying to get a package building using the go scaffolding. I have the configuration line:
pkg_source="https://user:tokenGoesHere@gitlab.com/path/to/repository"

When I build the project, I get go: cannot use path@version syntax in GOPATH mode.

How do I resolve this issue?


#2

I ended up using the just the regular https path for pkg_source and then did this:

do_before() {
    git config --global url."https://".insteadOf git://
    git config --global credential.helper store

    local repository_username="usernameGoesHere"
    local repository_password="passwordGoesHere"

    echo "https://$repository_username:$repository_password@gitlab.com" > ~/.git-credentials
}

As a tip, if you’re using writing in go and using gitlab, don’t use subgroups


#3

I generate a Gitlab Token then use it to do the download like this:

pkg_gitlab_id=849384
pkg_source="https://gitlab.com/api/v4/projects/${pkg_gitlab_id}/repository/archive?private_token=${gitlab_token}&sha=${pkg_version}"

I pull the $gitlab_token in from outside plan.sh


#4

I’m not super familiar with the gitlab api, but does that require a release to be tagged? Or can you use it just by specifying a branch?


#5

It’s a confusing name, it can be a branch / tag / sha I think


#6

Awesome. For the $gitlab_token, what method do you use to grab that?


#7

I have no idea if this is the right way of doing it - but I have all my plans in directories, and in the root (where I run my studios) I have a file I can source (as the first line in the plan) which exports my token.