deploy

package module
v0.0.0-...-d80aa0b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

README

AutoRotate-VPN/deploy

Usage

package main

import (
  "log"
  "github.com/Th3-S1lenc3/AutoRotate/deploy"
)

func main() {

  d := NewDeploy()

  // var apiToken string
  // var debug bool
  // var configFile string
  // var dryRun bool

  // Initialize
  err := d.Init(apiToken, debug)
  if err != nil {
    log.Fatal(err)
  }

  // Load Config From File
  instanceOptions, err := d.LoadConfigFromFile(configFile)
  if err != nil {
    log.Fatal(err)
  }

  // Or Manually Construct
  instanceOptions := deploy.InstanceCreateOptions{
    Region: "us-central",
  	Type: "g6-nanode-1",
  	Label: "test",
  	RootPass: "someSecurePassword",
  	StackScriptID: 123456,
  	StackScriptData map[string]string{
      "username": "demonstration",
    },
  	Image: "linode/debian11",
  	Tags: []string{
      "demonstration",
    },
  }

  res, err := d.Deploy(instanceOptions, dryRun)
  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(res)
}
JSON Config File
{
  "region": "us-central",
  "type": "g6-nanode-1",
  "label": "test",
  "root_pass": "someSecurePassword",
  "stackscript_id": "123456",
  "stackscript_data": {
    "username": "demonstration"
  },
  "image": "linode/debian11",
  "tags": [
    "demonstration"
  ]
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deploy

type Deploy struct {
	// contains filtered or unexported fields
}

func NewDeploy

func NewDeploy() *Deploy

func (*Deploy) Deploy

func (d *Deploy) Deploy(options InstanceCreateOptions, dryRun bool) (string, error)

func (*Deploy) Init

func (d *Deploy) Init(apiToken string, debug bool) error

func (*Deploy) LoadConfigFromFile

func (d *Deploy) LoadConfigFromFile(configFile string) (InstanceCreateOptions, error)

type InstanceCreateOptions

type InstanceCreateOptions struct {
	Region          string                           `json:"region"`
	Type            string                           `json:"type"`
	Label           string                           `json:"label,omitempty"`
	Group           string                           `json:"group,omitempty"`
	RootPass        string                           `json:"root_pass,omitempty"`
	AuthorizedKeys  []string                         `json:"authorized_keys,omitempty"`
	AuthorizedUsers []string                         `json:"authorized_users,omitempty"`
	StackScriptID   StringInt                        `json:"stackscript_id,omitempty"`
	StackScriptData map[string]string                `json:"stackscript_data,omitempty"`
	BackupID        StringInt                        `json:"backup_id,omitempty"`
	Image           string                           `json:"image,omitempty"`
	Interfaces      []linode.InstanceConfigInterface `json:"interfaces,omitempty"`
	BackupsEnabled  bool                             `json:"backups_enabled,omitempty,string"`
	PrivateIP       bool                             `json:"private_ip,omitempty,string"`
	Tags            []string                         `json:"tags,omitempty"`

	// Creation fields that need to be set explicitly false, "", or 0 use pointers
	SwapSize *int  `json:"swap_size,omitempty"`
	Booted   *bool `json:"booted,omitempty"`
}

type StringInt

type StringInt int

func (*StringInt) UnmarshalJSON

func (st *StringInt) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL