Coder Social home page Coder Social logo

atlas-go's Introduction

Atlas Go

Latest Version Build Status Go Documentation

Atlas Go is the official Go client for HashiCorp's Atlas service.

Usage

Authenticating with username and password

Atlas Go can automatically generate an API authentication token given a username and password. For example:

client := atlas.DefaultClient()
token, err := client.Login("username", "password")
if err != nil {
  panic(err)
}

The Login function returns an API token that can be used to sign requests. This function also sets the Token parameter on the Atlas Client, so future requests are signed with this access token.

If you have two-factor authentication enabled, you must manually generate an access token on the Atlas website.

Usage with on-premise Atlas

Atlas Go supports on-premise Atlas installs, but you must specify the URL of the Atlas server in the client:

client, err := atlas.NewClient("https://url.to.your.atlas.server")
if err != nil {
  panic(err)
}

Example

The following example generates a new access token for a user named "sethvargo", generates a new Application named "frontend", and uploads the contents of a path to said application with some user-supplied metadata:

client := atlas.DefaultClient()
token, err := client.Login("sethvargo", "b@c0n")
if err != nil {
  log.Fatalf("err logging in: %s", err)
}

app, err := client.CreateApp("sethvargo", "frontend")
if err != nil {
  log.Fatalf("err creating app: %s", err)
}

metadata := map[string]interface{
  "developed-on": runtime.GOOS,
}

data, size := functionThatReturnsAnIOReaderAndSize()
version, err := client.UploadApp(app, metadata, data, size)
if err != nil {
  log.Fatalf("err uploading app: %s", err)
}

// version is the unique version of the application that was just uploaded
version

FAQ

Q: Can I specify my token via an environment variable?
A: All of HashiCorp's products support the ATLAS_TOKEN environment variable. You can set this value in your shell profile or securely in your environment and it will be used.

Q: How can I authenticate if I have two-factor authentication enabled?
A: If you have two-factor authentication enabled, you must generate an access token via the Atlas website and pass it to the client initialization. The Atlas Go client does not support generating access tokens from two-factor authentication enabled accounts via the command line.

Q: Why do I need to specify the "user" for an Application, Build Configuration, and Runtime?
A: Since you can be a collaborator on different projects, we wanted to have absolute clarity around which artifact you are currently interacting with.

Contributing

To hack on Atlas Go, you will need a modern Go environment. To compile the atlas-go binary and run the test suite, simply execute:

$ make

This will compile the atlas-go binary into bin/atlas-go and run the test suite.

If you just want to run the tests:

$ make test

Or to run a specific test in the suite:

go test ./... -run SomeTestFunction_name

Submit Pull Requests and Issues to the Atlas Go project on GitHub.

atlas-go's People

Contributors

armon avatar calebalbers avatar cbednarski avatar ceh avatar jbardin avatar jefferai avatar justincampbell avatar mitchellh avatar mwhooker avatar pearkes avatar phinze avatar ryanuber avatar sethvargo avatar swampdragons avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atlas-go's Issues

Uploader barfs on symlinks

When trying to upload and archive a directory that contains symlinks, the archiver gets confused and errors:

$ packer push -create packer.json
Error archiving: failed copying file to archive: /Users/sethvargo/Desktop/test/discourse/adminjs

$ ls -al adminjs
lrwxr-xr-x  1 sethvargo  staff  28 Jan 21 12:31 adminjs -> app/assets/javascripts/admin

Triggering packer builds and terraform plan/apply

Hi,

Am I missing something or triggering packer/terraform runs is not supported in this client? If so - does it have some specific reason or it's something planned in the future and PRs are welcome?

If anyone has insights about Atlas API docs (if there're going to be published anytime soon) please share.

Thanks!

Bug in ArtifactFileURL, missing version

The url doesn't contain the version, which means the correct file path is not returned.

atlas-go/v1/artifact.go

Lines 185 to 194 in 85a782d

func (c *Client) ArtifactFileURL(av *ArtifactVersion) (*url.URL, error) {
if !av.File {
return nil, nil
}
u := *c.URL
u.Path = fmt.Sprintf("/api/v1/artifacts/%s/%s/%s/file",
av.User, av.Name, av.Type)
return &u, nil
}

u.Path = fmt.Sprintf("/api/v1/artifacts/%s/%s/%s/file", av.User, av.Name, av.Type)
should be u.Path = fmt.Sprintf("/api/v1/artifacts/%s/%s/%s/%s/file", av.User, av.Name, av.Type, av.Version)

Called from here in Terraform.

Add explicit support for ** in glob

Glob in Go doesn’t actually work the way it’s tested here:

Include: []string{"build/**/*"},

This test passes in *nix because (I think) the underlying shell takes over and expands the path. However, this doesn't work on Windows, and so is not portable. This is technically a bug in the test but people may be using this in the wild... Do we want to fix it by adding ** support for Windows?

Failing tests

Hello,

It looks like the tests have been failing for six months.

I am packaging atlas-go for Debian and I am wondering what I should do. Were the tests abandoned? Should I disable them?

Online Logs?

It seems that I never get a log for any build. They always just say "Waiting for logs...". This is even true of builds that have finished, successfully or otherwise. It would be really nice if they were live updating. However, it would be nice to see them at all.

Tracking Packer job status

Hi there,

It's possible the trigger a new Packer build with the current API but it doesn't seem possible to follow the status of this build.

This kind of feature could be useful when you have to maintain Packer images with multiple "layers" for example. You build the "base" image and then build the next image on top of the base one.

Do you think this feature can be added to the client/api ?

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.