cloudfoundry

package
v0.0.0-...-907143c Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ReconcileOrganizations recon.Type = "organizations"
	ReconcileSpaces        recon.Type = "spaces"
	ReconcileApps          recon.Type = "apps"
)
View Source
const CFGuid = "main"

Variables

This section is empty.

Functions

func NewReconciler

func NewReconciler(db Database, cf API, olderThan time.Duration) recon.Reconciler

NewReconciler fetches new reconciliation work from the database and updates the corresponding item via the CloudFoundry API.

It returns true, if there was work to be done and false, if there was no open reconciliation work.

Types

type API

type API interface {
	ListOrgs() ([]Org, error)
	ListSpaces(orgGuid string) ([]Space, error)
	ListApps(spaceGuid string) ([]App, error)
	GetRoutes(appId string) (Routes, error)
	GetInstances(appId string) (Instances, error)
}

API is an abstraction around the CloudFoundry functionality.

func NewApi

func NewApi(cli CfCli) API

func NewDefaultApi

func NewDefaultApi(l CFLogin) (API, error)

type App

type App struct {
	AppInfo `bson:",inline"`
}

type AppInfo

type AppInfo struct {
	Guid  string
	Name  string
	Space SpaceInfo
}

type CF

type CF struct {
	CFInfo      `bson:",inline"`
	Orgs        []string
	LastUpdated time.Time `bson:"lastUpdated"`
}

type CFInfo

type CFInfo struct {
	Guid string
}

type CFLogin

type CFLogin struct {
	Api  string
	User string
	Pass string
}

type CfCli

type CfCli interface {
	ListOrgs() ([]cf.Org, error)
	GetOrgByGuid(guid string) (cf.Org, error)
	GetSpaceByGuid(guid string) (cf.Space, error)
	ListSpacesByOrgGuid(orgGuid string) ([]cf.Space, error)
	ListAppsBySpaceGuid(spaceGuid string) ([]cf.App, error)
	GetAppRoutes(appGuid string) ([]cf.Route, error)
	GetAppInstances(guid string) (map[string]cf.AppInstance, error)
}

CfCli is a wrapper interface for the official cloudfoundry client extracting the needed functions.

type Database

type Database interface {
	AcceptReconcileJob(olderThan time.Duration) (reconciliation.Job, bool)

	UpsertOrgs(cfGuid string, orgs []Org) error
	UpsertOrgSpaces(orgGuid string, spaces []Space) error
	UpsertSpaceApps(spaceGuid string, apps []App) error

	DeleteOrg(guid string) (bool, error)
	DeleteSpace(guid string) (bool, error)
	DeleteApp(guid string) (bool, error)

	ListApps() ([]App, error)
	GetApp(id string) (App, error)

	Cached(id string, duration time.Duration, cached interface{}, f func() (interface{}, error)) (interface{}, error)
}

func NewMongoDatabase

func NewMongoDatabase(l MongoLogin) (Database, error)

type Instance

type Instance struct {
	State string
	Since time.Time
}

type Instances

type Instances []Instance

type MongoLogin

type MongoLogin struct {
	Uri string
	DB  string
}

type Org

type Org struct {
	OrgInfo     `bson:",inline"`
	Spaces      []string
	LastUpdated time.Time `bson:"lastUpdated"`
}

type OrgInfo

type OrgInfo struct {
	Guid string
	Name string
	Cf   CFInfo
}

type Provider

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

func NewProvider

func NewProvider(db Database, cf API) *Provider

func (*Provider) GetApp

func (p *Provider) GetApp(id string) (sdk.App, error)

func (*Provider) GetAppInstances

func (p *Provider) GetAppInstances(id string) (sdk.AppInstances, error)

func (*Provider) GetAppRouting

func (p *Provider) GetAppRouting(id string) (sdk.AppRouting, error)

func (*Provider) ListApps

func (p *Provider) ListApps() ([]sdk.App, error)

type Route

type Route struct {
	Host string `bson:"host"`
	Path string `bson:"path"`
	Port int    `bson:"port"`
}

type Routes

type Routes []Route

type Space

type Space struct {
	SpaceInfo   `bson:",inline"`
	Apps        []string
	LastUpdated time.Time `bson:"lastUpdated"`
}

type SpaceInfo

type SpaceInfo struct {
	Guid string
	Name string
	Org  OrgInfo
}

Jump to

Keyboard shortcuts

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