sync

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: AGPL-3.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TypeProfile       = "profile"
	TypeSettings      = "settings"
	TypeSingleSetting = "single-setting"
)

Export Types.

View Source
const (
	ExportTargetGlobal = "global"
)

Export IDs.

Variables

View Source
var (
	MsgNone           = ""
	MsgValid          = "Import is valid."
	MsgSuccess        = "Import successful."
	MsgRequireRestart = "Import successful. Restart required for setting to take effect."
)

Messages.

View Source
var (
	ErrMismatch = api.ErrorWithStatus(
		errors.New("the supplied export cannot be imported here"),
		http.StatusPreconditionFailed,
	)
	ErrSettingNotFound = api.ErrorWithStatus(
		errors.New("setting not found"),
		http.StatusPreconditionFailed,
	)
	ErrTargetNotFound = api.ErrorWithStatus(
		errors.New("import/export target does not exist"),
		http.StatusGone,
	)
	ErrUnchanged = api.ErrorWithStatus(
		errors.New("cannot export unchanged setting"),
		http.StatusGone,
	)
	ErrNotSettablePerApp = api.ErrorWithStatus(
		errors.New("cannot be set per app"),
		http.StatusGone,
	)
	ErrInvalidImportRequest = api.ErrorWithStatus(
		errors.New("invalid import request"),
		http.StatusUnprocessableEntity,
	)
	ErrInvalidSettingValue = api.ErrorWithStatus(
		errors.New("invalid setting value"),
		http.StatusUnprocessableEntity,
	)
	ErrInvalidProfileData = api.ErrorWithStatus(
		errors.New("invalid profile data"),
		http.StatusUnprocessableEntity,
	)
	ErrImportFailed = api.ErrorWithStatus(
		errors.New("import failed"),
		http.StatusInternalServerError,
	)
	ErrExportFailed = api.ErrorWithStatus(
		errors.New("export failed"),
		http.StatusInternalServerError,
	)
)

Errors.

Functions

This section is empty.

Types

type ExportRequest

type ExportRequest struct {
	From string   `json:"from"`
	Keys []string `json:"keys"`
}

ExportRequest is a request for an export.

type ImportRequest

type ImportRequest struct {
	// Where the export should be import to.
	Target string `json:"target"`
	// Only validate, but do not actually change anything.
	ValidateOnly bool `json:"validateOnly"`

	RawExport string `json:"rawExport"`
	RawMime   string `json:"rawMime"`
}

ImportRequest is a request to import an export.

type ImportResult

type ImportResult struct {
	RestartRequired  bool `json:"restartRequired"`
	ReplacesExisting bool `json:"replacesExisting"`
	ContainsUnknown  bool `json:"containsUnknown"`
}

ImportResult is returned by successful import operations.

func ImportSettings

func ImportSettings(r *SettingsImportRequest) (*ImportResult, error)

ImportSettings imports the global settings.

func ImportSingeSetting

func ImportSingeSetting(r *SingleSettingImportRequest) (*ImportResult, error)

ImportSingeSetting imports a single setting.

type ProfileExport

type ProfileExport struct {
	Type Type `json:"type" yaml:"type"`

	// Identification
	ID     string                `json:"id,omitempty"     yaml:"id,omitempty"`
	Source profile.ProfileSource `json:"source,omitempty" yaml:"source,omitempty"`

	// Human Metadata
	Name                string `json:"name"                  yaml:"name"`
	Description         string `json:"description,omitempty" yaml:"description,omitempty"`
	Homepage            string `json:"homepage,omitempty"    yaml:"homepage,omitempty"`
	PresentationPath    string `json:"presPath,omitempty"    yaml:"presPath,omitempty"`
	UsePresentationPath bool   `json:"usePresPath,omitempty" yaml:"usePresPath,omitempty"`
	IconData            string `json:"iconData,omitempty"    yaml:"iconData,omitempty"` // DataURL

	// Process matching
	Fingerprints []ProfileFingerprint `json:"fingerprints" yaml:"fingerprints"`

	// Settings
	Config map[string]any `json:"config,omitempty" yaml:"config,omitempty"`

	// Metadata
	LastEdited *time.Time `json:"lastEdited,omitempty" yaml:"lastEdited,omitempty"`
	Created    *time.Time `json:"created,omitempty"    yaml:"created,omitempty"`
	Internal   bool       `json:"internal,omitempty"   yaml:"internal,omitempty"`
}

ProfileExport holds an export of a profile.

func ExportProfile added in v1.6.1

func ExportProfile(scopedID string) (*ProfileExport, error)

ExportProfile exports a profile.

type ProfileExportRequest added in v1.6.1

type ProfileExportRequest struct {
	ID string `json:"id"`
}

ProfileExportRequest is a request for a profile export.

type ProfileFingerprint added in v1.6.1

type ProfileFingerprint struct {
	Type       string `json:"type"                 yaml:"type"`
	Key        string `json:"key,omitempty"        yaml:"key,omitempty"`
	Operation  string `json:"operation"            yaml:"operation"`
	Value      string `json:"value"                yaml:"value"`
	MergedFrom string `json:"mergedFrom,omitempty" yaml:"mergedFrom,omitempty"`
}

ProfileFingerprint represents a profile fingerprint.

type ProfileIcon added in v1.6.1

type ProfileIcon struct {
	IconData string `json:"iconData,omitempty" yaml:"iconData,omitempty"` // DataURL
}

ProfileIcon represents a profile icon only.

type ProfileImportRequest

type ProfileImportRequest struct {
	ImportRequest `json:",inline"`

	// AllowUnknown allows the import of unknown settings.
	// Otherwise, attempting to import an unknown setting will result in an error.
	AllowUnknown bool `json:"allowUnknown"`

	// AllowReplace allows the import to replace other existing profiles.
	AllowReplace bool `json:"allowReplaceProfiles"`

	Export *ProfileExport `json:"export"`
}

ProfileImportRequest is a request to import Profile.

type ProfileImportResult added in v1.6.1

type ProfileImportResult struct {
	ImportResult `json:",inline"`

	ReplacesProfiles []string `json:"replacesProfiles"`
}

ProfileImportResult is returned by successful import operations.

func ImportProfile added in v1.6.1

func ImportProfile(r *ProfileImportRequest, requiredProfileSource profile.ProfileSource) (*ProfileImportResult, error)

ImportProfile imports a profile.

type SettingsExport

type SettingsExport struct {
	Type Type `json:"type" yaml:"type"`

	Config map[string]any `json:"config" yaml:"config"`
}

SettingsExport holds an export of settings.

func ExportSettings

func ExportSettings(from string, keys []string) (*SettingsExport, error)

ExportSettings exports the global settings.

type SettingsImportRequest

type SettingsImportRequest struct {
	ImportRequest `json:",inline" yaml:",inline"`

	// Reset all settings of target before import.
	// The ImportResult also reacts to this flag and correctly reports whether
	// any settings would be replaced or deleted.
	Reset bool `json:"reset" yaml:"reset"`

	// AllowUnknown allows the import of unknown settings.
	// Otherwise, attempting to import an unknown setting will result in an error.
	AllowUnknown bool `json:"allowUnknown" yaml:"allowUnknown"`

	Export *SettingsExport `json:"export" yaml:"export"`
}

SettingsImportRequest is a request to import settings.

type SingleSettingExport

type SingleSettingExport struct {
	Type Type   `json:"type" yaml:"type"` // Must be TypeSingleSetting
	ID   string `json:"id"   yaml:"id"`   // Settings Key

	Value any `json:"value" yaml:"value"`
}

SingleSettingExport holds an export of a single setting.

func ExportSingleSetting

func ExportSingleSetting(key, from string) (*SingleSettingExport, error)

ExportSingleSetting export a single setting.

type SingleSettingImportRequest

type SingleSettingImportRequest struct {
	ImportRequest `json:",inline"`

	Export *SingleSettingExport `json:"export"`
}

SingleSettingImportRequest is a request to import a single setting.

type Type

type Type string

Type is the type of an export.

Jump to

Keyboard shortcuts

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