Skip to content

Commit

Permalink
Merge pull request #277 from flatcar-linux/tormath1/bye-packet
Browse files Browse the repository at this point in the history
*: rename `packet` to `equinixmetal`
  • Loading branch information
tormath1 authored Jan 21, 2022
2 parents 646844a + bbbe9e9 commit 2e8c1c8
Show file tree
Hide file tree
Showing 20 changed files with 206 additions and 183 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- kubernetes test for release 1.23.0 ([#275](https://github.com/flatcar-linux/mantle/pull/275))
- arm64 kubeadm test for `calico` CNI ([#278](https://github.com/flatcar-linux/mantle/pull/278))

### Changed
- removed `packet` occurrences in favor of `equinixmetal` ([#277](https://github.com/flatcar-linux/mantle/pull/277))

## [0.18.0] - 12/01/2022
### Security
- go: Update golang.org/x/{text,crypto} ([#262](https://github.com/flatcar-linux/mantle/pull/262))
Expand Down
18 changes: 9 additions & 9 deletions auth/packet.go → auth/equinixmetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ import (
"path/filepath"
)

const PacketConfigPath = ".config/packet.json"
const EquinixMetalConfigPath = ".config/equinixmetal.json"

// PacketProfile represents a parsed Packet profile. This is a custom format
// EquinixMetalProfile represents a parsed EquinixMetal profile. This is a custom format
// specific to Mantle.
type PacketProfile struct {
type EquinixMetalProfile struct {
ApiKey string `json:"api_key"`
Project string `json:"project"`
}

// ReadPacketConfig decodes a Packet config file, which is a custom format
// ReadEquinixMetalConfig decodes a EquinixMetal config file, which is a custom format
// used by Mantle to hold API keys.
//
// If path is empty, $HOME/.config/packet.json is read.
func ReadPacketConfig(path string) (map[string]PacketProfile, error) {
// If path is empty, $HOME/.config/equinixmetal.json is read.
func ReadEquinixMetalConfig(path string) (map[string]EquinixMetalProfile, error) {
if path == "" {
user, err := user.Current()
if err != nil {
return nil, err
}
path = filepath.Join(user.HomeDir, PacketConfigPath)
path = filepath.Join(user.HomeDir, EquinixMetalConfigPath)
}

f, err := os.Open(path)
Expand All @@ -50,12 +50,12 @@ func ReadPacketConfig(path string) (map[string]PacketProfile, error) {
}
defer f.Close()

var profiles map[string]PacketProfile
var profiles map[string]EquinixMetalProfile
if err := json.NewDecoder(f).Decode(&profiles); err != nil {
return nil, err
}
if len(profiles) == 0 {
return nil, fmt.Errorf("Packet config %q contains no profiles", path)
return nil, fmt.Errorf("EquinixMetal config %q contains no profiles", path)
}

return profiles, nil
Expand Down
42 changes: 21 additions & 21 deletions cmd/kola/kola.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func preRun(cmd *cobra.Command, args []string) {
os.Exit(3)
}

// Packet uses storage, and storage talks too much.
// EquinixMetal uses storage, and storage talks too much.
if !plog.LevelAt(capnslog.INFO) {
mantleLogger := capnslog.MustRepoLogger("github.com/flatcar-linux/mantle")
mantleLogger.SetLogLevel(map[string]capnslog.LogLevel{
Expand Down Expand Up @@ -188,7 +188,7 @@ func writeProps() error {
Image string `json:"image"`
Flavor string `json:"flavor"`
}
type Packet struct {
type EquinixMetal struct {
Facility string `json:"facility"`
Plan string `json:"plan"`
InstallerImageBaseURL string `json:"installer"`
Expand All @@ -199,20 +199,20 @@ func writeProps() error {
Mangled bool `json:"mangled"`
}
return enc.Encode(&struct {
Cmdline []string `json:"cmdline"`
Platform string `json:"platform"`
Distro string `json:"distro"`
IgnitionVersion string `json:"ignitionversion"`
Board string `json:"board"`
OSContainer string `json:"oscontainer"`
AWS AWS `json:"aws"`
Azure Azure `json:"azure"`
DO DO `json:"do"`
ESX ESX `json:"esx"`
GCE GCE `json:"gce"`
OpenStack OpenStack `json:"openstack"`
Packet Packet `json:"packet"`
QEMU QEMU `json:"qemu"`
Cmdline []string `json:"cmdline"`
Platform string `json:"platform"`
Distro string `json:"distro"`
IgnitionVersion string `json:"ignitionversion"`
Board string `json:"board"`
OSContainer string `json:"oscontainer"`
AWS AWS `json:"aws"`
Azure Azure `json:"azure"`
DO DO `json:"do"`
ESX ESX `json:"esx"`
GCE GCE `json:"gce"`
OpenStack OpenStack `json:"openstack"`
EquinixMetal EquinixMetal `json:"equinixmetal"`
QEMU QEMU `json:"qemu"`
}{
Cmdline: os.Args,
Platform: kolaPlatform,
Expand Down Expand Up @@ -254,11 +254,11 @@ func writeProps() error {
Image: kola.OpenStackOptions.Image,
Flavor: kola.OpenStackOptions.Flavor,
},
Packet: Packet{
Facility: kola.PacketOptions.Facility,
Plan: kola.PacketOptions.Plan,
InstallerImageBaseURL: kola.PacketOptions.InstallerImageBaseURL,
ImageURL: kola.PacketOptions.ImageURL,
EquinixMetal: EquinixMetal{
Facility: kola.EquinixMetalOptions.Facility,
Plan: kola.EquinixMetalOptions.Plan,
InstallerImageBaseURL: kola.EquinixMetalOptions.InstallerImageBaseURL,
ImageURL: kola.EquinixMetalOptions.ImageURL,
},
QEMU: QEMU{
Image: kola.QEMUOptions.DiskImage,
Expand Down
59 changes: 44 additions & 15 deletions cmd/kola/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
kolaOffering string
defaultTargetBoard = sdk.DefaultBoard()
kolaArchitectures = []string{"amd64"}
kolaPlatforms = []string{"aws", "azure", "do", "esx", "external", "gce", "openstack", "packet", "qemu", "qemu-unpriv"}
kolaPlatforms = []string{"aws", "azure", "do", "esx", "external", "gce", "openstack", "equinixmetal", "qemu", "qemu-unpriv"}
kolaDistros = []string{"cl", "fcos", "rhcos"}
kolaChannels = []string{"alpha", "beta", "stable", "edge", "lts"}
kolaOfferings = []string{"basic", "pro"}
Expand Down Expand Up @@ -159,18 +159,42 @@ func init() {
sv(&kola.OpenStackOptions.Domain, "openstack-domain", "", "OpenStack domain ID")
sv(&kola.OpenStackOptions.FloatingIPPool, "openstack-floating-ip-pool", "", "OpenStack floating IP pool for Compute v2 networking")

// packet-specific options
sv(&kola.PacketOptions.ConfigPath, "packet-config-file", "", "Packet config file (default \"~/"+auth.PacketConfigPath+"\")")
sv(&kola.PacketOptions.Profile, "packet-profile", "", "Packet profile (default \"default\")")
sv(&kola.PacketOptions.ApiKey, "packet-api-key", "", "Packet API key (overrides config file)")
sv(&kola.PacketOptions.Project, "packet-project", "", "Packet project UUID (overrides config file)")
sv(&kola.PacketOptions.Facility, "packet-facility", "sv15", "Packet facility code")
sv(&kola.PacketOptions.Plan, "packet-plan", "c3.small.x86", "Packet plan slug (default board-dependent, e.g. \"baremetal_0\")")
sv(&kola.PacketOptions.InstallerImageBaseURL, "packet-installer-image-base-url", "", "Packet installer image base URL, non-https (default board-dependent, e.g. \"http://stable.release.flatcar-linux.net/amd64-usr/current\")")
sv(&kola.PacketOptions.InstallerImageKernelURL, "packet-installer-image-kernel-url", "", "Packet installer image kernel URL, (default packet-installer-image-base-url/flatcar_production_pxe.vmlinuz)")
sv(&kola.PacketOptions.InstallerImageCpioURL, "packet-installer-image-cpio-url", "", "Packet installer image cpio URL, (default packet-installer-image-base-url/flatcar_production_pxe_image.cpio.gz)")
sv(&kola.PacketOptions.ImageURL, "packet-image-url", "", "Packet image URL (default board-dependent, e.g. \"https://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_production_packet_image.bin.bz2\")")
sv(&kola.PacketOptions.StorageURL, "packet-storage-url", "gs://users.developer.core-os.net/"+os.Getenv("USER")+"/mantle", "Google Storage base URL for temporary uploads")
// packet-specific options (kept for compatiblity but marked as deprecated)
sv(&kola.EquinixMetalOptions.ConfigPath, "packet-config-file", "", "Packet config file (default \"~/"+auth.EquinixMetalConfigPath+"\")")
sv(&kola.EquinixMetalOptions.Profile, "packet-profile", "", "Packet profile (default \"default\")")
sv(&kola.EquinixMetalOptions.ApiKey, "packet-api-key", "", "Packet API key (overrides config file)")
sv(&kola.EquinixMetalOptions.Project, "packet-project", "", "Packet project UUID (overrides config file)")
sv(&kola.EquinixMetalOptions.Facility, "packet-facility", "sv15", "Packet facility code")
sv(&kola.EquinixMetalOptions.Plan, "packet-plan", "c3.small.x86", "Packet plan slug (default board-dependent, e.g. \"baremetal_0\")")
sv(&kola.EquinixMetalOptions.InstallerImageBaseURL, "packet-installer-image-base-url", "", "Packet installer image base URL, non-https (default board-dependent, e.g. \"http://stable.release.flatcar-linux.net/amd64-usr/current\")")
sv(&kola.EquinixMetalOptions.InstallerImageKernelURL, "packet-installer-image-kernel-url", "", "Packet installer image kernel URL, (default packet-installer-image-base-url/flatcar_production_pxe.vmlinuz)")
sv(&kola.EquinixMetalOptions.InstallerImageCpioURL, "packet-installer-image-cpio-url", "", "Packet installer image cpio URL, (default packet-installer-image-base-url/flatcar_production_pxe_image.cpio.gz)")
sv(&kola.EquinixMetalOptions.ImageURL, "packet-image-url", "", "Packet image URL (default board-dependent, e.g. \"https://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_production_packet_image.bin.bz2\")")
sv(&kola.EquinixMetalOptions.StorageURL, "packet-storage-url", "gs://users.developer.core-os.net/"+os.Getenv("USER")+"/mantle", "Google Storage base URL for temporary uploads")
root.PersistentFlags().MarkDeprecated("packet-config-file", "packet options are deprecated, please update to equinixmetal options")
root.PersistentFlags().MarkDeprecated("packet-profile", "packet options are deprecated, please update to equinixmetal options")
root.PersistentFlags().MarkDeprecated("packet-api-key", "packet options are deprecated, please update to equinixmetal options")
root.PersistentFlags().MarkDeprecated("packet-project", "packet options are deprecated, please update to equinixmetal options")
root.PersistentFlags().MarkDeprecated("packet-facility", "packet options are deprecated, please update to equinixmetal options")
root.PersistentFlags().MarkDeprecated("packet-plan", "packet options are deprecated, please update to equinixmetal options")
root.PersistentFlags().MarkDeprecated("packet-installer-image-base-url", "packet options are deprecated, please update to equinixmetal options")
root.PersistentFlags().MarkDeprecated("packet-installer-image-kernel-url", "packet options are deprecated, please update to equinixmetal options")
root.PersistentFlags().MarkDeprecated("packet-installer-image-cpio-url", "packet options are deprecated, please update to equinixmetal options")
root.PersistentFlags().MarkDeprecated("packet-image-url", "packet options are deprecated, please update to equinixmetal options")
root.PersistentFlags().MarkDeprecated("packet-storage-url", "packet options are deprecated, please update to equinixmetal options")

// equinixmetal-specific options
sv(&kola.EquinixMetalOptions.ConfigPath, "equinixmetal-config-file", "", "EquinixMetal config file (default \"~/"+auth.EquinixMetalConfigPath+"\")")
sv(&kola.EquinixMetalOptions.Profile, "equinixmetal-profile", "", "EquinixMetal profile (default \"default\")")
sv(&kola.EquinixMetalOptions.ApiKey, "equinixmetal-api-key", "", "EquinixMetal API key (overrides config file)")
sv(&kola.EquinixMetalOptions.Project, "equinixmetal-project", "", "EquinixMetal project UUID (overrides config file)")
sv(&kola.EquinixMetalOptions.Facility, "equinixmetal-facility", "sv15", "EquinixMetal facility code")
sv(&kola.EquinixMetalOptions.Plan, "equinixmetal-plan", "c3.small.x86", "EquinixMetal plan slug (default board-dependent, e.g. \"baremetal_0\")")
sv(&kola.EquinixMetalOptions.InstallerImageBaseURL, "equinixmetal-installer-image-base-url", "", "EquinixMetal installer image base URL, non-https (default board-dependent, e.g. \"http://stable.release.flatcar-linux.net/amd64-usr/current\")")
sv(&kola.EquinixMetalOptions.InstallerImageKernelURL, "equinixmetal-installer-image-kernel-url", "", "EquinixMetal installer image kernel URL, (default equinixmetal-installer-image-base-url/flatcar_production_pxe.vmlinuz)")
sv(&kola.EquinixMetalOptions.InstallerImageCpioURL, "equinixmetal-installer-image-cpio-url", "", "EquinixMetal installer image cpio URL, (default equinixmetal-installer-image-base-url/flatcar_production_pxe_image.cpio.gz)")
sv(&kola.EquinixMetalOptions.ImageURL, "equinixmetal-image-url", "", "EquinixMetal image URL (default board-dependent, e.g. \"https://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_production_packet_image.bin.bz2\")")
sv(&kola.EquinixMetalOptions.StorageURL, "equinixmetal-storage-url", "gs://users.developer.core-os.net/"+os.Getenv("USER")+"/mantle", "Google Storage base URL for temporary uploads")

// QEMU-specific options
sv(&kola.QEMUOptions.Board, "board", defaultTargetBoard, "target board")
Expand All @@ -193,8 +217,8 @@ func syncOptions() error {
kola.DOOptions.Board = board
kola.AzureOptions.Board = board
kola.AWSOptions.Board = board
kola.PacketOptions.Board = board
kola.PacketOptions.GSOptions = &kola.GCEOptions
kola.EquinixMetalOptions.Board = board
kola.EquinixMetalOptions.GSOptions = &kola.GCEOptions

validateOption := func(name, item string, valid []string) error {
for _, v := range valid {
Expand All @@ -205,6 +229,11 @@ func syncOptions() error {
return fmt.Errorf("unsupported %v %q", name, item)
}

if kolaPlatform == "packet" {
fmt.Println("packet platform is deprecated, updating to equinixmetal")
kolaPlatform = "equinixmetal"
}

if err := validateOption("platform", kolaPlatform, kolaPlatforms); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/ore/packet.go → cmd/ore/equinixmetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package main

import (
"github.com/flatcar-linux/mantle/cmd/ore/packet"
"github.com/flatcar-linux/mantle/cmd/ore/equinixmetal"
)

func init() {
root.AddCommand(packet.Packet)
root.AddCommand(equinixmetal.EquinixMetal)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package packet
package equinixmetal

import (
"encoding/json"
Expand All @@ -29,30 +29,30 @@ import (
var (
cmdCreateDevice = &cobra.Command{
Use: "create-device [options]",
Short: "Create Packet device",
Long: `Create a Packet device.`,
Short: "Create EquinixMetal device",
Long: `Create an EquinixMetal device.`,
RunE: runCreateDevice,
}
hostname string
userDataPath string
)

func init() {
Packet.AddCommand(cmdCreateDevice)
EquinixMetal.AddCommand(cmdCreateDevice)
cmdCreateDevice.Flags().StringVar(&options.Facility, "facility", "sjc1", "facility code")
cmdCreateDevice.Flags().StringVar(&options.Plan, "plan", "", "plan slug (default board-dependent, e.g. \"baremetal_0\")")
cmdCreateDevice.Flags().StringVar(&options.Board, "board", "amd64-usr", "Container Linux board")
cmdCreateDevice.Flags().StringVar(&options.InstallerImageBaseURL, "installer-image-base-url", "", "installer image base URL, non-https (default board-dependent, e.g. \"http://stable.release.flatcar-linux.net/amd64-usr/current\")")
cmdCreateDevice.Flags().StringVar(&options.InstallerImageKernelURL, "installer-image-kernel-url", "", "Packet installer image kernel URL, (default installer-image-base-url/flatcar_production_pxe.vmlinuz)")
cmdCreateDevice.Flags().StringVar(&options.InstallerImageCpioURL, "installer-image-cpio-url", "", "Packet installer image cpio URL, (default installer-image-base-url/flatcar_production_pxe_image.cpio.gz)")
cmdCreateDevice.Flags().StringVar(&options.InstallerImageKernelURL, "installer-image-kernel-url", "", "EquinixMetal installer image kernel URL, (default installer-image-base-url/flatcar_production_pxe.vmlinuz)")
cmdCreateDevice.Flags().StringVar(&options.InstallerImageCpioURL, "installer-image-cpio-url", "", "EquinixMetal installer image cpio URL, (default installer-image-base-url/flatcar_production_pxe_image.cpio.gz)")
cmdCreateDevice.Flags().StringVar(&options.ImageURL, "image-url", "", "image base URL (default board-dependent, e.g. \"https://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_production_packet_image.bin.bz2\")")
cmdCreateDevice.Flags().StringVar(&hostname, "hostname", "", "hostname to assign to device")
cmdCreateDevice.Flags().StringVar(&userDataPath, "userdata-file", "", "path to file containing userdata")
}

func runCreateDevice(cmd *cobra.Command, args []string) error {
if len(args) != 0 {
fmt.Fprintf(os.Stderr, "Unrecognized args in packet create-device cmd: %v\n", args)
fmt.Fprintf(os.Stderr, "Unrecognized args in equinixmetal create-device cmd: %v\n", args)
os.Exit(2)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package packet
package equinixmetal

import (
"fmt"
Expand All @@ -24,13 +24,13 @@ import (
var (
cmdDeleteKeys = &cobra.Command{
Use: "delete-keys <key>...",
Short: "Delete Packet SSH keys",
Short: "Delete EquinixMetal SSH keys",
RunE: runDeleteKeys,
}
)

func init() {
Packet.AddCommand(cmdDeleteKeys)
EquinixMetal.AddCommand(cmdDeleteKeys)
}

func runDeleteKeys(cmd *cobra.Command, args []string) error {
Expand Down
60 changes: 60 additions & 0 deletions cmd/ore/equinixmetal/equinixmetal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright The Mantle Authors
// Copyright 2017 CoreOS, Inc.
// SPDX-License-Identifier: Apache-2.0

package equinixmetal

import (
"fmt"
"os"

"github.com/coreos/pkg/capnslog"
"github.com/flatcar-linux/mantle/auth"
"github.com/flatcar-linux/mantle/cli"
"github.com/flatcar-linux/mantle/platform"
"github.com/flatcar-linux/mantle/platform/api/equinixmetal"
"github.com/flatcar-linux/mantle/platform/api/gcloud"
"github.com/spf13/cobra"
)

var (
plog = capnslog.NewPackageLogger("github.com/flatcar-linux/mantle", "ore/equinixmetal")

EquinixMetal = &cobra.Command{
Use: "equinixmetal [command]",
Aliases: []string{"packet"},
Short: "EquinixMetal machine utilities",
}

API *equinixmetal.API
options = equinixmetal.Options{Options: &platform.Options{}}
gsOptions gcloud.Options
)

func init() {
options.GSOptions = &gsOptions
EquinixMetal.PersistentFlags().StringVar(&options.StorageURL, "storage-url", "gs://users.developer.core-os.net/"+os.Getenv("USER")+"/mantle", "Google Storage base URL for temporary uploads")
EquinixMetal.PersistentFlags().StringVar(&gsOptions.JSONKeyFile, "gs-json-key", "", "use a Google service account's JSON key to authenticate to Google Storage")
EquinixMetal.PersistentFlags().BoolVar(&gsOptions.ServiceAuth, "gs-service-auth", false, "use non-interactive Google auth when running within GCE")
EquinixMetal.PersistentFlags().StringVar(&options.ConfigPath, "config-file", "", "config file (default \"~/"+auth.EquinixMetalConfigPath+"\")")
EquinixMetal.PersistentFlags().StringVar(&options.Profile, "profile", "", "profile (default \"default\")")
EquinixMetal.PersistentFlags().StringVar(&options.ApiKey, "api-key", "", "API key (overrides config file)")
EquinixMetal.PersistentFlags().StringVar(&options.Project, "project", "", "project UUID (overrides config file)")
cli.WrapPreRun(EquinixMetal, preflightCheck)

}

func preflightCheck(cmd *cobra.Command, args []string) error {
plog.Debugf("Running EquinixMetal preflight check")
api, err := equinixmetal.New(&options)
if err != nil {
return fmt.Errorf("could not create EquinixMetal client: %v", err)
}
if err := api.PreflightCheck(); err != nil {
return fmt.Errorf("could not complete EquinixMetal preflight check: %v", err)
}

plog.Debugf("Preflight check success; we have liftoff")
API = api
return nil
}
Loading

0 comments on commit 2e8c1c8

Please sign in to comment.