api

package
v0.0.0-...-94f0592 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

This file was taken from the pq project and is licensed under the terms of the MIT license: https://github.com/lib/pq Copyright (c) 2011-2013, 'pq' Contributors Portions Copyright (C) 2011 Blake Mizerany

Index

Constants

View Source
const (
	// EventUpdateComplete indicates that the update process completed. It could
	// mean a successful or failed updated, depending on the result attached to
	// the event. This applies to all events.
	EventUpdateComplete = 3

	// EventUpdateDownloadStarted indicates that the instance started
	// downloading the update package.
	EventUpdateDownloadStarted = 13

	// EventUpdateDownloadFinished indicates that the update package was
	// downloaded.
	EventUpdateDownloadFinished = 14

	// EventUpdateInstalled indicates that the update package was installed.
	EventUpdateInstalled = 800
)
View Source
const (
	// ResultFailed indicates that the operation associated with the event
	// posted failed.
	ResultFailed = 0

	// ResultSuccess indicates that the operation associated with the event
	// posted succeeded.
	ResultSuccess = 1

	// ResultSuccessReboot also indicates a successful operation, but it's
	// meant only to be used along with events of EventUpdateComplete type.
	// It's important that instances use EventUpdateComplete events in
	// combination with ResultSuccessReboot to communicate a successful update
	// completed as it has a special meaning for Nebraska in order to adjust
	// properly the rollout policies and create activity entries.
	ResultSuccessReboot = 2
)
View Source
const (
	// InstanceStatusUndefined indicates that the instance hasn't sent yet an
	// event to Nebraska so it doesn't know in which state it is.
	InstanceStatusUndefined int = 1 + iota

	// InstanceStatusUpdateGranted indicates that the instance has been granted
	// an update (it should be reporting soon through events how is it going).
	InstanceStatusUpdateGranted

	// InstanceStatusError indicates that the instance reported an error while
	// processing the update.
	InstanceStatusError

	// InstanceStatusComplete indicates that the instance completed the update
	// process successfully.
	InstanceStatusComplete

	// InstanceStatusInstalled indicates that the instance has installed the
	// downloaded packages, but it hasn't applied it or restarted yet.
	InstanceStatusInstalled

	// InstanceStatusDownloaded indicates that the instance downloaded
	// successfully the update package.
	InstanceStatusDownloaded

	// InstanceStatusDownloading indicates that the instance started
	// downloading the update package.
	InstanceStatusDownloading

	// InstanceStatusOnHold indicates that the instance hasn't been granted an
	// update because one of the rollout policy limits has been reached.
	InstanceStatusOnHold
)
View Source
const (
	// PkgTypeFlatcar indicates that the package is a Flatcar update package
	PkgTypeFlatcar int = 1 + iota

	// PkgTypeDocker indicates that the package is a Docker container
	PkgTypeDocker

	// PkgTypeRocket indicates that the package is a Rocket container
	PkgTypeRocket

	// PkgTypeOther is the generic package type.
	PkgTypeOther
)
View Source
const AssetDebug = false

AssetDebug is true if the assets were built with the debug flag enabled.

View Source
const (
	// Realm used for basic authentication.
	Realm = "nebraska"
)

Variables

View Source
var (

	// ErrNoRowsAffected indicates that no rows were affected in an update or
	// delete database operation.
	ErrNoRowsAffected = errors.New("nebraska: no rows affected")

	// ErrInvalidSemver indicates that the provided semver version is not valid.
	ErrInvalidSemver = errors.New("nebraska: invalid semver")

	// ErrInvalidArch indicates that the provided architecture is not valid/supported
	ErrInvalidArch = errors.New("nebraska: invalid/unsupported arch")

	// ErrArchMismatch indicates that arches of two objects didn't
	// match (for example, for a package and channel)
	ErrArchMismatch = errors.New("nebraska: mismatched arches")
)
View Source
var (
	// ErrInvalidPackage error indicates that a package doesn't belong to the
	// application it was supposed to belong to.
	ErrInvalidPackage = errors.New("nebraska: invalid package")

	// ErrBlacklistedChannel error indicates an attempt of creating/updating a
	// channel using a package that has blacklisted the channel.
	ErrBlacklistedChannel = errors.New("nebraska: blacklisted channel")
)
View Source
var (
	// ErrInvalidInstance indicates that the instance provided is not valid or
	// it doesn't exist.
	ErrInvalidInstance = errors.New("nebraska: invalid instance")

	// ErrInvalidApplicationOrGroup indicates that the application or group id
	// provided are not valid or related to each other.
	ErrInvalidApplicationOrGroup = errors.New("nebraska: invalid application or group")

	// ErrInvalidEventTypeOrResult indicates that the event or result provided
	// are not valid (Nebraska only implements a subset of the Omaha protocol
	// events).
	ErrInvalidEventTypeOrResult = errors.New("nebraska: invalid event type or result")

	// ErrEventRegistrationFailed indicates that the event registration into
	// Nebraska failed.
	ErrEventRegistrationFailed = errors.New("nebraska: event registration failed")

	// ErrNoUpdateInProgress indicates that an event was received but there
	// wasn't an update in progress for the provided instance/application, so
	// it was rejected.
	ErrNoUpdateInProgress = errors.New("nebraska: no update in progress")

	// ErrFlatcarEventIgnored indicates that a Flatcar updater event was ignored.
	// This is a temporary solution to handle Flatcar specific behaviour.
	ErrFlatcarEventIgnored = errors.New("nebraska: flatcar event ignored")
)
View Source
var (
	// ErrInvalidChannel error indicates that a channel doesn't belong to the
	// application it was supposed to belong to.
	ErrInvalidChannel = errors.New("nebraska: invalid channel")

	// ErrExpectingValidTimezone error indicates that a valid timezone wasn't
	// provided when enabling the flag PolicyOfficeHours.
	ErrExpectingValidTimezone = errors.New("nebraska: expecting valid timezone")
)
View Source
var (
	// ErrRegisterInstanceFailed indicates that the instance registration did
	// not succeed.
	ErrRegisterInstanceFailed = errors.New("nebraska: register instance failed")

	// ErrUpdateInProgressOnInstance indicates that an update is currently in
	// progress on the instance requesting an update package, so the request
	// will be rejected.
	ErrUpdateInProgressOnInstance = errors.New("nebraska: update in progress on instance")

	// ErrNoPackageFound indicates that the group doesn't have a channel
	// assigned or that the channel doesn't have a package assigned.
	ErrNoPackageFound = errors.New("nebraska: no package found")

	// ErrNoUpdatePackageAvailable indicates that the instance requesting the
	// update has already the latest version of the application.
	ErrNoUpdatePackageAvailable = errors.New("nebraska: no update package available")

	// ErrUpdatesDisabled indicates that updates are not enabled in the group.
	ErrUpdatesDisabled = errors.New("nebraska: updates disabled")

	// ErrGetUpdatesStatsFailed indicates that there was a problem getting the
	// updates stats of the group which are needed to enforce the rollout
	// policy.
	ErrGetUpdatesStatsFailed = errors.New("nebraska: get updates stats failed")

	// ErrMaxUpdatesPerPeriodLimitReached indicates that the maximum number of
	// updates per period has been reached.
	ErrMaxUpdatesPerPeriodLimitReached = errors.New("nebraska: max updates per period limit reached")

	// ErrMaxConcurrentUpdatesLimitReached indicates that the maximum number of
	// concurrent updates has been reached.
	ErrMaxConcurrentUpdatesLimitReached = errors.New("nebraska: max concurrent updates limit reached")

	// ErrMaxTimedOutUpdatesLimitReached indicates that limit of instances that
	// timed out while updating has been reached.
	ErrMaxTimedOutUpdatesLimitReached = errors.New("nebraska: max timed out updates limit reached")

	// ErrGrantingUpdate indicates that something went wrong while granting an
	// update.
	ErrGrantingUpdate = errors.New("nebraska: error granting update")
)
View Source
var (
	// ErrBlacklistingChannel error indicates that the channel the package is
	// trying to blacklist is already pointing to the package.
	ErrBlacklistingChannel = errors.New("nebraska: channel trying to blacklist is already pointing to the package")
)
View Source
var (
	// ErrUpdatingPassword indicates that something went wrong while updating
	// the user's password.
	ErrUpdatingPassword = errors.New("nebraska: error updating password")
)

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDigest

func AssetDigest(name string) ([sha256.Size]byte, error)

AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"}, AssetDir("data/img") would return []string{"a.png", "b.png"}, AssetDir("foo.txt") and AssetDir("notexist") would return an error, and AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func AssetString

func AssetString(name string) (string, error)

AssetString returns the asset contents as a string (instead of a []byte).

func Digests

func Digests() (map[string][sha256.Size]byte, error)

Digests returns a map of all known files and their checksums.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func MustAssetString

func MustAssetString(name string) string

MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.

func OptionDisableUpdatesOnFailedRollout

func OptionDisableUpdatesOnFailedRollout(api *API) error

OptionDisableUpdatesOnFailedRollout will modify API to disable updates on failed rollout.

func OptionInitDB

func OptionInitDB(api *API) error

OptionInitDB will initialize the database during the API instance creation, dropping all existing tables, which will force all migration scripts to be re-executed. Use with caution, this will DESTROY ALL YOUR DATA.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory.

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively.

Types

type API

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

API represents an api instance used to interact with Nebraska entities.

func New

func New(options ...func(*API) error) (*API, error)

New creates a new API instance, creates the underlying db connection.

func NewForTest

func NewForTest(options ...func(*API) error) (*API, error)

NewForTest creates a new API instance with given options and fills the database with sample data for testing purposes.

func NewWithMigrations

func NewWithMigrations(options ...func(*API) error) (*API, error)

NewWithMigrations creates a new API instance, creates the underlying db connection and applies all available db migrations.

func (*API) AddApp

func (api *API) AddApp(app *Application) (*Application, error)

AddApp registers the provided application.

func (*API) AddAppCloning

func (api *API) AddAppCloning(app *Application, sourceAppID string) (*Application, error)

AddAppCloning registers the provided application, cloning the groups and channels from an existing application. Channels' packages will be set to null as packages won't be cloned.

func (*API) AddChannel

func (api *API) AddChannel(channel *Channel) (*Channel, error)

AddChannel registers the provided channel.

func (*API) AddFlatcarAction

func (api *API) AddFlatcarAction(action *FlatcarAction) (*FlatcarAction, error)

AddFlatcarAction registers the provided Omaha Flatcar action.

func (*API) AddGroup

func (api *API) AddGroup(group *Group) (*Group, error)

AddGroup registers the provided group.

func (*API) AddPackage

func (api *API) AddPackage(pkg *Package) (*Package, error)

AddPackage registers the provided package.

func (*API) AddTeam

func (api *API) AddTeam(team *Team) (*Team, error)

AddTeam registers a team.

func (*API) AddUser

func (api *API) AddUser(user *User) (*User, error)

AddTeam registers a team.

func (*API) Close

func (api *API) Close()

Close releases the connections to the database.

func (*API) DbStats

func (api *API) DbStats() sql.DBStats

func (*API) DeleteApp

func (api *API) DeleteApp(appID string) error

DeleteApp removes the application identified by the id provided.

func (*API) DeleteChannel

func (api *API) DeleteChannel(channelID string) error

DeleteChannel removes the channel identified by the id provided.

func (*API) DeleteGroup

func (api *API) DeleteGroup(groupID string) error

DeleteGroup removes the group identified by the id provided.

func (*API) DeletePackage

func (api *API) DeletePackage(pkgID string) error

DeletePackage removes the package identified by the id provided.

func (*API) GenerateUserSecret

func (api *API) GenerateUserSecret(username, password string) (string, error)

GenerateUserSecret generates a md5 hash from the username and password provided (username:realm:password).

func (*API) GetActivity

func (api *API) GetActivity(teamID string, p ActivityQueryParams) ([]*Activity, error)

GetActivity returns a list of activity entries that match the specified criteria in the query parameters.

func (*API) GetActivityCount

func (api *API) GetActivityCount(teamID string, p ActivityQueryParams) (int, error)

Gets the activity count using some ActivityQueryParams filters Page and PerPage are ignored. Start is nil, then it defaults -3 days. End is nil, then it defaults to Now.

func (*API) GetApp

func (api *API) GetApp(appID string) (*Application, error)

GetApp returns the application identified by the id provided.

func (*API) GetAppID

func (api *API) GetAppID(appOrProductID string) (string, error)

func (*API) GetAppInstancesPerChannelMetrics

func (api *API) GetAppInstancesPerChannelMetrics() ([]AppInstancesPerChannelMetric, error)

func (*API) GetApps

func (api *API) GetApps(teamID string, page, perPage uint64) ([]*Application, error)

GetApps returns all applications that belong to the team id provided.

func (*API) GetAppsCount

func (api *API) GetAppsCount(teamID string) (int, error)

func (*API) GetChannel

func (api *API) GetChannel(channelID string) (*Channel, error)

GetChannel returns the channel identified by the id provided.

func (*API) GetChannels

func (api *API) GetChannels(appID string, page, perPage uint64) ([]*Channel, error)

GetChannels returns all channels associated to the application provided.

func (*API) GetChannelsCount

func (api *API) GetChannelsCount(appID string) (int, error)

GetChannelsCount retuns the total number of channels in an app

func (*API) GetCountQuery

func (api *API) GetCountQuery(query *goqu.SelectDataset) (int, error)

func (*API) GetDefaultInterval

func (api *API) GetDefaultInterval() time.Duration

GetDefaultInterval returns the default interval used for instance stats queries.

func (*API) GetEvent

func (api *API) GetEvent(instanceID string, appID string, timestamp time.Time) (null.String, error)

func (*API) GetFailedUpdatesMetrics

func (api *API) GetFailedUpdatesMetrics() ([]FailedUpdatesMetric, error)

func (*API) GetFlatcarAction

func (api *API) GetFlatcarAction(packageID string) (*FlatcarAction, error)

GetFlatcarAction returns the Flatcar action entry associated to the package id provided.

func (*API) GetGroup

func (api *API) GetGroup(groupID string) (*Group, error)

GetGroup returns the group identified by the id provided.

func (*API) GetGroupID

func (api *API) GetGroupID(appID, trackName string, arch Arch) (string, error)

GetGroupID returns the ID of the first group identified by the track name and the channel architecture. The track names should be unique in combination with the group's channel architecture but this is not enforced on the DB level and the newest entry wins.

func (*API) GetGroupInstancesStats

func (api *API) GetGroupInstancesStats(groupID, duration string) (*InstancesStatusStats, error)

getGroupInstancesStats returns a summary of the status of the instances that belong to a given group.

func (*API) GetGroupStatusCountTimeline

func (api *API) GetGroupStatusCountTimeline(groupID string, duration string) (map[time.Time](map[int](VersionCountMap)), error)

func (*API) GetGroupVersionBreakdown

func (api *API) GetGroupVersionBreakdown(groupID string) ([]*VersionBreakdownEntry, error)

GetGroupVersionBreakdown returns a version breakdown of all instances running on a given group.

func (*API) GetGroupVersionCountTimeline

func (api *API) GetGroupVersionCountTimeline(groupID string, duration string) (map[time.Time](VersionCountMap), bool, error)

This function computes instance version count form two different tables instance_application and instance_status_history. There are three types of instances that can exist. 1. Instances without any update history. 2. Instances which got updated in the duration(ie 30d,7d etc). 3. Instances that have updated but not in the duration. Here 1,3 doesn't contribute to growth or decline of the graph, they are straight lines in the graph. Based on this logic three queries are made concurrently and calculated to achieve the end result.

Query 1 generates the time series using the `generate_series` postgres function and groups the instances without any update history(ie instance_application without any matching instance_status_history entry) based on version.

Query 2 filters all instance_application with instance_status_history in the duration sorted desc by instance_id and created_ts So we have entries of instances_status_history based on the created_ts the count is increased for the corresponding versions in the corresponding spans programatically

Query 3 filters all instance without any instance_status_history in the duration and takes the latest version for each instance and groups them to give a base count for all the versions. These version count values are directly added to all spans.

func (*API) GetGroups

func (api *API) GetGroups(appID string, page, perPage uint64) ([]*Group, error)

GetGroups returns all groups that belong to the application provided.

func (*API) GetGroupsCount

func (api *API) GetGroupsCount(appID string) (int, error)

GetGroupsCount retuns the total number of groups in an app

func (*API) GetInstance

func (api *API) GetInstance(instanceID, appID string) (*Instance, error)

GetInstance returns the instance identified by the id provided.

func (*API) GetInstanceStats

func (api *API) GetInstanceStats() ([]InstanceStats, error)

GetInstanceStats returns an InstanceStats table with all instances that have been previously been checked in.

func (*API) GetInstanceStatsByTimestamp

func (api *API) GetInstanceStatsByTimestamp(t time.Time) ([]InstanceStats, error)

GetInstanceStatsByTimestamp returns an InstanceStats array of instances matching a given timestamp value, ordered by version.

func (*API) GetInstanceStatusHistory

func (api *API) GetInstanceStatusHistory(instanceID, appID, groupID string, limit uint64) ([]*InstanceStatusHistoryEntry, error)

GetInstanceStatusHistory returns the status history of an instance in the context of the application/group provided.

func (*API) GetInstances

func (api *API) GetInstances(p InstancesQueryParams, duration string) (InstancesWithTotal, error)

GetInstances returns all instances that match with the provided criteria.

func (*API) GetInstancesCount

func (api *API) GetInstancesCount(p InstancesQueryParams, duration string) (int, error)

func (*API) GetPackage

func (api *API) GetPackage(pkgID string) (*Package, error)

GetPackage returns the package identified by the id provided.

func (*API) GetPackageByVersionAndArch

func (api *API) GetPackageByVersionAndArch(appID, version string, arch Arch) (*Package, error)

GetPackageByVersionAndArch returns the package identified by the application ID, version and arch provided.

func (*API) GetPackages

func (api *API) GetPackages(appID string, page, perPage uint64, searchVersion *string) ([]*Package, error)

GetPackages returns all packages associated to the application provided.

func (*API) GetPackagesCount

func (api *API) GetPackagesCount(appID string, searchVersion *string) (int, error)

GetPackagesCount retuns the total number of package in an app

func (*API) GetTeam

func (api *API) GetTeam() (*Team, error)

func (*API) GetTeams

func (api *API) GetTeams() ([]*Team, error)

func (*API) GetUpdatePackage

func (api *API) GetUpdatePackage(instanceID, instanceAlias, instanceIP, instanceVersion, appID, groupID string) (*Package, error)

GetUpdatePackage returns an update package for the instance/application provided. The instance details and the application it's running will be registered in Nebraska (or updated if it's already registered).

func (*API) GetUser

func (api *API) GetUser(username string) (*User, error)

GetUser returns the user identified by the username provided.

func (*API) GetUsersInTeam

func (api *API) GetUsersInTeam(teamID string) ([]*User, error)

func (*API) MigrateDown

func (api *API) MigrateDown(version string) (int, error)

func (*API) RegisterEvent

func (api *API) RegisterEvent(instanceID, appID, groupID string, etype, eresult int, previousVersion, errorCode string) error

RegisterEvent registers an event posted by an instance in Nebraska. The event will be bound to an application/group combination.

func (*API) RegisterInstance

func (api *API) RegisterInstance(instanceID, instanceAlias, instanceIP, instanceVersion, appID, groupID string) (*Instance, error)

RegisterInstance registers an instance into Nebraska.

func (*API) UpdateApp

func (api *API) UpdateApp(app *Application) error

UpdateApp updates an existing application using the content of the application provided.

func (*API) UpdateChannel

func (api *API) UpdateChannel(channel *Channel) error

UpdateChannel updates an existing channel using the content of the channel provided.

func (*API) UpdateGroup

func (api *API) UpdateGroup(group *Group) error

UpdateGroup updates an existing group using the context of the group provided.

func (*API) UpdateInstance

func (api *API) UpdateInstance(instanceID string, alias string) (*Instance, error)

func (*API) UpdateInstanceStats

func (api *API) UpdateInstanceStats(t *time.Time, duration *time.Duration) error

UpdateInstanceStats updates the instance_stats table with instances checked in during a given duration from a given time.

func (*API) UpdatePackage

func (api *API) UpdatePackage(pkg *Package) error

UpdatePackage updates an existing package using the content of the package provided.

func (*API) UpdateTeam

func (api *API) UpdateTeam(team *Team) error

func (*API) UpdateUserPassword

func (api *API) UpdateUserPassword(username, newPassword string) error

UpdateUserPassword updates the password of the provided user.

type Activity

type Activity struct {
	ID              string      `db:"id" json:"id"`
	AppID           null.String `db:"application_id" json:"app_id"`
	GroupID         null.String `db:"group_id" json:"group_id"`
	CreatedTs       time.Time   `db:"created_ts" json:"created_ts"`
	Class           int         `db:"class" json:"class"`
	Severity        int         `db:"severity" json:"severity"`
	Version         string      `db:"version" json:"version"`
	ApplicationName string      `db:"application_name" json:"application_name"`
	GroupName       null.String `db:"group_name" json:"group_name"`
	ChannelName     null.String `db:"channel_name" json:"channel_name"`
	InstanceID      null.String `db:"instance_id" json:"instance_id"`
}

Activity represents a Nebraska activity entry.

type ActivityQueryParams

type ActivityQueryParams struct {
	AppID      string    `db:"application_id"`
	GroupID    string    `db:"group_id"`
	ChannelID  string    `db:"channel_id"`
	InstanceID string    `db:"instance_id"`
	Version    string    `db:"version"`
	Severity   int       `db:"severity"`
	Start      time.Time `db:"start"`
	End        time.Time `db:"end"`
	Page       uint64    `json:"page"`
	PerPage    uint64    `json:"perpage"`
}

ActivityQueryParams represents a helper structure used to pass a set of parameters when querying activity entries.

type AppInstancesPerChannelMetric

type AppInstancesPerChannelMetric struct {
	ApplicationName string `db:"app_name" json:"app_name"`
	Version         string `db:"version" json:"version"`
	ChannelName     string `db:"channel_name" json:"channel_name"`
	InstancesCount  int    `db:"instances_count" json:"instances_count"`
}

type Application

type Application struct {
	ID          string      `db:"id" json:"id"`
	ProductID   null.String `db:"product_id" json:"product_id"`
	Name        string      `db:"name" json:"name"`
	Description string      `db:"description" json:"description"`
	CreatedTs   time.Time   `db:"created_ts" json:"created_ts"`
	TeamID      string      `db:"team_id" json:"-"`
	Groups      []*Group    `db:"groups" json:"groups"`
	Channels    []*Channel  `db:"channels" json:"channels"`

	Instances struct {
		Count int `db:"count" json:"count"`
	} `db:"instances" json:"instances,omitempty"`
}

Application represents a Nebraska application instance.

type Arch

type Arch uint
const (
	ArchAll Arch = iota
	ArchAMD64
	ArchAArch64
	ArchX86
)

func ArchFromCoreosString

func ArchFromCoreosString(s string) (Arch, error)

func ArchFromOmahaString

func ArchFromOmahaString(s string) (Arch, error)

func ArchFromString

func ArchFromString(s string) (Arch, error)

func (Arch) CoreosString

func (a Arch) CoreosString() string

func (Arch) IsValid

func (a Arch) IsValid() bool

func (Arch) OmahaString

func (a Arch) OmahaString() string

func (Arch) String

func (a Arch) String() string

type Channel

type Channel struct {
	ID            string      `db:"id" json:"id"`
	Name          string      `db:"name" json:"name"`
	Color         string      `db:"color" json:"color"`
	CreatedTs     time.Time   `db:"created_ts" json:"created_ts"`
	ApplicationID string      `db:"application_id" json:"application_id"`
	PackageID     null.String `db:"package_id" json:"package_id"`
	Package       *Package    `db:"package" json:"package"`
	Arch          Arch        `db:"arch" json:"arch"`
}

Channel represents a Nebraska application's channel.

type Event

type Event struct {
	ID              int         `db:"id" json:"id"`
	CreatedTs       time.Time   `db:"created_ts" json:"created_ts"`
	PreviousVersion null.String `db:"previous_version" json:"previous_version"`
	ErrorCode       null.String `db:"error_code" json:"error_code"`
	InstanceID      string      `db:"instance_id" json:"instance_id"`
	ApplicationID   string      `db:"application_id" json:"application_id"`
	EventTypeID     string      `db:"event_type_id" json:"event_type_id"`
}

Event represents an event posted by an instance to Nebraska.

type FailedUpdatesMetric

type FailedUpdatesMetric struct {
	ApplicationName string `db:"app_name" json:"app_name"`
	FailureCount    int    `db:"fail_count" json:"fail_count"`
}

type File

type File struct {
	ID        int64       `db:"id" json:"id"`
	PackageID string      `db:"package_id" json:"package_id"`
	Name      null.String `db:"name" json:"name"`
	Size      null.String `db:"size" json:"size"`
	Hash      null.String `db:"hash" json:"hash"`
	Hash256   null.String `db:"hash256" json:"hash256"`
	CreatedTs time.Time   `db:"created_ts" json:"created_ts"`
}

func (File) Equals

func (f File) Equals(otherFile File) bool

type FlatcarAction

type FlatcarAction struct {
	ID                    string    `db:"id" json:"id"`
	Event                 string    `db:"event" json:"event"`
	ChromeOSVersion       string    `db:"chromeos_version" json:"chromeos_version"`
	Sha256                string    `db:"sha256" json:"sha256"`
	NeedsAdmin            bool      `db:"needs_admin" json:"needs_admin"`
	IsDelta               bool      `db:"is_delta" json:"is_delta"`
	DisablePayloadBackoff bool      `db:"disable_payload_backoff" json:"disable_payload_backoff"`
	MetadataSignatureRsa  string    `db:"metadata_signature_rsa" json:"metadata_signature_rsa"`
	MetadataSize          string    `db:"metadata_size" json:"metadata_size"`
	Deadline              string    `db:"deadline" json:"deadline"`
	CreatedTs             time.Time `db:"created_ts" json:"created_ts"`
	PackageID             string    `db:"package_id" json:"-"`
}

FlatcarAction represents an Omaha action with some Flatcar specific fields.

type Group

type Group struct {
	ID                        string      `db:"id" json:"id"`
	Name                      string      `db:"name" json:"name"`
	Description               string      `db:"description" json:"description"`
	CreatedTs                 time.Time   `db:"created_ts" json:"created_ts"`
	RolloutInProgress         bool        `db:"rollout_in_progress" json:"rollout_in_progress"`
	ApplicationID             string      `db:"application_id" json:"application_id"`
	ChannelID                 null.String `db:"channel_id" json:"channel_id"`
	PolicyUpdatesEnabled      bool        `db:"policy_updates_enabled" json:"policy_updates_enabled"`
	PolicySafeMode            bool        `db:"policy_safe_mode" json:"policy_safe_mode"`
	PolicyOfficeHours         bool        `db:"policy_office_hours" json:"policy_office_hours"`
	PolicyTimezone            null.String `db:"policy_timezone" json:"policy_timezone"`
	PolicyPeriodInterval      string      `db:"policy_period_interval" json:"policy_period_interval"`
	PolicyMaxUpdatesPerPeriod int         `db:"policy_max_updates_per_period" json:"policy_max_updates_per_period"`
	PolicyUpdateTimeout       string      `db:"policy_update_timeout" json:"policy_update_timeout"`
	Channel                   *Channel    `db:"channel" json:"channel,omitempty"`
	Track                     string      `db:"track" json:"track"`
}

Group represents a Nebraska application's group.

type GroupDescriptor

type GroupDescriptor struct {
	AppID string
	Track string
	Arch  Arch
}

type Instance

type Instance struct {
	ID          string              `db:"id" json:"id"`
	IP          string              `db:"ip" json:"ip"`
	CreatedTs   time.Time           `db:"created_ts" json:"created_ts"`
	Application InstanceApplication `db:"application" json:"application,omitempty"`
	Alias       string              `db:"alias" json:"alias,omitempty"`
}

Instance represents an instance running one or more applications for which Nebraska can provide updates.

type InstanceApplication

type InstanceApplication struct {
	InstanceID          string      `db:"instance_id" json:"instance_id,omitempty"`
	ApplicationID       string      `db:"application_id" json:"application_id"`
	GroupID             null.String `db:"group_id" json:"group_id"`
	Version             string      `db:"version" json:"version"`
	CreatedTs           time.Time   `db:"created_ts" json:"created_ts"`
	Status              null.Int    `db:"status" json:"status"`
	LastCheckForUpdates time.Time   `db:"last_check_for_updates" json:"last_check_for_updates"`
	LastUpdateGrantedTs null.Time   `db:"last_update_granted_ts" json:"last_update_granted_ts"`
	LastUpdateVersion   null.String `db:"last_update_version" json:"last_update_version"`
	UpdateInProgress    bool        `db:"update_in_progress" json:"update_in_progress"`
}

InstanceApplication represents some details about an application running on a given instance: current version of the app, last time the instance checked for updates for this app, etc.

type InstanceStats

type InstanceStats struct {
	Timestamp   time.Time `db:"timestamp" json:"timestamp"`
	ChannelName string    `db:"channel_name" json:"channel_name"`
	Arch        string    `db:"arch" json:"arch"`
	Version     string    `db:"version" json:"version"`
	Instances   int       `db:"instances" json:"instances"`
}

type InstanceStatusHistoryEntry

type InstanceStatusHistoryEntry struct {
	ID            int         `db:"id" json:"-"`
	Status        int         `db:"status" json:"status"`
	Version       string      `db:"version" json:"version"`
	CreatedTs     time.Time   `db:"created_ts" json:"created_ts"`
	InstanceID    string      `db:"instance_id" json:"-"`
	ApplicationID string      `db:"application_id" json:"-"`
	GroupID       string      `db:"group_id" json:"-"`
	ErrorCode     null.String `db:"error_code" json:"error_code"`
}

InstanceStatusHistoryEntry represents an entry in the instance status history.

type InstancesQueryParams

type InstancesQueryParams struct {
	ApplicationID string `json:"application_id"`
	GroupID       string `json:"group_id"`
	Status        int    `json:"status"`
	Version       string `json:"version"`
	Page          uint64 `json:"page"`
	PerPage       uint64 `json:"perpage"`
	SortFilter    string `json:"sort_filter"`
	SortOrder     string `json:"sort_order"`
	SearchFilter  string `json:"search_filter"`
	SearchValue   string `json:"search_value"`
}

InstancesQueryParams represents a helper structure used to pass a set of parameters when querying instances.

type InstancesStatusStats

type InstancesStatusStats struct {
	Total         int      `db:"total" json:"total"`
	Undefined     null.Int `db:"undefined" json:"undefined"`
	UpdateGranted null.Int `db:"update_granted" json:"update_granted"`
	Error         null.Int `db:"error" json:"error"`
	Complete      null.Int `db:"complete" json:"complete"`
	Installed     null.Int `db:"installed" json:"installed"`
	Downloaded    null.Int `db:"downloaded" json:"downloaded"`
	Downloading   null.Int `db:"downloading" json:"downloading"`
	OnHold        null.Int `db:"onhold" json:"onhold"`
}

InstancesStatusStats represents a set of statistics about the status of the instances that belong to a given group.

type InstancesWithTotal

type InstancesWithTotal struct {
	TotalInstances uint64      `json:"total"`
	Instances      []*Instance `json:"instances"`
}

type Package

type Package struct {
	ID                string         `db:"id" json:"id"`
	Type              int            `db:"type" json:"type"`
	Version           string         `db:"version" json:"version"`
	URL               string         `db:"url" json:"url"`
	Filename          null.String    `db:"filename" json:"filename"`
	Description       null.String    `db:"description" json:"description"`
	Size              null.String    `db:"size" json:"size"`
	Hash              null.String    `db:"hash" json:"hash"`
	CreatedTs         time.Time      `db:"created_ts" json:"created_ts"`
	ChannelsBlacklist StringArray    `db:"channels_blacklist" json:"channels_blacklist"`
	ApplicationID     string         `db:"application_id" json:"application_id"`
	FlatcarAction     *FlatcarAction `db:"flatcar_action" json:"flatcar_action"`
	Arch              Arch           `db:"arch" json:"arch"`
	ExtraFiles        []File         `db:"extra_files" json:"extra_files"`
}

Package represents a Nebraska application's package.

type StatusVersionCountTimelineEntry

type StatusVersionCountTimelineEntry struct {
	Time    time.Time `db:"ts" json:"time"`
	Status  int       `db:"status" json:"status"`
	Version string    `db:"version" json:"version"`
	Total   uint64    `db:"total" json:"total"`
}

type StringArray

type StringArray []string

StringArray represents a one-dimensional array of the PostgreSQL character types.

func (*StringArray) Scan

func (a *StringArray) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

type Team

type Team struct {
	ID        string    `db:"id"`
	Name      string    `db:"name"`
	CreatedTs time.Time `db:"created_ts"`
}

Team represents a Nebraska team.

type UpdatesStats

type UpdatesStats struct {
	TotalInstances                   int `db:"total_instances"`
	UpdatesToCurrentVersionGranted   int `db:"updates_to_current_version_granted"`
	UpdatesToCurrentVersionAttempted int `db:"updates_to_current_version_attempted"`
	UpdatesToCurrentVersionSucceeded int `db:"updates_to_current_version_succeeded"`
	UpdatesToCurrentVersionFailed    int `db:"updates_to_current_version_failed"`
	UpdatesGrantedInLastPeriod       int `db:"updates_granted_in_last_period"`
	UpdatesInProgress                int `db:"updates_in_progress"`
	UpdatesTimedOut                  int `db:"updates_timed_out"`
}

UpdatesStats represents a set of statistics about the status of the updates that may be taking place in the instaces belonging to a given group.

type User

type User struct {
	ID        string    `db:"id" json:"id"`             // UUID v4 unique, created automatically
	Username  string    `db:"username" json:"username"` // unique username
	Secret    string    `db:"secret" json:"secret"`     // md5 hash from (username:realm:password)
	CreatedTs time.Time `db:"created_ts" json:"-"`      // Created automatically
	TeamID    string    `db:"team_id" json:"team_id"`   // User can be in single team
}

User represents a Nebraska user.

type VersionBreakdownEntry

type VersionBreakdownEntry struct {
	Version    string  `db:"version" json:"version"`
	Instances  int     `db:"instances" json:"instances"`
	Percentage float64 `db:"percentage" json:"percentage"`
}

VersionBreakdownEntry represents the distribution of the versions currently installed in the instances belonging to a given group.

type VersionCountMap

type VersionCountMap = map[string]uint64

type VersionCountTimelineEntry

type VersionCountTimelineEntry struct {
	Time    time.Time `db:"ts" json:"time"`
	Version string    `db:"version" json:"version"`
	Total   uint64    `db:"total" json:"total"`
}

Jump to

Keyboard shortcuts

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