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

Release v1.2.0 #156

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@65c5fb495d1e69aa8c08a3317bc44ff8aabe9772 # pin@v5
- uses: release-drafter/release-drafter@09c613e259eb8d4e7c81c2cb00618eb5fc4575a7 # pin@v5
with:
config-name: release-drafter.yml
env:
Expand Down
16 changes: 10 additions & 6 deletions builder/linode/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,21 +469,25 @@ func TestBuilderPrepare_NetworkInterfaces(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}

subnetID := 12345

expectedInterfaces := []Interface{
{
Purpose: "public",
Label: "",
IPAMAddress: "",
Purpose: "public",
Primary: true,
},
{
Purpose: "vlan",
Label: "vlan-1",
IPAMAddress: "10.0.0.1/24",
},
{
Purpose: "vlan",
Label: "vlan-2",
IPAMAddress: "10.0.0.2/24",
Purpose: "vpc",
SubnetID: &subnetID,
IPv4: &InterfaceIPv4{
VPC: "10.0.0.2",
NAT1To1: "any",
},
},
}

Expand Down
16 changes: 12 additions & 4 deletions builder/linode/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate packer-sdc mapstructure-to-hcl2 -type Config,Interface
//go:generate packer-sdc mapstructure-to-hcl2 -type Config,Interface,InterfaceIPv4

package linode

Expand All @@ -18,10 +18,18 @@ import (
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
)

type InterfaceIPv4 struct {
VPC string `mapstructure:"vpc"`
NAT1To1 string `mapstructure:"nat_1_1"`
}

type Interface struct {
Purpose string `mapstructure:"purpose"`
Label string `mapstructure:"label"`
IPAMAddress string `mapstructure:"ipam_address"`
Purpose string `mapstructure:"purpose"`
Label string `mapstructure:"label"`
IPAMAddress string `mapstructure:"ipam_address"`
Primary bool `mapstructure:"primary"`
SubnetID *int `mapstructure:"subnet_id"`
IPv4 *InterfaceIPv4 `mapstructure:"ipv4"`
}

type Config struct {
Expand Down
37 changes: 34 additions & 3 deletions builder/linode/config.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions builder/linode/step_create_linode.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@ type stepCreateLinode struct {
client linodego.Client
}

func flattenConfigInterface(i Interface) linodego.InstanceConfigInterface {
return linodego.InstanceConfigInterface{
func flattenConfigInterfaceIPv4(i *InterfaceIPv4) *linodego.VPCIPv4 {
if i == nil {
return nil
}

return &linodego.VPCIPv4{
VPC: i.VPC,
NAT1To1: i.NAT1To1,
}
}

func flattenConfigInterface(i Interface) linodego.InstanceConfigInterfaceCreateOptions {
return linodego.InstanceConfigInterfaceCreateOptions{
IPAMAddress: i.IPAMAddress,
Label: i.Label,
Purpose: linodego.ConfigInterfacePurpose(i.Purpose),
Primary: i.Primary,
SubnetID: i.SubnetID,
IPv4: flattenConfigInterfaceIPv4(i.IPv4),
}
}

Expand All @@ -31,7 +45,7 @@ func (s *stepCreateLinode) Run(ctx context.Context, state multistep.StateBag) mu

ui.Say("Creating Linode...")

interfaces := make([]linodego.InstanceConfigInterface, len(c.Interfaces))
interfaces := make([]linodego.InstanceConfigInterfaceCreateOptions, len(c.Interfaces))
for i, v := range c.Interfaces {
interfaces[i] = flattenConfigInterface(v)
}
Expand Down
3 changes: 1 addition & 2 deletions builder/linode/step_create_ssh_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"os"

"github.com/hashicorp/packer-plugin-sdk/multistep"
Expand All @@ -33,7 +32,7 @@ func (s *StepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) mult

if config.Comm.SSHPrivateKeyFile != "" {
ui.Say("Using existing SSH private key")
privateKeyBytes, err := ioutil.ReadFile(config.Comm.SSHPrivateKeyFile)
privateKeyBytes, err := os.ReadFile(config.Comm.SSHPrivateKeyFile)
if err != nil {
return handleError("Error loading configured private key file", err)
}
Expand Down
43 changes: 31 additions & 12 deletions docs/builders/linode.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ can also be supplied to override the typical auto-generated key:

- `swap_size` (int) - The disk size (MiB) allocated for swap space.

- `interface` ([]{purpose string, label string, ipam_address string}) - Network Interfaces
- `interface` ([](Interface)[#interface]) - Network Interfaces
to add to this Linode’s Configuration Profile. Singular repeatable block containing a `purpose`,
a `label`, and an `ipam_address` field.

Expand All @@ -120,6 +120,30 @@ can also be supplied to override the typical auto-generated key:
Please note that when you create a new Linode instance with a private image, you will
be required to setup a new root password.

#### Interface

This section outlines the fields configurable for a single interface object.

- `purpose` (string) - The purpose of this interface. (public, vlan, vpc)

- `primary` (bool) - Whether this interface is a primary interface.

VLAN-specific fields:

- `label` (string) - The label of the VLAN this interface relates to.

- `ipam_address` (string) - This Network Interface’s private IP address in CIDR notation.

VPC-specific fields:

- `subnet_id` (int) - The ID of the VPC Subnet this interface references.

- `ipv4` (block) - The IPv4 configuration of this VPC interface.

- `vpc` (string) - The IPv4 address from the VPC subnet to use for this interface.

- `nat_1_1` (string) - The public IPv4 address assigned to this Linode to be 1:1 NATed with the VPC IPv4 address.

## Examples

### Basic Example
Expand Down Expand Up @@ -212,20 +236,15 @@ source "linode" "example" {
interface {
purpose = "public"
label = ""
ipam_address = ""
}
interface {
purpose = "vlan"
label = "vlan-1"
ipam_address = "10.0.0.1/24"
}
interface {
purpose = "vlan"
label = "vlan-2"
ipam_address = "10.0.0.2/24"
purpose = "vpc"
subnet_id = 123
ipv4 {
vpc = "10.0.0.2"
nat_1_1 = "any"
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/hashicorp/hcl/v2 v2.16.2
github.com/hashicorp/packer-plugin-sdk v0.5.1
github.com/linode/linodego v1.23.0
github.com/linode/linodego v1.25.0
github.com/zclconf/go-cty v1.12.1
golang.org/x/crypto v0.14.0
golang.org/x/oauth2 v0.13.0
Expand All @@ -29,13 +29,13 @@ require (
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/dylanmei/iso8601 v0.1.0 // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/go-resty/resty/v2 v2.10.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
Expand Down Expand Up @@ -82,11 +82,11 @@ require (
github.com/ugorji/go/codec v1.2.6 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/net v0.16.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.126.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
Loading