apply

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(d ConfigDiff, api API, allowRemoveLabels bool) error

Apply applies the changes identified by the diff to the remote configuration.

Types

type API

type API interface {
	AddLabels(lbs label.Labels) error
	AddFilters(fs filter.Filters) error
	UpdateLabels(lbs label.Labels) error
	DeleteFilters(ids []string) error
	DeleteLabels(ids []string) error
}

API provides access to Gmail APIs.

type ConfigDiff

type ConfigDiff struct {
	FiltersDiff filter.FiltersDiff
	LabelsDiff  label.LabelsDiff

	LocalConfig GmailConfig
}

ConfigDiff contains the difference between local and upstream configuration, including both labels and filters.

For validation purposes, the local config is also kept.

func Diff

func Diff(local, upstream GmailConfig) (ConfigDiff, error)

Diff computes the diff between local and upstream configuration.

func (ConfigDiff) Empty

func (d ConfigDiff) Empty() bool

Empty returns whether the diff contains no changes.

func (ConfigDiff) String

func (d ConfigDiff) String() string

func (ConfigDiff) Validate

func (d ConfigDiff) Validate() error

Validate returns whether the given diff is valid.

type ConfigParseRes

type ConfigParseRes struct {
	GmailConfig
	Rules []parser.Rule
}

ConfigParseRes represents the result of a config parse.

func FromConfig

func FromConfig(cfg v1alpha3.Config) (ConfigParseRes, error)

FromConfig creates a GmailConfig from a parsed configuration file.

type FetchAPI

type FetchAPI interface {
	ListFilters() (filter.Filters, error)
	ListLabels() (label.Labels, error)
}

FetchAPI provides access to Gmail get APIs.

type GmailConfig

type GmailConfig struct {
	Labels  label.Labels
	Filters filter.Filters
}

GmailConfig represents a Gmail configuration.

func FromAPI

func FromAPI(api FetchAPI) (GmailConfig, error)

FromConfig creates a GmailConfig from Gmail APIs.

Jump to

Keyboard shortcuts

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