models

package
v0.0.0-...-875c423 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: CC0-1.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CertificateStatusAttached   string = "attached"
	CertificateStatusValidating string = "validating"
	CertificateStatusDeleted    string = "deleted"
	CertificateStatusFailed     string = "failed"
)
View Source
const ProvisioningExpirationPeriodHours time.Duration = 84 * time.Hour

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB) error

Types

type Certificate

type Certificate struct {
	gorm.Model
	RouteId     uint
	Domain      string
	CertURL     string
	Certificate []byte
	Expires     time.Time `gorm:"index"`
	// adding a certificateArn to this struct, so we can truck the requested/provisioned certificates by ACM
	CertificateArn    string `gorm:"not null"`
	CertificateStatus string `gorm:"not null"` //(Attached, Validating, Deleted, failed)
}

type Route

type Route struct {
	gorm.Model
	InstanceId        string `gorm:"not null;unique_index"`
	State             State  `gorm:"not null;index"`
	ChallengeJSON     []byte
	DomainExternal    string
	DomainInternal    string
	DistId            string
	Origin            string
	Path              string     // Always empty, should not remove because it is in DB
	InsecureOrigin    bool       // Always false, should not remove because it is in DB
	DefaultTTL        int64      `gorm:"default:86400"`
	ProvisioningSince *time.Time //using the same field to measure a time for Provisioning or Deprovisioning
	Certificates      []Certificate
}

func (*Route) BeforeCreate

func (r *Route) BeforeCreate(tx *gorm.DB) error

BeforeCreate hook will change the value of Provisioning_since field to time.Now() if creating a route in 'Provisioning' state if the state is 'Provisioned' then the value should be 'nil'

func (*Route) BeforeUpdate

func (r *Route) BeforeUpdate(tx *gorm.DB) error

func (*Route) GetDomains

func (r *Route) GetDomains() []string

func (*Route) IsProvisioningExpired

func (r *Route) IsProvisioningExpired() bool

the issue of a certificate in ACM has a time out limit of 72 hours plus few (12) hours to account for any unexpected delays we've got to the magic number of 84 hours represented by the const - ProvisioningExpirationPeriodHours

type RouteManager

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

func NewManager

func NewManager(
	logger lager.Logger,
	cloudFront utils.DistributionIface,
	settings config.Settings,
	routeStoreIface RouteStoreInterface,
	certsManager utils.CertificateManagerInterface,
) RouteManager

func (*RouteManager) CheckRoutesToUpdate

func (m *RouteManager) CheckRoutesToUpdate()

func (*RouteManager) Create

func (m *RouteManager) Create(
	instanceId,
	domain string,
	origin string,
	defaultTTL int64,
	forwardedHeaders utils.Headers,
	forwardCookies bool,
	tags map[string]string,
) (*Route, error)

func (*RouteManager) DeleteOrphanedCerts

func (m *RouteManager) DeleteOrphanedCerts()

func (*RouteManager) Disable

func (m *RouteManager) Disable(r *Route) error

func (*RouteManager) Get

func (m *RouteManager) Get(instanceId string) (*Route, error)

Get a Route from a database, by instanceId

func (*RouteManager) GetCDNConfiguration

func (m *RouteManager) GetCDNConfiguration(route *Route) (*cloudfront.Distribution, error)

func (*RouteManager) GetCurrentlyDeployedDomains

func (m *RouteManager) GetCurrentlyDeployedDomains(r *Route) ([]string, error)

func (*RouteManager) GetDNSChallenges

func (m *RouteManager) GetDNSChallenges(route *Route, onlyValidatingCertificates bool) ([]utils.DomainValidationChallenge, error)

func (*RouteManager) Poll

func (m *RouteManager) Poll(r *Route) error

func (*RouteManager) Update

func (m *RouteManager) Update(
	instanceId string,
	domain *string,
	defaultTTL *int64,
	forwardedHeaders *utils.Headers,
	forwardCookies *bool,
) (bool, error)

Update function updates the CDN route service and returns whether the update has been performed asynchronously or not this function is ONLY called when a tenant will issue 'cf service-update'

type RouteManagerIface

type RouteManagerIface interface {
	Create(
		instanceId string,
		domain string,
		origin string,
		defaultTTL int64,
		forwardedHeaders utils.Headers,
		forwardCookies bool,
		tags map[string]string,
	) (*Route, error)

	Update(
		instanceId string,
		domain *string,
		defaultTTL *int64,
		forwardedHeaders *utils.Headers,
		forwardCookies *bool,
	) (bool, error)

	Get(instanceId string) (*Route, error)

	Poll(route *Route) error

	Disable(route *Route) error

	DeleteOrphanedCerts()

	GetDNSChallenges(route *Route, onlyValidatingCertificates bool) ([]utils.DomainValidationChallenge, error)

	GetCDNConfiguration(route *Route) (*cloudfront.Distribution, error)
}

type RouteStore

type RouteStore struct {
	Database *gorm.DB
	Logger   lager.Logger
}

func (RouteStore) Create

func (r RouteStore) Create(route *Route) error

func (RouteStore) FindAllMatching

func (r RouteStore) FindAllMatching(route Route) ([]Route, error)

func (RouteStore) FindOneMatching

func (r RouteStore) FindOneMatching(route Route) (Route, error)

func (RouteStore) Save

func (r RouteStore) Save(route *Route) error

type RouteStoreInterface

type RouteStoreInterface interface {
	Save(*Route) error
	Create(*Route) error
	FindOneMatching(Route) (Route, error)
	FindAllMatching(Route) ([]Route, error)
}

type State

type State string
const (
	Provisioning   State = "provisioning"
	Provisioned    State = "provisioned"
	Deprovisioning State = "deprovisioning"
	Deprovisioned  State = "deprovisioned"
	Conflict       State = "conflict"
	Failed         State = "failed"
	TimedOut       State = "timedout"
)

func (*State) Scan

func (s *State) Scan(value interface{}) error

Unmarshal an `interface{}` to a `State` when reading from the database

func (State) Value

func (s State) Value() (driver.Value, error)

Marshal a `State` to a `string` when saving to the database

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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