Marques Johansson 99987c2d56 Add Linode Images builder
Packer Builder for [Linode Images](https://www.linode.com/docs/platform/disk-images/linode-images/)

Adds the following builder:

  * `linode`

Based on https://github.com/linode/packer-builder-linode (MPL/2)
(formerly maintained by @dradtke).  Includes website docs and tests.

Relates to #174, #3131
2019-04-15 20:40:59 -04:00

31 lines
645 B
Go

package linode
import (
"fmt"
"net/http"
"github.com/hashicorp/packer/version"
"github.com/linode/linodego"
"golang.org/x/oauth2"
)
func newLinodeClient(pat string) linodego.Client {
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: pat})
oauthTransport := &oauth2.Transport{
Source: tokenSource,
}
oauth2Client := &http.Client{
Transport: oauthTransport,
}
client := linodego.NewClient(oauth2Client)
projectURL := "https://www.packer.io"
userAgent := fmt.Sprintf("Packer/%s (+%s) linodego/%s",
version.FormattedVersion(), projectURL, linodego.Version)
client.SetUserAgent(userAgent)
return client
}