sync

package
v1.6.27 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

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

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

ExportProfile exports a profile.

type ProfileExportRequest

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

ProfileExportRequest is a request for a profile export.

type ProfileFingerprint

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

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

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

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

ProfileImportResult is returned by successful import operations.

func ImportProfile

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 Sync added in v1.6.19

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

func New added in v1.6.19

func New(instance instance) (*Sync, error)

New returns a new NetEnv module.

func (*Sync) Manager added in v1.6.19

func (s *Sync) Manager() *mgr.Manager

func (*Sync) Start added in v1.6.19

func (s *Sync) Start() error

func (*Sync) Stop added in v1.6.19

func (s *Sync) Stop() error

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