gogobosh

package module
v0.0.0-...-8f27bc4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: MIT Imports: 15 Imported by: 0

README

Go Go BOSH - BOSH client API for golang applications

This project is a golang library for applications wanting to talk to a BOSH/MicroBOSH or bosh-lite.

  • GoDoc
  • Test status Build Status

API

The following client functions are available, as a subset of the full BOSH Director API.

  • client.GetInfo()
  • client.GetStemcells()
  • client.GetReleases()
  • client.GetDeployments()
  • client.GetDeployment("cf-warden")
  • client.GetDeploymentVMs("cf-warden")
  • client.GetTasks()
  • client.GetTask(123)
  • client.GetTaskResult(123)

Install

go get github.com/cloudfoundry-community/gogobosh

Documentation

The documentation is published to https://godoc.org/github.com/cloudfoundry-community/gogobosh.

Also, view the documentation locally with:

godoc -goroot=$GOPATH github.com/cloudfoundry-community/gogobosh
Use

As a short getting started guide:

package main

import (
  "github.com/cloudfoundry-community/gogobosh"
  "fmt"
)

func main() {
  c, _ := gogobosh.NewClient(gogobosh.DefaultConfig())
  info, _ := c.GetInfo()

  fmt.Println("Director")
  fmt.Printf("  Name       %s\n", info.Name)
  fmt.Printf("  Version    %s\n", info.Version)
  fmt.Printf("  User       %s\n", info.User)
  fmt.Printf("  UUID       %s\n", info.UUID)
  fmt.Printf("  CPI        %s\n", info.CPI)
}

Tests

Tests are all local currently; and do not test against a running bosh or bosh-lite. I'd like to at least do integration tests against a bosh-lite in future.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPU

type CPU struct {
	Sys  string `json:"sys"`
	User string `json:"user"`
	Wait string `json:"wait"`
}

CPU struct

type Cfg

type Cfg struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Type      string `json:"type"`
	Content   string `json:"content"`
	CreatedAt int    `json:"int"`
	Deleted   bool   `json:"deleted"`
}

Cfg struct

type Client

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

Client used to communicate with BOSH

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient returns a new client

func (*Client) Cleanup

func (c *Client) Cleanup(removeall bool) (Task, error)

Cleanup will post to the cleanup endpoint of bosh, passing along the removeall flag passed in as a bool

func (*Client) CreateDeployment

func (c *Client) CreateDeployment(manifest string) (Task, error)

CreateDeployment from given BOSH

func (*Client) DeleteDeployment

func (c *Client) DeleteDeployment(name string) (Task, error)

DeleteDeployment from given BOSH

func (*Client) DoRequest

func (c *Client) DoRequest(r *request) (*http.Response, error)

DoRequest runs a request with our client

func (*Client) GetCloudConfig

func (c *Client) GetCloudConfig(latest bool) ([]Cfg, error)

GetCloudConfig from given BOSH

func (*Client) GetDeployment

func (c *Client) GetDeployment(name string) (Manifest, error)

GetDeployment from given BOSH

func (*Client) GetDeploymentVMs

func (c *Client) GetDeploymentVMs(name string) ([]VM, error)

GetDeploymentVMs from given BOSH

func (*Client) GetDeployments

func (c *Client) GetDeployments() ([]Deployment, error)

GetDeployments from given BOSH

func (*Client) GetInfo

func (c *Client) GetInfo() (info Info, err error)

GetInfo returns BOSH Info

func (*Client) GetReleases

func (c *Client) GetReleases() ([]Release, error)

GetReleases from given BOSH

func (*Client) GetStemcells

func (c *Client) GetStemcells() ([]Stemcell, error)

GetStemcells from given BOSH

func (*Client) GetTask

func (c *Client) GetTask(id int) (Task, error)

GetTask from given BOSH

func (*Client) GetTaskEvents

func (c *Client) GetTaskEvents(id int) ([]TaskEvent, error)

func (*Client) GetTaskOutput

func (c *Client) GetTaskOutput(id int, typ string) ([]string, error)

GetTaskOutput ...

func (*Client) GetTaskResult

func (c *Client) GetTaskResult(id int) []string

GetTaskResult from given BOSH

func (*Client) GetTasks

func (c *Client) GetTasks() ([]Task, error)

GetTasks from given BOSH

func (*Client) GetToken

func (c *Client) GetToken() (string, error)

GetToken - returns the current token bearer

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string) *request

NewRequest is used to create a new request

func (*Client) UUID

func (c *Client) UUID() string

UUID return uuid

func (*Client) UpdateCloudConfig

func (c *Client) UpdateCloudConfig(config string) error

UpdateCloudConfig

func (*Client) UploadRelease

func (c *Client) UploadRelease(url, sha1 string) (Task, error)

func (*Client) UploadStemcell

func (c *Client) UploadStemcell(url, sha1 string) (Task, error)

type Config

type Config struct {
	BOSHAddress       string
	Username          string
	Password          string
	ClientID          string
	ClientSecret      string
	UAAAuth           bool
	HttpClient        *http.Client
	SkipSslValidation bool
	TokenSource       oauth2.TokenSource
	Endpoint          *Endpoint
}

Config is used to configure the creation of a client

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig configuration for client

type Deployment

type Deployment struct {
	Name        string     `json:"name"`
	CloudConfig string     `json:"cloud_config"`
	Releases    []Resource `json:"releases"`
	Stemcells   []Resource `json:"stemcells"`
}

Deployment struct

func (*Deployment) HasRelease

func (d *Deployment) HasRelease(name string) bool

HasRelease if deployment has release

type Disk

type Disk struct {
	Ephemeral  DiskStats `json:"ephemeral"`
	System     DiskStats `json:"system"`
	Persistent DiskStats `json:"persistent"`
}

Disk struct

type DiskStats

type DiskStats struct {
	Percent      string `json:"percent"`
	InodePercent string `json:"inode_percent"`
}

DiskStats struct

type Endpoint

type Endpoint struct {
	URL string `json:"doppler_logging_endpoint"`
}

func DefaultEndpoint

func DefaultEndpoint() *Endpoint

type Event

type Event struct {
	ID         string                 `json:"id"`
	ParentID   string                 `json:"parent_id"`
	Timestamp  int                    `json:"timestamp"`
	User       string                 `json:"user"`
	Action     string                 `json:"action"`
	ObjectType string                 `json:"object_type"`
	ObjectName string                 `json:"object_name"`
	Task       string                 `json:"task"`
	Deployment string                 `json:"deployment"`
	Error      string                 `json:"error"`
	Context    map[string]interface{} `json:"context"`
}

Event struct

type Info

type Info struct {
	Name               string             `json:"name"`
	UUID               string             `json:"uuid"`
	Version            string             `json:"version"`
	User               string             `json:"user"`
	CPI                string             `json:"cpi"`
	UserAuthentication UserAuthentication `json:"user_authentication"`
}

Info struct

type Manifest

type Manifest struct {
	Manifest string `json:"manifest"`
}

Manifest struct

type Memory

type Memory struct {
	Percent string `json:"percent"`
	KB      string `json:"KB"`
}

Memory struct

type Process

type Process struct {
	Name   string        `json:"name"`
	State  string        `json:"state"`
	Uptime Uptime        `json:"uptime"`
	Mem    ProcessMemory `json:"mem"`
	CPU    ProcessCPU    `json:"cpu"`
}

VM Process struct

type ProcessCPU

type ProcessCPU struct {
	Total float64 `json:"total"`
}

ProcessCPU struct

type ProcessMemory

type ProcessMemory struct {
	Percent float64 `json:"percent"`
	KB      int     `json:"KB"`
}

ProcessMemory struct

type Release

type Release struct {
	Name            string           `json:"name"`
	ReleaseVersions []ReleaseVersion `json:"release_versions"`
}

Release struct

type ReleaseVersion

type ReleaseVersion struct {
	Version            string   `json:"version"`
	CommitHash         string   `json:"commit_hash"`
	UncommittedChanges bool     `json:"uncommitted_changes"`
	CurrentlyDeployed  bool     `json:"currently_deployed"`
	JobNames           []string `json:"job_names"`
}

ReleaseVersion struct

type Resource

type Resource struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Resource struct

type Stemcell

type Stemcell struct {
	Name            string `json:"name"`
	OperatingSystem string `json:"operating_system"`
	Version         string `json:"version"`
	CID             string `json:"cid"`
	Deployments     []struct {
		Name string `json:"name"`
	} `json:"deployments"`
}

Stemcell struct

type Task

type Task struct {
	ID          int    `json:"id"`
	State       string `json:"state"`
	Description string `json:"description"`
	Timestamp   int    `json:"timestamp"`
	Result      string `json:"result"`
	User        string `json:"user"`
}

Task struct

type TaskEvent

type TaskEvent struct {
	Time     int      `json:"time"`
	Stage    string   `json:"stage"`
	Tags     []string `json:"tags"`
	Total    int      `json:"total"`
	Task     string   `json:"task"`
	Index    int      `json:"index"`
	State    string   `json:"state"`
	Progress int      `json:"progress"`

	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

TaskEvent struct

type Uptime

type Uptime struct {
	Secs int `json:"secs"`
}

Uptime struct

type UserAuthentication

type UserAuthentication struct {
	Type    string `json:"type"`
	Options struct {
		URL string `json:"url"`
	} `json:"options"`
}

UserAuthentication struct

type VM

type VM struct {
	VMCID             string    `json:"vm_cid"`
	IPs               []string  `json:"ips"`
	DNS               []string  `json:"dns"`
	AgentID           string    `json:"agent_id"`
	JobName           string    `json:"job_name"`
	Index             int       `json:"index"`
	JobState          string    `json:"job_state"`
	State             string    `json:"state"`
	ResourcePool      string    `json:"resource_pool"`
	VMType            string    `json:"vm_type"`
	Vitals            Vitals    `json:"vitals"`
	Processes         []Process `json:"processes"`
	ResurectionPaused bool      `json:"resurrection_paused"`
	AZ                string    `json:"az"`
	ID                string    `json:"id"`
	Bootstrap         bool      `json:"bootstrap"`
	Ignore            bool      `json:"ignore"`
}

VM struct

type Vitals

type Vitals struct {
	Disk Disk     `json:"disk"`
	Load []string `json:"load"`
	Mem  Memory   `json:"mem"`
	Swap Memory   `json:"swap"`
	CPU  CPU      `json:"cpu"`
}

VM Vitals struct

Jump to

Keyboard shortcuts

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