model

package
v0.0.0-...-2cc3bea Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package model package model contains Datastore models Config Service uses.

Index

Constants

View Source
const (
	// ConfigSetKind is the Datastore entity kind for ConfigSet.
	ConfigSetKind = "ConfigSetV2"

	// RevisionKind is the Datastore entity kind for Revision.
	RevisionKind = "RevisionV2"

	// FileKind is the Datastore entity kind for File.
	FileKind = "FileV2"

	// ImportAttemptKind is the Datastore entity kind for ImportAttempt.
	ImportAttemptKind = "ImportAttemptV2"

	// ServiceKind is the Datastore entity kind for Service.
	ServiceKind = "Service"

	// CurrentCfgSetVersion is a global version for all ConfigSet entities. It can
	// be used to force a global refresh.
	CurrentCfgSetVersion = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigSet

type ConfigSet struct {

	// ID is the name of a config set.
	// Examples: services/luci-config, projects/chromium.
	ID config.Set `gae:"$id"`

	// LatestRevision contains the latest revision info for this ConfigSet.
	LatestRevision RevisionInfo `gae:"latest_revision"`
	// Location is the source location which points the root of this ConfigSet.
	Location *cfgcommonpb.Location `gae:"location"`
	// Version is the global version of the config set.
	// It may be used to decide to force a refresh.
	Version int64 `gae:"version,noindex"`
	// contains filtered or unexported fields
}

ConfigSet is a versioned collection of config files.

func (*ConfigSet) Load

func (cs *ConfigSet) Load(p datastore.PropertyMap) error

Load implements datastore.PropertyLoadSaver.

func (*ConfigSet) Save

func (cs *ConfigSet) Save(withMeta bool) (datastore.PropertyMap, error)

Save implements datastore.PropertyLoadSaver. It makes sure ConfigSet.Version always set to CurrentCfgSetVersion when saving into Datastore.

type File

type File struct {

	//  Path is the file path relative to its config set root path.
	Path string `gae:"$id"`
	// Revision is a key for parent Revision.
	Revision *datastore.Key `gae:"$parent"`
	// CreateTime is the timestamp when this File entity is imported.
	CreateTime time.Time `gae:"create_time,noindex"`
	// Content is the gzipped raw content of the small config file.
	Content []byte `gae:"content,noindex"`
	// GcsURI is a Google Cloud Storage URI where it stores large gzipped file.
	// The format is "gs://<bucket>/<object_name>"
	// Note: Either Content field or GcsUri field will be set, but not both.
	GcsURI gs.Path `gae:"gcs_uri,noindex"`
	// ContentSHA256 is the SHA256 hash of the file content.
	ContentSHA256 string `gae:"content_sha256"`
	// Size is the raw file size in bytes.
	Size int64 `gae:"size,noindex"`
	// Location is a pinned, fully resolved source location to this file.
	Location *cfgcommonpb.Location `gae:"location"`
	// contains filtered or unexported fields
}

File represents a single config file. Immutable.

TODO(vadimsh): `Content` can be moved to a child entity to allow listing file metadata without pulling large blob from the datastore. This will be useful in GetConfigSet and DeleteStaleConfigs implementations.

func GetConfigFileByHash

func GetConfigFileByHash(ctx context.Context, configSet config.Set, contentSha256 string) (*File, error)

GetConfigFileByHash fetches a file entity by content hash for the given config set. If multiple file entities are found, the most recently created one will be returned.

Returns NoSuchConfigError when the matching file can not be found in the storage.

func GetLatestConfigFile

func GetLatestConfigFile(ctx context.Context, configSet config.Set, filePath string) (*File, error)

GetLatestConfigFile returns the latest File entity as is for the given config set.

Returns NoSuchConfigError when the config set or file can not be found.

func (*File) GetGSPath

func (f *File) GetGSPath() gs.Path

GetGSPath returns the GCS path to where the config file is stored.

func (*File) GetPath

func (f *File) GetPath() string

GetPath returns that path to the File.

func (*File) GetRawContent

func (f *File) GetRawContent(ctx context.Context) ([]byte, error)

GetRawContent returns the raw and uncompressed content of this config.

May download content from Google Cloud Storage if content is not stored inside the entity due to its size. The result will be cached so the next GetRawContent call will not pay the cost to fetch and decompress.

type ImportAttempt

type ImportAttempt struct {

	// ID is always the string "last" because we only need last attempt info.
	ID string `gae:"$id,last"`

	// ConfigSet is a key for parent ConfigSet.
	ConfigSet *datastore.Key `gae:"$parent"`
	// Revision refers to the revision info.
	Revision RevisionInfo `gae:"revision,noindex"`
	// Success indicates whether this attempt is succeeded.
	Success bool `gae:"success,noindex"`
	// Message is a human-readable message about this import attempt.
	Message string `gae:"message,noindex"`
	// ValidationResult is the result of validating the config set.
	ValidationResult *cfgcommonpb.ValidationResult `gae:"validation_result"`
	// contains filtered or unexported fields
}

ImportAttempt describes what happened last time we tried to import a config set.

type NoSuchConfigError

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

NoSuchConfigError captures the error caused by unknown config set or file.

func (*NoSuchConfigError) Error

func (e *NoSuchConfigError) Error() string

Error implements error interface.

func (*NoSuchConfigError) IsUnknownConfigSet

func (e *NoSuchConfigError) IsUnknownConfigSet() bool

IsUnknownConfigSet returns true the error is caused by unknown config set.

func (*NoSuchConfigError) IsUnknownFile

func (e *NoSuchConfigError) IsUnknownFile() bool

IsUnknownFile returns true the error is caused by unknown file name.

func (*NoSuchConfigError) IsUnknownFileHash

func (e *NoSuchConfigError) IsUnknownFileHash() bool

IsUnknownFile returns true the error is caused by unknown file hash.

type RevisionInfo

type RevisionInfo struct {
	// ID is a revision name. If imported from Git, it is a commit hash.
	ID string `gae:"id"`
	// Location is a pinned location with revision info in the source repo.
	Location *cfgcommonpb.Location `gae:"location"`
	// CommitTime is the commit time of this revision.
	CommitTime time.Time `gae:"commit_time,noindex"`
	// CommitterEmail is the committer's email.
	CommitterEmail string `gae:"committer_email,noindex"`
	// AuthorEmail is the email of the commit author.
	AuthorEmail string `gae:"author_email,noindex"`
}

RevisionInfo contains a revision metadata. Referred by ConfigSet and ImportAttempt.

type Service

type Service struct {
	// Name is the name of the service.
	Name string `gae:"$id"`
	// Info contains information  for LUCI Config to interact with the service.
	Info *cfgcommonpb.Service `gae:"info"`
	// Metadata describes the metadata of a service.
	Metadata *cfgcommonpb.ServiceMetadata `gae:"metadata"`
	// LegacyMetadata is returned by the service that is still talking in
	// legacy LUCI Config protocol (i.e. REST based).
	//
	// TODO: crbug/1232565 - Remove this support once all backend services are
	// able to talk in the new LUCI Config protocol (i.e. expose
	// `cfgcommonpb.Consumer` interface)
	LegacyMetadata *cfgcommonpb.ServiceDynamicMetadata `gae:"legacy_metadata"`
	// UpdateTime is the time this entity is updated.
	UpdateTime time.Time `gae:"update_time"`
}

Service contains information about a registered service.

Jump to

Keyboard shortcuts

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