sync

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: AGPL-3.0 Imports: 13 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

	// Identification (sync or import as new only)
	ID     string
	Source string

	// Human Metadata
	Name                string
	Description         string
	Homepage            string
	Icons               []profile.Icon
	PresentationPath    string
	UsePresentationPath bool

	// Process matching
	Fingerprints []profile.Fingerprint

	// Settings
	Config map[string]any

	// Metadata (sync only)
	LastEdited time.Time
	Created    time.Time
	Internal   bool
}

ProfileExport holds an export of a profile.

type ProfileImportRequest

type ProfileImportRequest struct {
	ImportRequest

	// Reset all settings and fingerprints of target before import.
	Reset bool

	Export *ProfileExport
}

ProfileImportRequest is a request to import Profile.

type SettingsExport

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

	Config map[string]any `json:"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"`

	// 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"`

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

	Export *SettingsExport `json:"export"`
}

SettingsImportRequest is a request to import settings.

type SingleSettingExport

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

	Value any `json:"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