registry

package
v0.0.0-...-ec7abc8 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelA = iota
	LabelB
	LabelC
	LabelD
	LabelE
	LabelF
)

The label scores go from A to F.

View Source
const (
	DUCUserCiphered = "user_ciphered"
	DUCUserReserved = "user_reserved"
	DUCNone         = "none"
)

"DUC" stands for DataUserCommitment

View Source
const (
	DUCByCozy   = "cozy"
	DUCByEditor = "editor"
	DUCByNone   = "none"
)

"DUCBy" stands for DataUserCommitmentBy

Variables

View Source
var (
	ErrAppAlreadyExists  = errshttp.NewError(http.StatusConflict, "Application already exists")
	ErrAppNotFound       = errshttp.NewError(http.StatusNotFound, "Application was not found")
	ErrAppSlugMismatch   = errshttp.NewError(http.StatusBadRequest, "Application slug does not match the one specified in the body")
	ErrAppSlugInvalid    = errshttp.NewError(http.StatusBadRequest, "Invalid application slug: should contain only lowercase alphanumeric characters and dashes")
	ErrAppEditorMismatch = errshttp.NewError(http.StatusBadRequest, "Application can not be updated: editor can not change")

	ErrVersionAlreadyExists = errshttp.NewError(http.StatusConflict, "Version already exists")
	ErrVersionSlugMismatch  = errshttp.NewError(http.StatusBadRequest, "Version slug does not match the application")
	ErrVersionNotFound      = errshttp.NewError(http.StatusNotFound, "Version was not found")
	ErrVersionInvalid       = errshttp.NewError(http.StatusBadRequest, "Invalid version value")
	ErrChannelInvalid       = errshttp.NewError(http.StatusBadRequest, `Invalid version channel: should be "stable", "beta" or "dev"`)
)
View Source
var Channels = []Channel{Stable, Beta, Dev}

Functions

func ActivateMaintenanceApp

func ActivateMaintenanceApp(c *space.Space, appSlug string, opts MaintenanceOptions) error

func ActivateMaintenanceVirtualSpace

func ActivateMaintenanceVirtualSpace(virtualSpaceName, appSlug string, opts MaintenanceOptions) error

ActivateMaintenanceVirtualSpace tells that an app is in maintenance in the given virtual space.

func ChannelToStr

func ChannelToStr(channel Channel) string

ChannelToStr returns a string that describes the channel.

func CleanOldVersions

func CleanOldVersions(space *space.Space, appSlug, channel string, params base.CleanParameters, run RunType) error

CleanOldVersions removes a specific app version of a space

func CreatePendingVersion

func CreatePendingVersion(c *space.Space, ver *Version, attachments []*kivik.Attachment, app *App) error

func CreateReleaseVersion

func CreateReleaseVersion(c *space.Space, ver *Version, attachments []*kivik.Attachment, app *App, ensureVersion bool) (err error)

func DeactivateMaintenanceApp

func DeactivateMaintenanceApp(c *space.Space, appSlug string) error

func DeactivateMaintenanceVirtualSpace

func DeactivateMaintenanceVirtualSpace(virtualSpaceName, appSlug string) error

DeactivateMaintenanceVirtualSpace tells that an app is no longer in maintenance in the given virtual space.

func DeleteOverwrittenVersion

func DeleteOverwrittenVersion(s base.VirtualSpace, version *Version) error

func DeletePendingVersion

func DeletePendingVersion(c *space.Space, version *Version) error

func FindAppOverride

func FindAppOverride(virtualSpace *base.VirtualSpace, appSlug string, name string) (string, error)

FindAppOverride finds if the app have overwritten value in the virtual space

func GetSlugs

func GetSlugs(c *space.Space) ([]string, error)

func HandleAssets

func HandleAssets(tarball *Tarball, opts *VersionOptions) ([]*kivik.Attachment, error)

HandleAssets handles all the assets of the app tarball (icon, partnership icon, screenshots). Appened to attachments

func IsValidApp

func IsValidApp(app *AppOptions) error

func IsValidVersion

func IsValidVersion(ver *VersionOptions) error

func MoveAssetToGlobalDatabase

func MoveAssetToGlobalDatabase(c *space.Space, ver *Version, content []byte, filename, contentType string) error

MoveAssetToGlobalDatabase moves an asset located in the "local" container in the global database. This function is not intended to stay forever and will be removed when no more assets will be remaining in the app containers. It does the following steps: 1. Creating the new asset object in the global database 2. Adds a reference to the asset in the couch version document 3. Removes the old asset location

func OverwriteAppIcon

func OverwriteAppIcon(virtualSpaceName, appSlug, file string) error

OverwriteAppIcon tells that an app will have a different icon in the virtual space.

func OverwriteAppName

func OverwriteAppName(virtualSpaceName, appSlug, newName string) error

OverwriteAppName tells that an app will have a different name in the virtual space.

func RegenerateOverwrittenTarballs

func RegenerateOverwrittenTarballs(virtualSpaceName string, appSlug string) (err error)

func RemoveAppFromSpace

func RemoveAppFromSpace(s *space.Space, appSlug string) error

RemoveAppFromSpace deletes an application and all its versions from a space.

func RemoveSpace

func RemoveSpace(s *space.Space) error

RemoveSpace deletes CouchDB databases and Swift container for this space.

Types

type App

type App struct {
	ID  string `json:"_id,omitempty"`
	Rev string `json:"_rev,omitempty"`

	Slug      string    `json:"slug"`
	Type      string    `json:"type"`
	Editor    string    `json:"editor"`
	CreatedAt time.Time `json:"created_at"`

	MaintenanceActivated bool                `json:"maintenance_activated,omitempty"`
	MaintenanceOptions   *MaintenanceOptions `json:"maintenance_options,omitempty"`

	DataUsageCommitment   string `json:"data_usage_commitment"`
	DataUsageCommitmentBy string `json:"data_usage_commitment_by"`

	// Calculated fields, not present in the database
	Versions      *AppVersions `json:"versions,omitempty"`
	Label         Label        `json:"label"`
	LatestVersion *Version     `json:"latest_version,omitempty"`
}

func CreateApp

func CreateApp(c *space.Space, opts *AppOptions, editor *auth.Editor) (*App, error)

func FindApp

func FindApp(v *base.VirtualSpace, c *space.Space, appSlug string, channel Channel) (*App, error)

func GetAppsList

func GetAppsList(v *base.VirtualSpace, c *space.Space, opts *AppsListOptions) (int, []*App, error)

func GetMaintainanceApps

func GetMaintainanceApps(c *space.Space) ([]*App, error)

func ModifyApp

func ModifyApp(c *space.Space, appSlug string, opts AppOptions) (*App, error)

type AppOptions

type AppOptions struct {
	Slug   string `json:"slug"`
	Editor string `json:"editor"`
	Type   string `json:"type"`

	DataUsageCommitment   *string `json:"data_usage_commitment"`
	DataUsageCommitmentBy *string `json:"data_usage_commitment_by"`
}

type AppVersions

type AppVersions struct {
	HasVersions bool     `json:"has_versions"`
	Stable      []string `json:"stable,omitempty"`
	Beta        []string `json:"beta,omitempty"`
	Dev         []string `json:"dev,omitempty"`
}

func FindAppVersions

func FindAppVersions(c *space.Space, appSlug string, channel Channel, concat ConcatChannels) (*AppVersions, error)

FindAppVersions return all the app versions. The concat params allows you to concatenate stable & beta versions in dev list, and stable versions in beta list

func FindAppVersionsCacheMiss

func FindAppVersionsCacheMiss(c *space.Space, appSlug string, channel Channel, concat ConcatChannels) (*AppVersions, error)

func GetVersionsListFromCache

func GetVersionsListFromCache(c *space.Space, channelStr string, apps []*App) []*AppVersions

func (*AppVersions) GetAll

func (av *AppVersions) GetAll() []string

type AppsListOptions

type AppsListOptions struct {
	Limit                int
	Cursor               int
	Sort                 string
	Filters              map[string]string
	LatestVersionChannel Channel
	VersionsChannel      Channel
}

type Attachment

type Attachment struct {
	ContentType   string
	Content       io.Reader
	Etag          string
	ContentLength string
}

func FindAppAttachment

func FindAppAttachment(c *space.Space, appSlug, filename string, channel Channel) (*Attachment, error)

func FindAttachmentFromOverwrite

func FindAttachmentFromOverwrite(space *base.VirtualSpace, appSlug, filename string) (*Attachment, bool, error)

FindAttachmentFromOverwrite finds if the app was overwritten in the virtual space.

func FindOverwrittenTarball

func FindOverwrittenTarball(space *base.VirtualSpace, version *Version) (*Attachment, bool, error)

func FindVersionAttachment

func FindVersionAttachment(c *space.Space, version *Version, filename string) (*Attachment, error)

type Channel

type Channel int

Channel is a way to regroup versions of an application, in function of the expected stability.

const (
	Stable Channel = iota + 1
	Beta
	Dev
)

There are currently 3 channels: stable, beta, and dev.

func GetVersionChannel

func GetVersionChannel(version string) Channel

GetVersionChannel returns the channel in which a version is published.

func StrToChannel

func StrToChannel(channel string) (Channel, error)

StrToChannel returns the channel from a string.

type ConcatChannels

type ConcatChannels bool

ConcatChannels type

const (
	Concatenated    ConcatChannels = true
	NotConcatenated ConcatChannels = false
)

type Developer

type Developer struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

type Label

type Label int

Label is a score given to apps to show the trust a user can have in it.

type Locales

type Locales map[string]interface{}

type MaintenanceMessage

type MaintenanceMessage struct {
	LongMessage  string `json:"long_message"`
	ShortMessage string `json:"short_message"`
}

type MaintenanceOptions

type MaintenanceOptions struct {
	FlagInfraMaintenance   bool                          `json:"flag_infra_maintenance"`
	FlagShortMaintenance   bool                          `json:"flag_short_maintenance"`
	FlagDisallowManualExec bool                          `json:"flag_disallow_manual_exec"`
	Messages               map[string]MaintenanceMessage `json:"messages"`
}

type Manifest

type Manifest struct {
	Editor      string      `json:"editor"`
	Name        string      `json:"name"`
	Slug        string      `json:"slug"`
	Version     string      `json:"version"`
	Icon        string      `json:"icon"`
	Partnership Partnership `json:"partnership"`
	Screenshots []string    `json:"screenshots"`
	Locales     map[string]struct {
		Screenshots []string `json:"screenshots"`
	} `json:"locales"`
}

Manifest type contains a subset of the attributes contained in the manifest of applications. It is only here to help us reading some informations from the manifest that are useful to us, without manipulating maps.

func ReadTarballManifest

func ReadTarballManifest(tr io.Reader, url string) (*Manifest, []byte, map[string]interface{}, error)

ReadTarballManifest handles the tarball manifest. It checks if the manifest exists, is valid JSON and tries to load it to the Manifest struct

type Partnership

type Partnership struct {
	Icon        string `json:"icon,omitempty"`
	Description string `json:"description,omitempty"`
}

type Platform

type Platform struct {
	Type string `json:"type"`
	URL  string `json:"url"`
}

type RunType

type RunType bool

RunType is the type for telling if it's a dry run or a real one.

const (
	// DryRun will just simulate the job and tell what would happen with a real
	// run.
	DryRun RunType = true
	// RealRun will really delete the old versions.
	RealRun RunType = false
)

type Tarball

type Tarball struct {
	Manifest        *Manifest
	ManifestContent []byte
	ManifestMap     map[string]interface{}
	PackageVersion  string
	HasPrefix       bool
	TarPrefix       string
	ContentType     string
	AppType         string
	Content         []byte
	URL             string
	Size            int64
}

Tarball holds all the data from a downloaded app version

func ReadTarballVersion

func ReadTarballVersion(reader io.Reader, contentType, url string) (*Tarball, error)

ReadTarballVersion reads the content of the version tarball which has been downloaded. It reads the tarball to check if an app prefix exists, ensure that the manifest and the package.json (if exists) files are correct, and eventually returns a Tarball struct that holds these informations for the next steps

func (*Tarball) CheckEditor

func (t *Tarball) CheckEditor() (bool, error)

CheckEditor validates a tarball manifest editor

func (*Tarball) CheckSlug

func (t *Tarball) CheckSlug() (bool, error)

CheckEditor validates a tarball manifest slug

func (*Tarball) CheckVersion

func (t *Tarball) CheckVersion(expectedVersion string) (bool, error)

CheckVersion controls the matching versions between retrieved tarball and options

type Version

type Version struct {
	ID  string `json:"_id,omitempty"`
	Rev string `json:"_rev,omitempty"`

	AttachmentReferences map[string]string `json:"attachments"`
	Slug                 string            `json:"slug"`
	Editor               string            `json:"editor"`
	Type                 string            `json:"type"`
	Version              string            `json:"version"`
	Manifest             json.RawMessage   `json:"manifest"`
	CreatedAt            time.Time         `json:"created_at"`
	URL                  string            `json:"url"`
	Size                 int64             `json:"size,string"`
	Sha256               string            `json:"sha256"`
	TarPrefix            string            `json:"tar_prefix"`
}

func ApprovePendingVersion

func ApprovePendingVersion(c *space.Space, pending *Version, app *App) (*Version, error)

func DownloadVersion

func DownloadVersion(opts *VersionOptions) (*Version, []*kivik.Attachment, error)

func FindLastNVersions

func FindLastNVersions(c *space.Space, appSlug string, channelStr string, nMajor, nMinor int) ([]*Version, error)

FindLastNVersions returns the N lasts versions of an app If N is greater than available versions, only available are returned

func FindLastsVersionsSince

func FindLastsVersionsSince(c *space.Space, appSlug, channel string, date time.Time) ([]*Version, error)

FindLastsVersionsSince returns versions of a channel up to a date

Example: FindLastsVersionSince("foo", "stable", myDate) returns all the versions created beetween myDate and now

func FindLatestVersion

func FindLatestVersion(c *space.Space, appSlug string, channel Channel) (*Version, error)

func FindLatestVersionCacheMiss

func FindLatestVersionCacheMiss(v *base.VirtualSpace, c *space.Space, appSlug string, channel Channel) (*Version, error)

func FindLatestVersionWithOverride

func FindLatestVersionWithOverride(v *base.VirtualSpace, c *space.Space, appSlug string, channel Channel) (*Version, error)

func FindOverwrittenVersion

func FindOverwrittenVersion(space *base.VirtualSpace, version *Version) (*Version, error)

func FindPendingVersion

func FindPendingVersion(c *space.Space, appSlug, version string) (*Version, error)

func FindPublishedVersion

func FindPublishedVersion(c *space.Space, appSlug, version string) (*Version, error)

func FindVersion

func FindVersion(c *space.Space, appSlug, version string) (*Version, error)

func GetAppChannelVersions

func GetAppChannelVersions(c *space.Space, appSlug string, channel Channel) ([]*Version, error)

GetAppChannelVersions returns the versions list of an app channel

func GetAppPengindVersions

func GetAppPengindVersions(c *space.Space, appSlug string) ([]*Version, error)

func GetPendingVersions

func GetPendingVersions(c *space.Space) ([]*Version, error)

func GetVersionsLatestFromCache

func GetVersionsLatestFromCache(c *space.Space, channelStr string, apps []*App) []*Version

func (*Version) Clone

func (version *Version) Clone() *Version

func (*Version) Delete

func (v *Version) Delete(c *space.Space) error

Expire function deletes a version from the database

func (*Version) RemoveAllAttachments

func (v *Version) RemoveAllAttachments(c *space.Space) error

RemoveAllAttachments removes all the attachments of a version

type VersionOptions

type VersionOptions struct {
	Version     string          `json:"version"`
	URL         string          `json:"url"`
	Sha256      string          `json:"sha256"`
	Parameters  json.RawMessage `json:"parameters"`
	Icon        string          `json:"icon"`
	Partnership Partnership     `json:"partnership"`
	Screenshots []string        `json:"screenshots"`
	SpacePrefix base.Prefix
	RegistryURL *url.URL
}

Jump to

Keyboard shortcuts

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