* Contains the SSH fix by @watters of #3840.
* Fixed minor lint error. * Added documentation for this builder in `triton.html.md`. * Added (and updated) the needed Joyent Triton Cloud API Go libraries to `vendor.json`.
This commit is contained in:
parent
396147b1ee
commit
7606dd541b
|
@ -38,8 +38,10 @@ func (c *AccessConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
errs = append(errs, fmt.Errorf("triton_key_id is required to use the triton builder"))
|
errs = append(errs, fmt.Errorf("triton_key_id is required to use the triton builder"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.KeyMaterial == "" {
|
var err error
|
||||||
errs = append(errs, fmt.Errorf("triton_key_material is required to use the triton builder"))
|
c.KeyMaterial, err = processKeyMaterial(c.KeyMaterial)
|
||||||
|
if c.KeyMaterial == "" || err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("valid triton_key_material is required to use the triton builder"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
|
|
|
@ -35,9 +35,9 @@ func TestAccessConfig_Prepare(t *testing.T) {
|
||||||
|
|
||||||
func testAccessConfig(t *testing.T) AccessConfig {
|
func testAccessConfig(t *testing.T) AccessConfig {
|
||||||
return AccessConfig{
|
return AccessConfig{
|
||||||
Endpoint: "test-endpoint",
|
Endpoint: "test-endpoint",
|
||||||
Account: "test-account",
|
Account: "test-account",
|
||||||
KeyID: "test-id",
|
KeyID: "test-id",
|
||||||
KeyMaterial: "test-private-key",
|
KeyMaterial: "test-private-key",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
|
||||||
*.o
|
|
||||||
*.a
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Folders
|
|
||||||
_obj
|
|
||||||
_test
|
|
||||||
|
|
||||||
# Architecture specific extensions/prefixes
|
|
||||||
*.[568vq]
|
|
||||||
[568vq].out
|
|
||||||
|
|
||||||
*.cgo1.go
|
|
||||||
*.cgo2.c
|
|
||||||
_cgo_defun.c
|
|
||||||
_cgo_gotypes.go
|
|
||||||
_cgo_export.*
|
|
||||||
|
|
||||||
_testmain.go
|
|
||||||
|
|
||||||
*.exe
|
|
||||||
|
|
||||||
# IntelliJ files
|
|
||||||
.idea
|
|
||||||
*.iml
|
|
|
@ -1,2 +1,98 @@
|
||||||
gocommon
|
gocommon
|
||||||
========
|
========
|
||||||
|
|
||||||
|
Common Go library for Joyent's Triton and Manta.
|
||||||
|
|
||||||
|
[![wercker status](https://app.wercker.com/status/2f63bf7f68bfdd46b979abad19c0bee0/s/master "wercker status")](https://app.wercker.com/project/byKey/2f63bf7f68bfdd46b979abad19c0bee0)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Use `go-get` to install gocommon.
|
||||||
|
```
|
||||||
|
go get github.com/joyent/gocommon
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Auto-generated documentation can be found on godoc.
|
||||||
|
|
||||||
|
- [github.com/joyent/gocommon](http://godoc.org/github.com/joyent/gocommon)
|
||||||
|
- [github.com/joyent/gocommon/client](http://godoc.org/github.com/joyent/client)
|
||||||
|
- [github.com/joyent/gocommon/errors](http://godoc.org/github.com/joyent/gocommon/errors)
|
||||||
|
- [github.com/joyent/gocommon/http](http://godoc.org/github.com/joyent/gocommon/http)
|
||||||
|
- [github.com/joyent/gocommon/jpc](http://godoc.org/github.com/joyent/gocommon/jpc)
|
||||||
|
- [github.com/joyent/gocommon/testing](http://godoc.org/github.com/joyent/gocommon/testing)
|
||||||
|
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Report bugs and request features using [GitHub Issues](https://github.com/joyent/gocommon/issues), or contribute code via a [GitHub Pull Request](https://github.com/joyent/gocommon/pulls). Changes will be code reviewed before merging. In the near future, automated tests will be run, but in the meantime please `go fmt`, `go lint`, and test all contributions.
|
||||||
|
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
This library assumes a Go development environment setup based on [How to Write Go Code](https://golang.org/doc/code.html). Your GOPATH environment variable should be pointed at your workspace directory.
|
||||||
|
|
||||||
|
You can now use `go get github.com/joyent/gocommon` to install the repository to the correct location, but if you are intending on contributing back a change you may want to consider cloning the repository via git yourself. This way you can have a single source tree for all Joyent Go projects with each repo having two remotes -- your own fork on GitHub and the upstream origin.
|
||||||
|
|
||||||
|
For example if your GOPATH is `~/src/joyent/go` and you're working on multiple repos then that directory tree might look like:
|
||||||
|
|
||||||
|
```
|
||||||
|
~/src/joyent/go/
|
||||||
|
|_ pkg/
|
||||||
|
|_ src/
|
||||||
|
|_ github.com
|
||||||
|
|_ joyent
|
||||||
|
|_ gocommon
|
||||||
|
|_ gomanta
|
||||||
|
|_ gosdc
|
||||||
|
|_ gosign
|
||||||
|
```
|
||||||
|
|
||||||
|
### Recommended Setup
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir -p ${GOPATH}/src/github.com/joyent
|
||||||
|
$ cd ${GOPATH}/src/github.com/joyent
|
||||||
|
$ git clone git@github.com:<yourname>/gocommon.git
|
||||||
|
|
||||||
|
# fetch dependencies
|
||||||
|
$ git clone git@github.com:<yourname>/gosign.git
|
||||||
|
$ go get -v -t ./...
|
||||||
|
|
||||||
|
# add upstream remote
|
||||||
|
$ cd gocommon
|
||||||
|
$ git remote add upstream git@github.com:joyent/gocommon.git
|
||||||
|
$ git remote -v
|
||||||
|
origin git@github.com:<yourname>/gocommon.git (fetch)
|
||||||
|
origin git@github.com:<yourname>/gocommon.git (push)
|
||||||
|
upstream git@github.com:joyent/gocommon.git (fetch)
|
||||||
|
upstream git@github.com:joyent/gocommon.git (push)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Tests
|
||||||
|
|
||||||
|
The library needs values for the `SDC_URL`, `MANTA_URL`, `MANTA_KEY_ID` and `SDC_KEY_ID` environment variables even though the tests are run locally. You can generate a temporary key and use its fingerprint for tests without adding the key to your Triton Cloud account.
|
||||||
|
|
||||||
|
```
|
||||||
|
# create a temporary key
|
||||||
|
ssh-keygen -b 2048 -C "Testing Key" -f /tmp/id_rsa -t rsa -P ""
|
||||||
|
|
||||||
|
# set up environment
|
||||||
|
# note: leave the -E md5 argument off on older ssh-keygen
|
||||||
|
export KEY_ID=$(ssh-keygen -E md5 -lf /tmp/id_rsa | awk -F' ' '{print $2}' | cut -d':' -f2-)
|
||||||
|
export SDC_KEY_ID=${KEY_ID}
|
||||||
|
export MANTA_KEY_ID=${KEY_ID}
|
||||||
|
export SDC_URL=https://us-east-1.api.joyent.com
|
||||||
|
export MANTA_URL=https://us-east.manta.joyent.com
|
||||||
|
|
||||||
|
cd ${GOPATH}/src/github.com/joyent/gocommon
|
||||||
|
go test ./...
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build the Library
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ${GOPATH}/src/github.com/joyent/gocommon
|
||||||
|
go build ./...
|
||||||
|
```
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
box: golang
|
||||||
|
|
||||||
|
build:
|
||||||
|
steps:
|
||||||
|
# Sets the go workspace and places you package
|
||||||
|
# at the right place in the workspace tree
|
||||||
|
- setup-go-workspace:
|
||||||
|
package-dir: github.com/joyent/gocommon
|
||||||
|
|
||||||
|
# Gets the dependencies
|
||||||
|
- script:
|
||||||
|
name: go get
|
||||||
|
code: |
|
||||||
|
go get -v -t ./...
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
- script:
|
||||||
|
name: go build
|
||||||
|
code: |
|
||||||
|
go build ./...
|
||||||
|
|
||||||
|
- script:
|
||||||
|
name: make a new key for testing
|
||||||
|
code: |
|
||||||
|
ssh-keygen -b 2048 \
|
||||||
|
-C "Testing Key" \
|
||||||
|
-f /root/.ssh/id_rsa \
|
||||||
|
-t rsa \
|
||||||
|
-P ""
|
||||||
|
|
||||||
|
# Test the project
|
||||||
|
- script:
|
||||||
|
name: go test
|
||||||
|
code: |
|
||||||
|
export KEY_ID=$(ssh-keygen -lf /root/.ssh/id_rsa | awk -F' ' '{print $2}' | cut -d':' -f2-)
|
||||||
|
export SDC_KEY_ID=${KEY_ID}
|
||||||
|
export MANTA_KEY_ID=${KEY_ID}
|
||||||
|
export SDC_URL=https://us-east-1.api.joyent.com
|
||||||
|
export MANTA_URL=https://us-east.manta.joyent.com
|
||||||
|
go test ./...
|
|
@ -0,0 +1,163 @@
|
||||||
|
# gosdc
|
||||||
|
|
||||||
|
[![wercker status](https://app.wercker.com/status/349ee60ed0afffd99d2b2b354ada5938/s/master "wercker status")](https://app.wercker.com/project/bykey/349ee60ed0afffd99d2b2b354ada5938)
|
||||||
|
|
||||||
|
`gosdc` is a Go client for Joyent's SmartDataCenter
|
||||||
|
|
||||||
|
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-generate-toc again -->
|
||||||
|
**Table of Contents**
|
||||||
|
|
||||||
|
- [gosdc](#gosdc)
|
||||||
|
- [Usage](#usage)
|
||||||
|
- [Examples](#examples)
|
||||||
|
- [Resources](#resources)
|
||||||
|
- [License](#license)
|
||||||
|
|
||||||
|
<!-- markdown-toc end -->
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
To create a client
|
||||||
|
([`*cloudapi.Client`](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client)),
|
||||||
|
you'll need a few things:
|
||||||
|
|
||||||
|
1. your account ID
|
||||||
|
2. the ID of the key associated with your account
|
||||||
|
3. your private key material
|
||||||
|
4. the cloud endpoint you want to use (for example
|
||||||
|
`https://us-east-1.api.joyentcloud.com`)
|
||||||
|
|
||||||
|
Given these four pieces of information, you can initialize a client with the
|
||||||
|
following:
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/joyent/gocommon/client"
|
||||||
|
"github.com/joyent/gosdc/cloudapi"
|
||||||
|
"github.com/joyent/gosign/auth"
|
||||||
|
)
|
||||||
|
|
||||||
|
func client(key, keyId, account, endpoint string) (*cloudapi.Client, error) {
|
||||||
|
keyData, err := ioutil.ReadFile(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
userAuth, err := auth.NewAuth(account, string(keyData), "rsa-sha256")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
creds := &auth.Credentials{
|
||||||
|
UserAuthentication: auth,
|
||||||
|
SdcKeyId: keyId,
|
||||||
|
SdcEndpoint: auth.Endpoint{URL: endpoint},
|
||||||
|
}
|
||||||
|
|
||||||
|
return cloudapi.New(client.NewClient(
|
||||||
|
creds.SdcEndpoint.URL,
|
||||||
|
cloudapi.DefaultAPIVersion,
|
||||||
|
creds,
|
||||||
|
log.New(os.Stderr, "", log.LstdFlags),
|
||||||
|
)), nil
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
Projects using the gosdc API:
|
||||||
|
|
||||||
|
- [triton-terraform](https://github.com/joyent/triton-terraform)
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
After creating a client, you can manipulate resources in the following ways:
|
||||||
|
|
||||||
|
| Resource | Create | Read | Update | Delete | Extra |
|
||||||
|
|----------|--------|------|--------|--------|-------|
|
||||||
|
| Datacenters | | [GetDatacenter](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetDatacenter), [ListDatacenters](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListDatacenters) | | | |
|
||||||
|
| Firewall Rules | [CreateFirewallRule](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.CreateFirewallRule) | [GetFirewallRule](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetFirewallRule), [ListFirewallRules](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListFirewallRules), [ListmachineFirewallRules](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListMachineFirewallRules) | [UpdateFirewallRule](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.UpdateFirewallRule), [EnableFirewallRule](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.EnableFirewallRule), [DisableFirewallRule](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DisableFirewallRule) | [DeleteFirewallRule](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DeleteFirewallRule) | |
|
||||||
|
| Instrumentations | [CreateInstrumentation](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.CreateInstrumentation) | [GetInstrumentation](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetInstrumentation), [ListInstrumentations](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListInstrumentations), [GetInstrumentationHeatmap](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetInstrumentationHeatmap), [GetInstrumentationHeatmapDetails](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetInstrumentationHeatmapDetails), [GetInstrumentationValue](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetInstrumentationValue) | | [DeleteInstrumentation](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DeleteInstrumentation) | [DescribeAnalytics](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DescribeAnalytics) |
|
||||||
|
| Keys | [CreateKey](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.CreateKey) | [GetKey](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetKey), [ListKeys](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListKeys) | | [DeleteKey](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DeleteKey) | |
|
||||||
|
| Machines | [CreateMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.CreateMachine) | [GetMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetMachine), [ListMachines](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListMachines), [ListFirewallRuleMachines](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListFirewallRuleMachines) | [RenameMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.RenameMachine), [ResizeMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ResizeMachine) | [DeleteMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DeleteMachine) | [CountMachines](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.CountMachines), [MachineAudit](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.MachineAudit), [StartMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.StartMachine), [StartMachineFromSnapshot](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.StartMachineFromSnapshot), [StopMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.StopMachine), [RebootMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.RebootMachine) |
|
||||||
|
| Machine (Images) | [CreateImageFromMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.CreateImageFromMachine) | [GetImage](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetImage), [ListImages](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListImages) | | [DeleteImage](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DeleteImage) | [ExportImage](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ExportImage) |
|
||||||
|
| Machine (Metadata) | | [GetMachineMetadata](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetMachineMetadata) | [UpdateMachineMetadata](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.UpdateMachineMetadata) | [DeleteMachineMetadata](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DeleteMachineMetadata), [DeleteAllMachineMetadata](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DeleteAllMachineMetadata) | |
|
||||||
|
| Machine (Snapshots) | [CreateMachineSnapshot](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.CreateMachineSnapshot) | [GetMachineSnapshot](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetMachineSnapshot), [ListMachineSnapshots](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListMachineSnapshots) | | [DeleteMachineSnapshot](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DeleteMachineSnapshot) | |
|
||||||
|
| Machine (Tags) | | [GetMachineTag](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetMachineTag), [ListMachineTags](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListMachineTags) | [AddMachineTags](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.AddMachineTags), [ReplaceMachineTags](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ReplaceMachineTags) | [DeleteMachineTag](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DeleteMachineTag), [DeleteMachineTags](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DeleteMachineTags) | [EnableFirewallMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.EnableFirewallMachine), [DisableFirewallMachine](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.DisableFirewallMachine) |
|
||||||
|
| Networks | | [GetNetwork](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetNetwork), [ListNetworks](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListNetworks) | | | |
|
||||||
|
| Packages | | [GetPackage](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.GetPackage), [ListPackages](https://godoc.org/github.com/joyent/gosdc/cloudapi#Client.ListPackages) | | | |
|
||||||
|
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Report bugs and request features using [GitHub Issues](https://github.com/joyent/gosdc/issues), or contribute code via a [GitHub Pull Request](https://github.com/joyent/gosdc/pulls). Changes will be code reviewed before merging. In the near future, automated tests will be run, but in the meantime please `go fmt`, `go lint`, and test all contributions.
|
||||||
|
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
This library assumes a Go development environment setup based on [How to Write Go Code](https://golang.org/doc/code.html). Your GOPATH environment variable should be pointed at your workspace directory.
|
||||||
|
|
||||||
|
You can now use `go get github.com/joyent/gosdc` to install the repository to the correct location, but if you are intending on contributing back a change you may want to consider cloning the repository via git yourself. This way you can have a single source tree for all Joyent Go projects with each repo having two remotes -- your own fork on GitHub and the upstream origin.
|
||||||
|
|
||||||
|
For example if your GOPATH is `~/src/joyent/go` and you're working on multiple repos then that directory tree might look like:
|
||||||
|
|
||||||
|
```
|
||||||
|
~/src/joyent/go/
|
||||||
|
|_ pkg/
|
||||||
|
|_ src/
|
||||||
|
|_ github.com
|
||||||
|
|_ joyent
|
||||||
|
|_ gocommon
|
||||||
|
|_ gomanta
|
||||||
|
|_ gosdc
|
||||||
|
|_ gosign
|
||||||
|
```
|
||||||
|
|
||||||
|
### Recommended Setup
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir -p ${GOPATH}/src/github.com/joyent
|
||||||
|
$ cd ${GOPATH}/src/github.com/joyent
|
||||||
|
$ git clone git@github.com:<yourname>/gosdc.git
|
||||||
|
|
||||||
|
# fetch dependencies
|
||||||
|
$ git clone git@github.com:<yourname>/gocommon.git
|
||||||
|
$ git clone git@github.com:<yourname>/gosign.git
|
||||||
|
$ go get -v -t ./...
|
||||||
|
|
||||||
|
# add upstream remote
|
||||||
|
$ cd gosdc
|
||||||
|
$ git remote add upstream git@github.com:joyent/gosdc.git
|
||||||
|
$ git remote -v
|
||||||
|
origin git@github.com:<yourname>/gosdc.git (fetch)
|
||||||
|
origin git@github.com:<yourname>/gosdc.git (push)
|
||||||
|
upstream git@github.com:joyent/gosdc.git (fetch)
|
||||||
|
upstream git@github.com:joyent/gosdc.git (push)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Tests
|
||||||
|
|
||||||
|
You can run the tests either locally or against live Triton. If you want to run the tests locally you'll want to generate an SSH key and pass the appropriate flags to the test harness as shown below.
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ${GOPATH}/src/github.com/joyent/gosdc
|
||||||
|
ssh-keygen -b 2048 -C "Testing Key" -f test_key.id_rsa -t rsa -P ""
|
||||||
|
env KEY_NAME=`pwd`/test_key.id_rsa LIVE=false go test ./...
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build the Library
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ${GOPATH}/src/github.com/joyent/gosdc
|
||||||
|
go build ./...
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
gosdc is licensed under the Mozilla Public License Version 2.0, a copy of which
|
||||||
|
is available at [LICENSE](LICENSE)
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
Package gosdc enables Go programs to interact with the Joyent CloudAPI.
|
||||||
|
|
||||||
|
The gosdc package is structured as follow:
|
||||||
|
|
||||||
|
- gosdc/cloudapi. This package interacts with the Cloud API (http://apidocs.joyent.com/cloudapi/).
|
||||||
|
- gosdc/localservices. This package provides local services to be used for testing.
|
||||||
|
|
||||||
|
Licensed under the Mozilla Public License version 2.0
|
||||||
|
|
||||||
|
Copyright (c) Joyent Inc.
|
||||||
|
|
||||||
|
*/
|
||||||
|
package gosdc
|
|
@ -0,0 +1,46 @@
|
||||||
|
box: golang
|
||||||
|
|
||||||
|
# services:
|
||||||
|
# - postgres
|
||||||
|
# http://devcenter.wercker.com/docs/services/postgresql.html
|
||||||
|
|
||||||
|
# - mongodb
|
||||||
|
# http://devcenter.wercker.com/docs/services/mongodb.html
|
||||||
|
|
||||||
|
build:
|
||||||
|
# The steps that will be executed on build
|
||||||
|
# Steps make up the actions in your pipeline
|
||||||
|
# Read more about steps on our dev center:
|
||||||
|
# http://devcenter.wercker.com/docs/steps/index.html
|
||||||
|
steps:
|
||||||
|
# Sets the go workspace and places you package
|
||||||
|
# at the right place in the workspace tree
|
||||||
|
- setup-go-workspace:
|
||||||
|
package-dir: github.com/joyent/gosdc
|
||||||
|
|
||||||
|
# Gets the dependencies
|
||||||
|
- script:
|
||||||
|
name: go get
|
||||||
|
code: |
|
||||||
|
go get -v -t ./...
|
||||||
|
|
||||||
|
- script:
|
||||||
|
name: make a new key for testing
|
||||||
|
code: |
|
||||||
|
ssh-keygen -b 2048 \
|
||||||
|
-C "Testing Key" \
|
||||||
|
-f $WERCKER_SOURCE_DIR/test_key.id_rsa \
|
||||||
|
-t rsa \
|
||||||
|
-P ""
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
- script:
|
||||||
|
name: go build
|
||||||
|
code: |
|
||||||
|
go build ./...
|
||||||
|
|
||||||
|
# Test the project
|
||||||
|
- script:
|
||||||
|
name: go test
|
||||||
|
code: |
|
||||||
|
env KEY_NAME=$WERCKER_SOURCE_DIR/test_key.id_rsa LIVE=false go test ./...
|
|
@ -0,0 +1,73 @@
|
||||||
|
gosign
|
||||||
|
======
|
||||||
|
|
||||||
|
Go HTTP signing library for Joyent's Triton and Manta.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Use `go-get` to install gosign
|
||||||
|
```
|
||||||
|
go get github.com/joyent/gosign
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Documentation can be found on godoc.
|
||||||
|
|
||||||
|
- [github.com/joyent/gosign](http://godoc.org/github.com/joyent/gosign)
|
||||||
|
- [github.com/joyent/gosign/auth](http://godoc.org/github.com/joyent/gosign/auth)
|
||||||
|
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Report bugs and request features using [GitHub Issues](https://github.com/joyent/gosign/issues), or contribute code via a [GitHub Pull Request](https://github.com/joyent/gosign/pulls). Changes will be code reviewed before merging. In the near future, automated tests will be run, but in the meantime please `go fmt`, `go lint`, and test all contributions.
|
||||||
|
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
This library assumes a Go development environment setup based on [How to Write Go Code](https://golang.org/doc/code.html). Your GOPATH environment variable should be pointed at your workspace directory.
|
||||||
|
|
||||||
|
You can now use `go get github.com/joyent/gosign` to install the repository to the correct location, but if you are intending on contributing back a change you may want to consider cloning the repository via git yourself. This way you can have a single source tree for all Joyent Go projects with each repo having two remotes -- your own fork on GitHub and the upstream origin.
|
||||||
|
|
||||||
|
For example if your GOPATH is `~/src/joyent/go` and you're working on multiple repos then that directory tree might look like:
|
||||||
|
|
||||||
|
```
|
||||||
|
~/src/joyent/go/
|
||||||
|
|_ pkg/
|
||||||
|
|_ src/
|
||||||
|
|_ github.com
|
||||||
|
|_ joyent
|
||||||
|
|_ gocommon
|
||||||
|
|_ gomanta
|
||||||
|
|_ gosdc
|
||||||
|
|_ gosign
|
||||||
|
```
|
||||||
|
|
||||||
|
### Recommended Setup
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir -p ${GOPATH}/src/github.com/joyent
|
||||||
|
$ cd ${GOPATH}/src/github.com/joyent
|
||||||
|
$ git clone git@github.com:<yourname>/gosign.git
|
||||||
|
$ cd gosign
|
||||||
|
$ git remote add upstream git@github.com:joyent/gosign.git
|
||||||
|
$ git remote -v
|
||||||
|
origin git@github.com:<yourname>/gosign.git (fetch)
|
||||||
|
origin git@github.com:<yourname>/gosign.git (push)
|
||||||
|
upstream git@github.com:joyent/gosign.git (fetch)
|
||||||
|
upstream git@github.com:joyent/gosign.git (push)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run Tests
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ${GOPATH}/src/github.com/joyent/gosign
|
||||||
|
go test ./...
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build the Library
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ${GOPATH}/src/github.com/joyent/gosign
|
||||||
|
go build ./...
|
||||||
|
```
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* The sign package enables Go programs to create signed requests for
|
||||||
|
* the Joyent Public Cloud and Joyent Manta services.
|
||||||
|
*
|
||||||
|
* The sign package is structured as follow:
|
||||||
|
*
|
||||||
|
* - gosign/auth. This package deals with the authorization and signature of requests.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 Joyent Inc.
|
||||||
|
* Written by Daniele Stroppa <daniele.stroppa@joyent.com>
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
package gosign
|
|
@ -512,6 +512,21 @@
|
||||||
"path": "github.com/jmespath/go-jmespath",
|
"path": "github.com/jmespath/go-jmespath",
|
||||||
"revision": "c01cf91b011868172fdcd9f41838e80c9d716264"
|
"revision": "c01cf91b011868172fdcd9f41838e80c9d716264"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "NOwNdnb70M6s9LvhaPFabBVwlBs=",
|
||||||
|
"path": "github.com/joyent/gocommon",
|
||||||
|
"revision": "b78708995d1c2ebdb64a3061b0bca5d8ccdf0fc2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "zg/V3yqR59RlBEhTqjW7AhEp16o=",
|
||||||
|
"path": "github.com/joyent/gosdc",
|
||||||
|
"revision": "ec8b3503a75edca0df26581b83807677b0240716"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"checksumSHA1": "xVAU7r1t8lxJ1AHvgNNXxwU+jIo=",
|
||||||
|
"path": "github.com/joyent/gosign",
|
||||||
|
"revision": "9abcee278795b82b36858cdfc857c8a0e7de797c"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "6nmAJBw2phU9MUmkUnqFvbO5urg=",
|
"checksumSHA1": "6nmAJBw2phU9MUmkUnqFvbO5urg=",
|
||||||
"path": "github.com/kardianos/osext",
|
"path": "github.com/kardianos/osext",
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
---
|
||||||
|
description: |
|
||||||
|
The `triton` Packer builder is able to create new images for use with Triton. These images can be used with both the Joyent public cloud (which is powered by Triton) as well with private Triton installations. This builder uses the Triton Cloud API to create images. The builder creates and launches a temporary VM based on a specified source image, runs any provisioning necessary, uses the Triton "VM to image" functionality to create a reusable image and finally destroys the temporary VM. This reusable image can then be used to launch new VM's.
|
||||||
|
page_title: Triton Builder
|
||||||
|
...
|
||||||
|
|
||||||
|
# Triton Builder
|
||||||
|
|
||||||
|
Type: `triton`
|
||||||
|
|
||||||
|
The `triton` Packer builder is able to create new images for use with Triton. These images can be used with both the [Joyent public cloud](https://www.joyent.com/) (which is powered by Triton) as well with private [Triton](https://github.com/joyent/triton) installations. This builder uses the Triton Cloud API to create images. The builder creates and launches a temporary VM based on a specified source image, runs any provisioning necessary, uses the Triton "VM to image" functionality to create a reusable image and finally destroys the temporary VM. This reusable image can then be used to launch new VM's.
|
||||||
|
|
||||||
|
The builder does *not* manage images. Once it creates an image, it is up to you to use it or delete it.
|
||||||
|
|
||||||
|
## Configuration Reference
|
||||||
|
|
||||||
|
There are many configuration options available for the builder. They are segmented below into two categories: required and optional parameters.
|
||||||
|
|
||||||
|
In addition to the options listed here, a [communicator](/docs/templates/communicator.html) can be configured for this builder.
|
||||||
|
|
||||||
|
### Required:
|
||||||
|
|
||||||
|
- `triton_account` (string) - The username of the Triton account to use when using the Triton Cloud API.
|
||||||
|
- `triton_key_id` (string) - The fingerprint of the public key of the SSH key pair to use for authentication against Triton.
|
||||||
|
- `triton_key_material` (string) - The path to the private key of the SSH key pair associated with the Triton account to be used. For example `~/.ssh/id_rsa`.
|
||||||
|
|
||||||
|
- `source_machine_image` (string) - The UUID of the image to base the new image on. On the Joyent public cloud this could for example be `70e3ae72-96b6-11e6-9056-9737fd4d0764` for version 16.3.1 of the 64bit SmartOS base image.
|
||||||
|
- `source_machine_name` (string) - Name of the VM used for building the image. Does not affect (and does not have to be the same) as the name for a VM instance running this image. Maximum 512 characters but should in practice be much shorter (think between 5 and 20 characters). For example `mysql-64-server-image-builder`.
|
||||||
|
- `source_machine_package` (string) - The Triton package to use while building the image. Does not affect (and does not have to be the same) as the package which will be used for a VM instance running this image. On the Joyent public cloud this could for example be `g3-standard-0.5-smartos`.
|
||||||
|
|
||||||
|
- `image_name` (string) - The name the finished image in Triton will be assigned. Maximum 512 characters but should in practice be much shorter (think between 5 and 20 characters). For example `postgresql-95-server` for an image used as a PostgreSQL 9.5 server.
|
||||||
|
- `image_version` (string) - The version string for this image. Maximum 128 characters. Any string will do but a format of `Major.Minor.Patch` is strongly advised by Joyent. See [Semantic Versioning](http://semver.org/) for more information on the `Major.Minor.Patch` versioning format.
|
||||||
|
|
||||||
|
### Optional:
|
||||||
|
|
||||||
|
- `triton_url` (string) - The URL of the Triton cloud API to use. If omitted it will default to the URL of the Joyent Public cloud. If you are using your own private Triton installation you will have to supply the URL of the cloud API of your own Triton installation.
|
||||||
|
|
||||||
|
- `source_machine_firewall_enabled` (boolean) - Whether or not the firewall of the VM used to create an image of is enabled. The Triton firewall only filters inbound traffic to the VM. For the Joyent public cloud and private Triton installations SSH traffic is always allowed by default. All outbound traffic is always allowed. Currently this builder does not provide an interface to add specific firewall rules. The default is `false`.
|
||||||
|
- `source_machine_metadata` (object of key/value strings) - Triton metadata applied to the VM used to create the image. Metadata can be used to pass configuration information to the VM without the need for networking. See [Using the metadata API](https://docs.joyent.com/private-cloud/instances/using-mdata) in the Joyent documentation for more information. This can for example be used to set the `user-script` metadata key to have Triton start a user supplied script after the VM has booted.
|
||||||
|
- `source_machine_networks` (array of strings) - The UUID's of Triton networks added to the source machine used for creating the image. For example if any of the provisioners which are run need Internet access you will need to add the UUID's of the appropriate networks here.
|
||||||
|
- `source_machine_tags` (object of key/value strings) - Tags applied to the VM used to create the image.
|
||||||
|
|
||||||
|
- `image_acls` (array of strings) - The UUID's of the users which will have access to this image. When omitted only the owner (the Triton user whose credentials are used) will have access to the image.
|
||||||
|
- `image_description` (string) - Description of the image. Maximum 512 characters.
|
||||||
|
- `image_eula_url` (string) - URL of the End User License Agreement (EULA) for the image. Maximum 128 characters.
|
||||||
|
- `image_homepage` (string) - URL of the homepage where users can find information about the image. Maximum 128 characters.
|
||||||
|
- `image_tags` (object of key/value strings) - Tag applied to the image.
|
||||||
|
|
||||||
|
## Basic Example
|
||||||
|
|
||||||
|
Below is a minimal example to create an image on the Joyent public cloud:
|
||||||
|
|
||||||
|
``` {.javascript}
|
||||||
|
"builders": [{
|
||||||
|
"type": "triton",
|
||||||
|
"triton_account": "triton_username",
|
||||||
|
"triton_key_id": "6b:95:03:3d:d3:6e:52:69:01:96:1a:46:4a:8d:c1:7e",
|
||||||
|
"triton_key_material": "${file("~/.ssh/id_rsa")}",
|
||||||
|
"source_machine_name": "image-builder",
|
||||||
|
"source_machine_package": "g3-standard-0.5-smartos",
|
||||||
|
"source_machine_image": "70e3ae72-96b6-11e6-9056-9737fd4d0764",
|
||||||
|
"image_name": "my_new_image",
|
||||||
|
"image_version": "1.0.0",
|
||||||
|
}],
|
||||||
|
```
|
Loading…
Reference in New Issue