common

package
v0.4.44 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppManagementServiceName = "app-management"
	AppManagementVersion     = "0.4.19"

	AppsDirectoryName = "Apps"

	ComposeAppAuthorCasaOSTeam = "CasaOS Team"

	ComposeExtensionNameXCasaOS                = "x-casaos"
	ComposeExtensionPropertyNameStoreAppID     = "store_app_id"
	ComposeExtensionPropertyNameTitle          = "title"
	ComposeExtensionPropertyNameIsUncontrolled = "is_uncontrolled"

	ComposeYAMLFileName = "docker-compose.yml"

	ContainerLabelV1AppStoreID = "io.casaos.v1.app.store.id"

	DefaultCategoryFont = "grid"
	DefaultLanguage     = "en_us"
	DefaultPassword     = "casaos"
	DefaultPGID         = "1000"
	DefaultPUID         = "1000"
	DefaultUserName     = "admin"

	Localhost           = "127.0.0.1"
	MIMEApplicationYAML = "application/yaml"

	CategoryListFileName  = "category-list.json"
	RecommendListFileName = "recommend-list.json"
)

Variables

View Source
var (
	PropertyTypeAppName = message_bus.PropertyType{
		Name:        "app:name",
		Description: utils.Ptr("name of the app which could be a container image name including version, a snap name or the name of any other forms of app"),
		Example:     utils.Ptr("hello-world:latest (this is the name of a container image"),
	}

	PropertyTypeAppTitle = message_bus.PropertyType{
		Name:        "app:title",
		Description: utils.Ptr("titles of the app in different languages - serialized as JSON"),
		Example:     utils.Ptr("{\"en_us\":\"OpenSpeedTest\"}"),
	}

	PropertyTypeAppIcon = message_bus.PropertyType{
		Name:        "app:icon",
		Description: utils.Ptr("icon of the app"),
		Example:     utils.Ptr("https://example.com/icon.png"),
	}

	PropertyTypeAppProgress = message_bus.PropertyType{
		Name:        "app:progress",
		Description: utils.Ptr("progress of the app"),
		Example:     utils.Ptr("64"),
	}

	PropertyTypeCheckPortConflict = message_bus.PropertyType{
		Name:        "check_port_conflict",
		Description: utils.Ptr("todo: the field should be remove in future. it is not need for most message"),
		Example:     utils.Ptr("true"),
	}

	PropertyTypeDryRun = message_bus.PropertyType{
		Name:        "dry_run",
		Description: utils.Ptr("todo: the field should be remove in future. it is not need for most message"),
		Example:     utils.Ptr("false"),
	}
)

app properties

View Source
var (
	PropertyTypeContainerID = message_bus.PropertyType{
		Name:        "docker:container:id",
		Description: utils.Ptr("ID of the container"),
		Example:     utils.Ptr("855084f79fc89bea4de5111c69621b3329ecf0a1106863a7a83bbdef01d33b9e"),
	}

	PropertyTypeContainerName = message_bus.PropertyType{
		Name:        "docker:container:name",
		Description: utils.Ptr("name of the container"),
		Example:     utils.Ptr("hello-world"),
	}
)

container properties

View Source
var (
	PropertyTypeImageName = message_bus.PropertyType{
		Name:        "docker:image:name",
		Description: utils.Ptr("name of the image"),
		Example:     utils.Ptr("hello-world:latest"),
	}

	PropertyTypeImageUpdated = message_bus.PropertyType{
		Name:        "docker:image:updated",
		Description: utils.Ptr("true if a newer image was pulled, false if the check found none. Absent when no check completed: a failed pull says nothing either way."),
	}
)

image properties

View Source
var (
	PropertyTypeBackupDestination = message_bus.PropertyType{
		Name:        "backup:destination",
		Description: utils.Ptr("name of the destination a backup goes to or comes from"),
		Example:     utils.Ptr("offsite"),
	}
	PropertyTypeBackupStamp = message_bus.PropertyType{
		Name:        "backup:stamp",
		Description: utils.Ptr("which run, as the run log names it"),
		Example:     utils.Ptr("2026-09-13T02-29-56Z"),
	}
	// PropertyTypeBackupKind tells a backup from a restore: the same four events
	// carry both, since a dashboard shows both the same way.
	PropertyTypeBackupKind = message_bus.PropertyType{
		Name:        "backup:kind",
		Description: utils.Ptr("`backup` or `restore`"),
		Example:     utils.Ptr("backup"),
	}
)

backup properties

View Source
var (
	EventTypeAppStoreRegisterBegin = message_bus.EventType{
		SourceID:         AppManagementServiceName,
		Name:             "app-store:register-begin",
		PropertyTypeList: []message_bus.PropertyType{},
	}

	EventTypeAppStoreRegisterEnd = message_bus.EventType{
		SourceID:         AppManagementServiceName,
		Name:             "app-store:register-end",
		PropertyTypeList: []message_bus.PropertyType{},
	}

	EventTypeAppStoreRegisterError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app-store:register-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeMessage,
		},
	}
)

event types for app-store

View Source
var (
	EventTypeAppInstallBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:install-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeAppIcon,
		},
	}

	EventTypeAppInstallProgress = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:install-progress",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeAppIcon,
			PropertyTypeAppProgress,
			PropertyTypeAppTitle,
			PropertyTypeCheckPortConflict,
			PropertyTypeDryRun,
		},
	}

	EventTypeAppInstallEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:install-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeAppIcon,
		},
	}

	EventTypeAppInstallError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:install-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeAppIcon,
			PropertyTypeMessage,
		},
	}

	EventTypeAppUninstallBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:uninstall-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeAppUninstallEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:uninstall-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeAppUninstallError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:uninstall-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeMessage,
		},
	}

	EventTypeAppUpdateBegin = message_bus.EventType{
		SourceID:         AppManagementServiceName,
		Name:             "app:update-begin",
		PropertyTypeList: []message_bus.PropertyType{},
	}

	EventTypeAppUpdateEnd = message_bus.EventType{
		SourceID:         AppManagementServiceName,
		Name:             "app:update-end",
		PropertyTypeList: []message_bus.PropertyType{},
	}

	EventTypeAppUpdateError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:update-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeMessage,
		},
	}

	// A backup or a restore, from start to end. Progress is one event per
	// operation rather than per byte: what a person watching wants to know is
	// which folder it is on and how many are left, and rclone's own transfer
	// statistics are a job away for anyone who wants bytes.
	EventTypeBackupBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "backup:begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName, PropertyTypeAppTitle, PropertyTypeAppIcon,
			PropertyTypeBackupDestination, PropertyTypeBackupStamp, PropertyTypeBackupKind,
		},
	}

	EventTypeBackupProgress = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "backup:progress",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName, PropertyTypeAppTitle, PropertyTypeAppIcon,
			PropertyTypeBackupDestination, PropertyTypeBackupStamp, PropertyTypeBackupKind,
			PropertyTypeAppProgress, PropertyTypeMessage,
		},
	}

	EventTypeBackupEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "backup:end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName, PropertyTypeAppTitle, PropertyTypeAppIcon,
			PropertyTypeBackupDestination, PropertyTypeBackupStamp, PropertyTypeBackupKind,
		},
	}

	EventTypeBackupError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "backup:error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName, PropertyTypeAppTitle, PropertyTypeAppIcon,
			PropertyTypeBackupDestination, PropertyTypeBackupStamp, PropertyTypeBackupKind,
			PropertyTypeMessage,
		},
	}

	EventTypeAppApplyChangesBegin = message_bus.EventType{
		SourceID:         AppManagementServiceName,
		Name:             "app:apply-changes-begin",
		PropertyTypeList: []message_bus.PropertyType{},
	}

	EventTypeAppApplyChangesEnd = message_bus.EventType{
		SourceID:         AppManagementServiceName,
		Name:             "app:apply-changes-end",
		PropertyTypeList: []message_bus.PropertyType{},
	}

	EventTypeAppApplyChangesError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:apply-changes-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeMessage,
		},
	}

	EventTypeAppStartBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:start-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeAppStartEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:start-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeAppStartError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:start-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeMessage,
		},
	}

	EventTypeAppStopBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:stop-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeAppStopEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:stop-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeAppStopError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:stop-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeMessage,
		},
	}

	EventTypeAppRestartBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:restart-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeAppRestartEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:restart-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeAppRestartError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "app:restart-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeMessage,
		},
	}
)

event types for app

View Source
var (
	EventTypeImagePullBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:image:pull-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeImagePullProgress = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:image:pull-progress",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeMessage,
		},
	}

	EventTypeImagePullEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:image:pull-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeImageUpdated,
		},
	}

	EventTypeImagePullError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:image:pull-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeMessage,
		},
	}

	EventTypeImageRemoveBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:image:remove-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeImageRemoveEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:image:remove-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
		},
	}

	EventTypeImageRemoveError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:image:remove-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeAppName,
			PropertyTypeMessage,
		},
	}
)

event types for image

View Source
var (
	EventTypeContainerCreateBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:create-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerName,
		},
	}

	EventTypeContainerCreateEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:create-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
			PropertyTypeContainerName,
		},
	}

	EventTypeContainerCreateError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:create-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerName,
			PropertyTypeMessage,
		},
	}

	EventTypeContainerStartBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:start-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
		},
	}

	EventTypeContainerStartEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:start-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
		},
	}

	EventTypeContainerStartError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:start-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
			PropertyTypeMessage,
		},
	}

	EventTypeContainerStopBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:stop-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
		},
	}

	EventTypeContainerStopEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:stop-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
		},
	}

	EventTypeContainerStopError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:stop-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
			PropertyTypeMessage,
		},
	}

	EventTypeContainerRenameBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:rename-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
			PropertyTypeContainerName,
		},
	}

	EventTypeContainerRenameEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:rename-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
			PropertyTypeContainerName,
		},
	}

	EventTypeContainerRenameError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:rename-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
			PropertyTypeContainerName,
			PropertyTypeMessage,
		},
	}

	EventTypeContainerRemoveBegin = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:remove-begin",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
		},
	}

	EventTypeContainerRemoveEnd = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:remove-end",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
		},
	}

	EventTypeContainerRemoveError = message_bus.EventType{
		SourceID: AppManagementServiceName,
		Name:     "docker:container:remove-error",
		PropertyTypeList: []message_bus.PropertyType{
			PropertyTypeContainerID,
			PropertyTypeMessage,
		},
	}
)

event types for container

View Source
var NeedCheckDigestTags = []string{
	"latest", "stable", "edge", "beta", "alpha",
	"main", "master", "develop", "dev",
	"nightly", "canary", "rolling", "unstable", "testing", "preview", "insiders",
}

Tags that name a STREAM rather than a version: the same name is republished as new images are built, so the name says nothing about which image is running and only the digest can tell whether it moved.

This list decides three things, and they have to agree or the dashboard contradicts itself: whether an update rewrites the image in a compose file, whether a differing image counts as an update being available, and which version the upgradable list shows.

It held "latest" alone, next to an upstream note saying more could be added. Everything else -- an app tracking `develop`, `nightly`, `edge` -- was read as a pinned version, so an update replaced the owner's choice of stream with whatever fixed tag the catalogue named.

Being wrong in the inclusive direction is cheap: a tag listed here that is really a version means the compose file keeps the reference it has and the pull is what moves it, which is what a pull does anyway. Being wrong the other way silently un-picks somebody's choice.

View Source
var (
	// PropertyTypeAppUpdated is set only when an update actually replaced what the app
	// runs. Absent means it did not: nothing newer, nothing checked, or it failed --
	// app:update-error carries the reason when there is one.
	PropertyTypeAppUpdated = message_bus.PropertyType{
		Name:        "app:updated",
		Description: utils.Ptr("true if the app now runs what the update installed"),
	}
)

app update properties

View Source
var (
	PropertyTypeMessage = message_bus.PropertyType{
		Name:        "message",
		Description: utils.Ptr("message at different levels, typically for error"),
	}
)

common properties

View Source
var SampleCategoryListJSON string
View Source
var SampleComposeAppYAML string
View Source
var SampleLegacyAppfileExportJSON string
View Source
var SampleVanillaComposeAppYAML string

Functions

func PropertiesFromContext

func PropertiesFromContext(ctx context.Context) map[string]string

PropertiesFromContext returns a copy of the event properties carried by ctx, safe to read while another goroutine is still adding to them. Writing to the copy changes nothing the events will carry -- SetProperties is what does that.

func SetProperties

func SetProperties(ctx context.Context, properties map[string]string)

SetProperties adds to the event properties carried by ctx, so that every event published from it -- including the ones already in flight -- carries them.

A context built without WithProperties has nowhere to put them, and they are dropped: it is a context that publishes no events of its own.

func WithProperties

func WithProperties(ctx context.Context, properties map[string]string) context.Context

Returns a new context with the given properties for events.

Types

This section is empty.

Jump to

Keyboard shortcuts

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