Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an article about using Go + Habitat #3145

Open
tashimi opened this issue Sep 14, 2017 · 5 comments
Open

Add an article about using Go + Habitat #3145

tashimi opened this issue Sep 14, 2017 · 5 comments
Labels
Documentation Flags an issue / PR for attention by the technical documentation team Stale Type:Hackathon
Milestone

Comments

@tashimi
Copy link
Contributor

tashimi commented Sep 14, 2017

When building a go app, treat private repos the same as any in-code dependency - you probably don’t want to package them all independently, since the go build system has hard requirements on location of the software itself.

You’ll need to inject the keys needed into the studio, and then let go dep do its thing.

You need to lay down a .netrc file in your studio and use https:// git urls everywhere.

We have some code like this in our .studiorc files for projects that need to talk to private repos:

  if [[ -z $GITHUB_TOKEN ]]; then
    echo -e "\nError: Unable to configure ~/.netrc in the studio."
    echo "Missing the environment variable: GITHUB_TOKEN"
    echo -e "\nVerify that you have a file called '.secrets' with the following export:"
    echo "export GITHUB_TOKEN=[your-secret-token]"
    exit 1
  else
    echo -e "machine github.com\n  login $GITHUB_TOKEN" >> ~/.netrc
    cat <<EOF > $HOME/.netrc
machine github.com
   login $GITHUB_TOKEN
EOF
  fi
}

# Setup ~/.netrc configuration in the studio
#
# We have a dependency with the converge-service that is a private
# github repository, at the moment the go dep tool doesn't support
# this pattern:
#
#    (for more information look at the following issues)
# => https://github.com/golang/dep/issues/286
# => https://github.com/golang/dep/issues/174
#
# For that reason we will setup the `~/.netrc` file to point to our
# private `GITHUB_TOKEN` and be able to consume the private repo
#
# Requirements:
# => Create a file called `.secrets` with the content:
#
# export GITHUB_TOKEN=secret
#
source /src/.secrets
generate_netrc_config
# But what is this `.netrc` file?
# => https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html```

Similarly, you could inject your SSH key via `studiorc/.secrets`

Use https instead of ssh with github  because folks in proxied environments have a ton of trouble using git-over-ssh

@reset
Copy link
Collaborator

reset commented Sep 24, 2017

Documentation will get us there in the meantime but this experience should be as seamless and low friction to setup as possible. Related to #2099

@rahulwa
Copy link

rahulwa commented Oct 6, 2017

Can anybody help me to pass host ssh key to studio (like while doing hab studio enter) so that can be accessed at build time.

@reset
Copy link
Collaborator

reset commented Oct 6, 2017

@rahulwa the best place to look for help is in the general channel of our Slack discussion. A bunch of people who are using and building Habitat are all located there!

@stale
Copy link

stale bot commented Apr 3, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

@stale stale bot added the Stale label Apr 3, 2020
@christophermaier christophermaier added Documentation Flags an issue / PR for attention by the technical documentation team and removed A-documentation labels Aug 18, 2020
@stale stale bot removed the Stale label Aug 18, 2020
@rahulgoel1 rahulgoel1 removed the E-easy label Jul 23, 2021
@stale
Copy link

stale bot commented Aug 12, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

@stale stale bot added the Stale label Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Flags an issue / PR for attention by the technical documentation team Stale Type:Hackathon
Projects
None yet
Development

No branches or pull requests

7 participants