yc

package
v0.0.0-...-072b9f9 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KsToolKey = "yc.ks-tool.dev"

	DefaultDiskType          = "network-ssd"
	DefaultDiskID            = "fd83j4siasgfq4pi1qif" //debian-12-v20240920
	DefaultDiskSizeGib int64 = 10

	DefaultPlatformID = "standard-v3"
	DefaultZone       = "ru-central1-d"

	DefaultCores        int64 = 2
	DefaultCoreFraction int64 = 100
	DefaultMemoryGib    int64 = 2
)

Variables

View Source
var (
	Statuses = func() string {
		var out []string
		for k := range statuses {
			out = append(out, k)
		}

		sort.Strings(out)
		return strings.Join(out, ", ")
	}

	AllowStatus = func(s string) bool {
		s = strings.ToUpper(s[:1]) + strings.ToLower(s[1:])
		_, ok := statuses[s]
		return ok
	}
)

Functions

func FPrintClusterGet

func FPrintClusterGet(w io.Writer, lst []*compute.Instance)

func FPrintComputeList

func FPrintComputeList(w io.Writer, lst []*compute.Instance)

Types

type Client

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

func NewClient

func NewClient(token string) (*Client, error)

func NewFromIAMKey

func NewFromIAMKey(token []byte) (*Client, error)

NewFromIAMKey creates an SDK instance with credentials for the given IAM Key See https://yandex.cloud/ru/docs/iam/concepts/authorization/iam-token for details.

func NewFromToken

func NewFromToken(token string) (*Client, error)

NewFromToken creates an SDK instance with credentials for user Yandex Passport OAuth token. See https://cloud.yandex.ru/docs/iam/concepts/authorization/oauth-token for details.

func (*Client) ComputeInstanceCreate

func (c *Client) ComputeInstanceCreate(ctx context.Context, cfg *ComputeInstanceConfig) (*operation.Operation, error)

func (*Client) ComputeInstanceDelete

func (c *Client) ComputeInstanceDelete(ctx context.Context, id string) (*operation.Operation, error)

func (*Client) ComputeInstanceGroupCreate

func (c *Client) ComputeInstanceGroupCreate(ctx context.Context, id string) (*operation.Operation, error)

func (*Client) ComputeInstanceGroupDelete

func (c *Client) ComputeInstanceGroupDelete(ctx context.Context, id string) (*operation.Operation, error)

func (*Client) ComputeInstanceList

func (c *Client) ComputeInstanceList(
	ctx context.Context,
	folderID string,
	lbl map[string]string,
	filters ...Filter,
) ([]*compute.Instance, error)

func (*Client) ComputeInstanceStart

func (c *Client) ComputeInstanceStart(ctx context.Context, id string) (*operation.Operation, error)

func (*Client) ComputeInstanceStop

func (c *Client) ComputeInstanceStop(ctx context.Context, id string) (*operation.Operation, error)

func (*Client) FirstSubnetInZone

func (c *Client) FirstSubnetInZone(ctx context.Context, folderID string, zone string) (string, error)

func (*Client) IAMServiceAccountGetIdByName

func (c *Client) IAMServiceAccountGetIdByName(ctx context.Context, name string) (string, error)

type ComputeInstanceConfig

type ComputeInstanceConfig struct {
	Name       string `mapstructure:"name"`
	PlatformID string `mapstructure:"platform-id"`

	FolderID string `mapstructure:"folder-id"`
	SubnetID string `mapstructure:"subnet-id"`
	Zone     string `mapstructure:"zone"`
	Address  string `mapstructure:"address"`

	Cores        uint `mapstructure:"cores"`
	CoreFraction uint `mapstructure:"core-fraction"`
	Memory       uint `mapstructure:"memory"`

	DiskType string `mapstructure:"disk-type"`
	DiskID   string `mapstructure:"disk-id"`
	DiskSize uint   `mapstructure:"disk-size"`

	Preemptible    bool   `mapstructure:"preemptible"`
	NoPublicIP     bool   `mapstructure:"no-public-ip"`
	ServiceAccount string `mapstructure:"sa"`

	UserDataFile      string   `mapstructure:"user-data-file"`
	User              string   `mapstructure:"user"`
	SshPublicKeyFiles []string `mapstructure:"ssh-pub"`
	Shell             string   `mapstructure:"shell"`

	ClusterID         string
	Metadata          map[string]string
	Labels            map[string]string
	SshAuthorizedKeys []string
}

func (*ComputeInstanceConfig) SetUserData

func (cfg *ComputeInstanceConfig) SetUserData(tpl string) error

type ComputeInstanceIPv4

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

func (ComputeInstanceIPv4) External

func (i ComputeInstanceIPv4) External() string

func (ComputeInstanceIPv4) Internal

func (i ComputeInstanceIPv4) Internal() string

type Filter

type Filter struct {
	Field    string
	Operator FilterOperator
	Value    any
}

func (Filter) String

func (f Filter) String() string

type FilterOperator

type FilterOperator string
const (
	OperatorEq    FilterOperator = "="
	OperatorNe    FilterOperator = "!="
	OperatorIn    FilterOperator = "IN"
	OperatorNotIn FilterOperator = "NOT IN"
)

Jump to

Keyboard shortcuts

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