opapp

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2018 License: Apache-2.0 Imports: 17 Imported by: 5

Documentation

Index

Constants

View Source
const (
	TypeArray    = "array"
	TypeString   = "string"
	TypeInteger  = "integer"
	TypeNumber   = "number"
	TypePassword = "password"
	TypeBoolean  = "boolean"
)
View Source
const APIVersionV1 = "v1"
View Source
const ClusterSchema = `` /* 13647-byte string literal not displayed */

Variables

This section is empty.

Functions

func ValidateClusterConfTmpl

func ValidateClusterConfTmpl(clusterTmpl *ClusterConfTemplate, input jsonutil.Json) error

Types

type BufferedFile

type BufferedFile struct {
	Name string
	Data []byte
}

BufferedFile represents an archive file buffered for later processing.

type ClusterConf

type ClusterConf struct {
	RenderJson string `json:"-"`

	AppId                      string                 `json:"app_id"`
	VersionId                  string                 `json:"version_id"`
	GlobalUuid                 string                 `json:"global_uuid"`
	Name                       string                 `json:"name"`
	Description                string                 `json:"description"`
	Subnet                     string                 `json:"subnet"`
	Links                      map[string]string      `json:"links"`
	BackupPolicy               string                 `json:"backup_policy"`
	IncrementalBackupSupported *bool                  `json:"incremental_backup_supported"`
	UpgradePolicy              []string               `json:"upgrade_policy"`
	Nodes                      []Node                 `json:"nodes"`
	Env                        map[string]interface{} `json:"env"`
	AdvancedActions            []string               `json:"advanced_actions"`
	Endpoints                  map[string]struct {
		Port     uint32 `json:"port"`
		Protocol string `json:"protocol"`
	} `json:"endpoints"`
	MetadataRootAccess *bool        `json:"metadata_root_access"`
	HealthCheck        *HealthCheck `json:"health_check"`
	Monitor            *Monitor     `json:"monitor"`
	DisplayTabs        struct {
		DisplayTabsItems map[string]struct {
			Cmd              string   `json:"cmd"`
			RolesToExecuteOn []string `json:"roles_to_execute_on"`
			Description      string   `json:"description"`
			Timeout          uint32   `json:"timeout"`
		}
	} `json:"display_tabs"`
}

func (ClusterConf) Validate

func (c ClusterConf) Validate() error

type ClusterConfTemplate

type ClusterConfTemplate struct {
	Raw string
}

func (*ClusterConfTemplate) Render

func (c *ClusterConfTemplate) Render(input jsonutil.Json) (ClusterConf, error)

type ConfigTemplate

type ConfigTemplate struct {
	Raw         string
	Type        string            `json:"type,omitempty"`
	Properties  []*ConfigTemplate `json:"properties,omitempty"`
	Key         string            `json:"key,omitempty"`
	Description string            `json:"description,omitempty"`
	Required    bool              `json:"required,omitempty"`

	Default interface{} `json:"default,omitempty"`
	Pattern *string     `json:"pattern,omitempty"`

	Limits            map[string][]string `json:"limits,omitempty"`
	AllowedOperations []string            `json:"allowed_operations,omitempty"`

	Port *int `json:"port,omitempty"`

	Range []interface{} `json:"range,omitempty"`
	Min   *float64      `json:"min,omitempty"`
	Max   *float64      `json:"max,omitempty"`
	Step  *int64        `json:"step,omitempty"`

	Changeable  *bool   `json:"changeable,omitempty"`
	Separator   *string `json:"separator,omitempty"`
	Multichoice *bool   `json:"multichoice,omitempty"`
}

func DecodeConfigJson

func DecodeConfigJson(data []byte) (*ConfigTemplate, error)

func (*ConfigTemplate) GetDefaultConfig

func (c *ConfigTemplate) GetDefaultConfig() jsonutil.Json

func (*ConfigTemplate) GetRenderedConfig

func (c *ConfigTemplate) GetRenderedConfig(config jsonutil.Json) jsonutil.Json

input user defined config, output rendered config with default values

func (*ConfigTemplate) Validate

func (c *ConfigTemplate) Validate(config jsonutil.Json, parent ...string) error

validate the rendered config

type HealthCheck

type HealthCheck struct {
	Enable             *bool  `json:"enable"`
	IntervalSec        uint32 `json:"interval_sec"`
	TimeoutSec         uint32 `json:"timeout_sec"`
	ActionTimeoutSec   uint32 `json:"action_timeout_sec"`
	HealthyThreshold   uint32 `json:"healthy_threshold"`
	UnhealthyThreshold uint32 `json:"unhealthy_threshold"`
	CheckCmd           string `json:"check_cmd"`
	ActionCmd          string `json:"action_cmd"`
}

type IndexFile

type IndexFile struct {
	APIVersion string                `json:"api_version"`
	Generated  time.Time             `json:"generated"`
	Entries    map[string]OpVersions `json:"entries"`
}

func LoadIndexFile

func LoadIndexFile(path string) (*IndexFile, error)

LoadIndexFile takes a file at the given path and returns an IndexFile object

func NewIndexFile

func NewIndexFile() *IndexFile

NewIndexFile initializes an index.

func (IndexFile) Add

func (i IndexFile) Add(md *Metadata, filename, baseURL, digest string)

Add adds a file to the index This can leave the index in an unsorted state

func (IndexFile) Get

func (i IndexFile) Get(name, version string) (*OpVersion, error)

Get returns the AppVersion for the given name.

If version is empty, this will return the app with the highest version.

func (IndexFile) Has

func (i IndexFile) Has(name, version string) bool

Has returns true if the index has an entry for a app with the given name and exact version.

func (*IndexFile) Merge

func (i *IndexFile) Merge(f *IndexFile)

Merge merges the given index file into this index.

This merges by name and version.

If one of the entries in the given index does _not_ already exist, it is added. In all other cases, the existing record is preserved.

This can leave the index in an unsorted state

func (IndexFile) SortEntries

func (i IndexFile) SortEntries()

SortEntries sorts the entries by version in descending order.

In canonical form, the individual version records should be sorted so that the most recent release for every version is in the 0th slot in the Entries.AppVersions array. That way, tooling can predict the newest version without needing to parse SemVers.

func (IndexFile) WriteFile

func (i IndexFile) WriteFile(dest string, mode os.FileMode) error

WriteFile writes an index file to the given destination path.

The mode on the file is set to 'mode'.

type Maintainer

type Maintainer struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
}

type Metadata

type Metadata struct {
	ApiVersion  string        `json:"api_version,omitempty"`
	Name        string        `json:"name"`
	Version     string        `json:"version"`
	AppVersion  string        `json:"app_version,omitempty"`
	Description string        `json:"description,omitempty"`
	Home        string        `json:"home,omitempty"`
	Icon        string        `json:"icon,omitempty"`
	Maintainers []*Maintainer `json:"maintainers,omitempty"`
	Screenshots []string      `json:"screenshots,omitempty"`
	Keywords    []string      `json:"keywords,omitempty"`
	Sources     []string      `json:"sources,omitempty"`
}

func DecodePackageJson

func DecodePackageJson(data []byte) (*Metadata, error)

func (*Metadata) GetApiVersion

func (m *Metadata) GetApiVersion() string

func (*Metadata) GetAppVersion

func (m *Metadata) GetAppVersion() string

func (*Metadata) GetDescription

func (m *Metadata) GetDescription() string

func (*Metadata) GetHome

func (m *Metadata) GetHome() string

func (*Metadata) GetIcon

func (m *Metadata) GetIcon() string

func (*Metadata) GetKeywords

func (m *Metadata) GetKeywords() []string

func (*Metadata) GetMaintainers

func (m *Metadata) GetMaintainers() []*Maintainer

func (*Metadata) GetName

func (m *Metadata) GetName() string

func (*Metadata) GetPackageName

func (m *Metadata) GetPackageName() string

func (*Metadata) GetScreenshots

func (m *Metadata) GetScreenshots() []string

func (*Metadata) GetSources

func (m *Metadata) GetSources() []string

func (*Metadata) GetVersion

func (m *Metadata) GetVersion() string

type Monitor

type Monitor struct {
	Enable *bool  `json:"enable"`
	Cmd    string `json:"cmd"`
	Items  map[string]struct {
		Unit                   string   `json:"unit"`
		ValueType              string   `json:"value_type"`
		StatisticsType         string   `json:"statistics_type"`
		ScaleFactorWhenDisplay uint32   `json:"scale_factor_when_display"`
		Enums                  []string `json:"enums"`
	} `json:"items"`
	Groups  map[string][]string `json:"groups"`
	Display []string            `json:"display"`
	Alarm   []string            `json:"alarm"`
}

type Node

type Node struct {
	Role            string   `json:"role"`
	AdvancedActions []string `json:"advanced_actions"`
	Loadbalancer    []struct {
		Listener string `json:"listener"`
		Port     uint32 `json:"port"`
		Policy   string `json:"policy"`
	} `json:"loadbalancer"`
	Container struct {
		Type  string `json:"type"`
		Image string `json:"image"`
	} `json:"container"`
	Count  uint32 `json:"count"`
	CPU    uint32 `json:"cpu"`
	Memory uint32 `json:"memory"`
	GPU    uint32 `json:"gpu"`
	Volume struct {
		Size         uint32      `json:"size"`
		InstanceSize uint32      `json:"instance_size"`
		MountPoint   interface{} `json:"mount_point"`
		MountOptions string      `json:"mount_options"`
		Filesystem   string      `json:"filesystem"`
	} `json:"volume"`
	Replica               uint32                 `json:"replica"`
	Passphraseless        string                 `json:"passphraseless"`
	VerticalScalingPolicy string                 `json:"vertical_scaling_policy"`
	UserAccess            *bool                  `json:"user_access"`
	Services              map[string]interface{} `json:"services"`
	ServerIDUpperBound    uint32                 `json:"server_id_upper_bound"`
	Env                   map[string]interface{} `json:"env"`
	AgentInstalled        *bool                  `json:"agent_installed"`
	CustomMetadata        map[string]interface{} `json:"custom_metadata"`
	HealthCheck           *HealthCheck           `json:"health_check"`
	Monitor               *Monitor               `json:"monitor"`
}

type OpApp

type OpApp struct {
	Metadata *Metadata `json:"metadata,omitempty"`

	ConfigTemplate *ConfigTemplate `json:"config,omitempty"`

	ClusterConfTemplate *ClusterConfTemplate `json:"cluster_template,omitempty"`

	Files []BufferedFile `json:"files,omitempty"`
}

func (*OpApp) Validate

func (a *OpApp) Validate(config jsonutil.Json) error

type OpVersion

type OpVersion struct {
	*Metadata
	URLs    []string  `json:"urls"`
	Created time.Time `json:"created,omitempty"`
	Removed bool      `json:"removed,omitempty"`
	Digest  string    `json:"digest,omitempty"`
}

OpVersion represents a app entry in the IndexFile

func (OpVersion) GetUrls

func (h OpVersion) GetUrls() []string

type OpVersions

type OpVersions []*OpVersion

OpVersions is a list of versioned app references. Implements a sorter on OpApp.

func (OpVersions) Len

func (c OpVersions) Len() int

Len returns the length.

func (OpVersions) Less

func (c OpVersions) Less(a, b int) bool

Less returns true if the version of entry a is less than the version of entry b.

func (OpVersions) Swap

func (c OpVersions) Swap(i, j int)

Swap swaps the position of two items in the versions slice.

type Service

type Service struct {
	NodesToExecuteOn *uint32                `json:"nodes_to_execute_on"`
	PostStartService *bool                  `json:"post_start_service"`
	PostStopService  *bool                  `json:"post_stop_service"`
	Timeout          *uint32                `json:"timeout"`
	ServiceParams    map[string]interface{} `json:"service_params"`
	PreCheck         string                 `json:"pre_check"`
	Cmd              string                 `json:"cmd"`
	Order            *uint32                `json:"order"`
}

type ServiceParams

type ServiceParams struct {
	Params map[string]interface{}
}

Jump to

Keyboard shortcuts

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