Documentation
¶
Overview ¶
Package pkger implements a means to create and consume reusable templates for what will eventually come to support all influxdb resources. As of writing this we have support for creating buckets, dashboards, labels, and variables. All the resources can be cloned to create a new pkg from existing resources as well.
The parser supports both JSON and YAML encodings as well as a number of different ways to read the file/reader/string as it may.
As an example, you can use the following to parse and validate a YAML file and see a summary of its contents:
newPkg, err := Parse(EncodingYAML, FromFile(PATH_TO_FILE)) if err != nil { panic(err) // handle error as you see fit } sum := newPkg.Summary() fmt.Println(sum) // do something with the summary
The parser will validate all contents of the package and provide any and all fields/entries that failed validation.
If you wish to use the Pkg type in your transport layer and let the the transport layer manage the decoding, then you can run the following to validate the package after the raw decoding is done:
if err := pkg.Validate(); err != nil { panic(err) // handle error as you see fit }
If a validation error is encountered during the validation or parsing then the error returned will be of type *parseErr. The parseErr provides a rich set of validations failures. There can be numerous failures in a package and we did our best to inform the caller about them all in a single run.
If you want to see the effects of a package before applying it to the organization's influxdb platform, you have the flexibility to dry run the package and see the outcome of what would happen after it were to be applied. You may use the following to dry run a package within your organization:
svc := NewService(serviceOpts...) summary, diff, err := svc.DryRun(ctx, orgID, pkg) if err != nil { panic(err) // handle error as you see fit } // explore the summary and diff
The diff provided here is a diff of the existing state of the platform for your organization and the concluding the state after the application of a package. All buckets, labels, and variables, when given a name that already exists, will not create a new resource, but rather, will edit the existing resource. If this is not a desired result, then rename your bucket to something else to avoid the imposed changes applying this package would incur. The summary provided is a summary of hte package itself. If a resource exists all IDs will be populated for them, if they do not, then they will be zero values. Any zero value ID is safe to assume is not populated. All influxdb.ID's must be non zero to be valid.
If you would like to apply a package you may use the service to do so. The following will apply the package in full to the provided organization.
svc := NewService(serviceOpts...) summary, err := svc.Apply(ctx, orgID, pkg) if err != nil { panic(err) // handle error as you see fit } // explore the summary
The summary will be populated with valid IDs that were created during the application of the package. If an error is encountered during the application of a package, then all changes that had occurred will be rolled back. However, as a warning for buckets, changes may have incurred destructive changes. The changes are not applied inside a large transaction, for numerous reasons, but it is something to be considered. If you have dry run the package before it is to be applied, then the changes should have been made known to you. If not, then there is potential loss of data if the changes to a bucket resulted in the retention period being shortened in the package.
If you would like to export existing resources into the form of a package, then you have the ability to do so using the following:
resourcesToClone := []ResourceToClone{ { Kind: KindBucket, ID: Existing_BUCKET_ID, Name: "new bucket name" }, { Kind: KindDashboard, ID: Existing_Dashboard_ID, }, { Kind: KindLabel, ID: Existing_Label_ID, }, { Kind: KindVarible, ID: Existing_Var_ID, }, } svc := NewService(serviceOpts...) newPkg, err := svc.CreatePkg(ctx, CreateWithMetadata(Metadata{ Name: "pkg name", Description: "stand up desc", Version: "v1.0.0", }), CreateWithExistingResources(resourcesToClone...), ) if err != nil { panic(err) // handle error as you see fit } // explore newly created and validated package
Things to note about the behavior of exporting existing resources. All label associations with existing resources will be included in the new package. However, the variables that are used within a dashboard query will not be added automatically to the package. Variables will need to be passed in alongside the dashboard to be added to the package.
Index ¶
- Constants
- Variables
- func IsParseErr(err error) bool
- func NewParseError(errs ...ValidationErr) error
- type ApplyOpt
- type ApplyOptFn
- type CreateOpt
- type CreatePkgSetFn
- type Diff
- type DiffBucket
- type DiffBucketValues
- type DiffChart
- type DiffCheck
- type DiffCheckValues
- type DiffDashboard
- type DiffLabel
- type DiffLabelMapping
- type DiffLabelValues
- type DiffNotificationEndpoint
- type DiffNotificationEndpointValues
- type DiffNotificationRule
- type DiffTask
- type DiffTelegraf
- type DiffVariable
- type DiffVariableValues
- type Encoder
- type Encoding
- type HTTPRemoteService
- func (s *HTTPRemoteService) Apply(ctx context.Context, orgID, userID influxdb.ID, pkg *Pkg, opts ...ApplyOptFn) (Summary, error)
- func (s *HTTPRemoteService) CreatePkg(ctx context.Context, setters ...CreatePkgSetFn) (*Pkg, error)
- func (s *HTTPRemoteService) DryRun(ctx context.Context, orgID, userID influxdb.ID, pkg *Pkg, opts ...ApplyOptFn) (Summary, Diff, error)
- type HTTPServer
- type Kind
- type Object
- type ParseError
- type Pkg
- type PkgRemote
- type ReaderFn
- type ReqApplyPkg
- type ReqCreatePkg
- type Resource
- type ResourceToClone
- type RespApplyPkg
- type RespCreatePkg
- type SVC
- type SVCMiddleware
- type SafeID
- type Service
- func (s *Service) Apply(ctx context.Context, orgID, userID influxdb.ID, pkg *Pkg, opts ...ApplyOptFn) (sum Summary, e error)
- func (s *Service) CreatePkg(ctx context.Context, setters ...CreatePkgSetFn) (*Pkg, error)
- func (s *Service) DryRun(ctx context.Context, orgID, userID influxdb.ID, pkg *Pkg, opts ...ApplyOptFn) (Summary, Diff, error)
- type ServiceSetterFn
- func WithBucketSVC(bktSVC influxdb.BucketService) ServiceSetterFn
- func WithCheckSVC(checkSVC influxdb.CheckService) ServiceSetterFn
- func WithDashboardSVC(dashSVC influxdb.DashboardService) ServiceSetterFn
- func WithLabelSVC(labelSVC influxdb.LabelService) ServiceSetterFn
- func WithLogger(log *zap.Logger) ServiceSetterFn
- func WithNotificationEndpointSVC(endpointSVC influxdb.NotificationEndpointService) ServiceSetterFn
- func WithNotificationRuleSVC(ruleSVC influxdb.NotificationRuleStore) ServiceSetterFn
- func WithSecretSVC(secretSVC influxdb.SecretService) ServiceSetterFn
- func WithTaskSVC(taskSVC influxdb.TaskService) ServiceSetterFn
- func WithTelegrafSVC(telegrafSVC influxdb.TelegrafConfigStore) ServiceSetterFn
- func WithVariableSVC(varSVC influxdb.VariableService) ServiceSetterFn
- type Summary
- type SummaryBucket
- type SummaryChart
- type SummaryCheck
- type SummaryDashboard
- type SummaryLabel
- type SummaryLabelMapping
- type SummaryNotificationEndpoint
- type SummaryNotificationRule
- type SummaryStatusRule
- type SummaryTagRule
- type SummaryTask
- type SummaryTelegraf
- type SummaryVariable
- type ValidateOptFn
- type ValidationErr
Constants ¶
const APIVersion = "influxdata.com/v2alpha1"
APIVersion marks the current APIVersion for influx packages.
const RoutePrefix = "/api/v2/packages"
Variables ¶
var ErrInvalidEncoding = errors.New("invalid encoding provided")
ErrInvalidEncoding indicates the encoding is invalid type for the parser.
Functions ¶
func IsParseErr ¶
IsParseErr inspects a given error to determine if it is a parseErr. If a parseErr it is, it will return it along with the confirmation boolean. If the error is not a parseErr it will return nil values for the parseErr, making it unsafe to use.
func NewParseError ¶
func NewParseError(errs ...ValidationErr) error
NewParseError creates a new parse error from existing validation errors.
Types ¶
type ApplyOptFn ¶
ApplyOptFn updates the ApplyOpt per the functional option.
func ApplyWithEnvRefs ¶
func ApplyWithEnvRefs(envRefs map[string]string) ApplyOptFn
ApplyWithEnvRefs provides env refs to saturate the missing reference fields in the pkg.
func ApplyWithSecrets ¶
func ApplyWithSecrets(secrets map[string]string) ApplyOptFn
ApplyWithSecrets provides secrets to the platform that the pkg will need.
type CreateOpt ¶
type CreateOpt struct { OrgIDs map[influxdb.ID]bool Resources []ResourceToClone }
CreateOpt are the options for creating a new package.
type CreatePkgSetFn ¶
CreatePkgSetFn is a functional input for setting the pkg fields.
func CreateWithAllOrgResources ¶
func CreateWithAllOrgResources(orgID influxdb.ID) CreatePkgSetFn
CreateWithAllOrgResources allows the create method to clone all existing resources for the given organization.
func CreateWithExistingResources ¶
func CreateWithExistingResources(resources ...ResourceToClone) CreatePkgSetFn
CreateWithExistingResources allows the create method to clone existing resources.
type Diff ¶
type Diff struct { Buckets []DiffBucket `json:"buckets"` Checks []DiffCheck `json:"checks"` Dashboards []DiffDashboard `json:"dashboards"` Labels []DiffLabel `json:"labels"` LabelMappings []DiffLabelMapping `json:"labelMappings"` NotificationEndpoints []DiffNotificationEndpoint `json:"notificationEndpoints"` NotificationRules []DiffNotificationRule `json:"notificationRules"` Tasks []DiffTask `json:"tasks"` Telegrafs []DiffTelegraf `json:"telegrafConfigs"` Variables []DiffVariable `json:"variables"` }
Diff is the result of a service DryRun call. The diff outlines what is new and or updated from the current state of the platform.
func (Diff) HasConflicts ¶
HasConflicts provides a binary t/f if there are any changes within package after dry run is complete.
type DiffBucket ¶
type DiffBucket struct { ID SafeID `json:"id"` Name string `json:"name"` New DiffBucketValues `json:"new"` Old *DiffBucketValues `json:"old,omitempty"` // using omitempty here to signal there was no prev state with a nil }
DiffBucket is a diff of an individual bucket.
func (DiffBucket) IsNew ¶
func (d DiffBucket) IsNew() bool
IsNew indicates whether a pkg bucket is going to be new to the platform.
type DiffBucketValues ¶
type DiffBucketValues struct { Description string `json:"description"` RetentionRules retentionRules `json:"retentionRules"` }
DiffBucketValues are the varying values for a bucket.
type DiffChart ¶
type DiffChart SummaryChart
DiffChart is a diff of oa chart. Since all charts are new right now. the SummaryChart is reused here.
type DiffCheck ¶
type DiffCheck struct { ID SafeID `json:"id"` Name string `json:"name"` New DiffCheckValues `json:"new"` Old *DiffCheckValues `json:"old"` }
DiffCheck is a diff of an individual check.
type DiffCheckValues ¶
DiffCheckValues are the varying values for a check.
func (*DiffCheckValues) UnmarshalJSON ¶
func (d *DiffCheckValues) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON decodes the check values.
type DiffDashboard ¶
type DiffDashboard struct { Name string `json:"name"` Desc string `json:"description"` Charts []DiffChart `json:"charts"` }
DiffDashboard is a diff of an individual dashboard. This resource is always new.
type DiffLabel ¶
type DiffLabel struct { ID SafeID `json:"id"` Name string `json:"name"` New DiffLabelValues `json:"new"` Old *DiffLabelValues `json:"old,omitempty"` // using omitempty here to signal there was no prev state with a nil }
DiffLabel is a diff of an individual label.
type DiffLabelMapping ¶
type DiffLabelMapping struct { IsNew bool `json:"isNew"` ResType influxdb.ResourceType `json:"resourceType"` ResID SafeID `json:"resourceID"` ResName string `json:"resourceName"` LabelID SafeID `json:"labelID"` LabelName string `json:"labelName"` }
DiffLabelMapping is a diff of an individual label mapping. A single resource may have multiple mappings to multiple labels. A label can have many mappings to other resources.
type DiffLabelValues ¶
DiffLabelValues are the varying values for a label.
type DiffNotificationEndpoint ¶
type DiffNotificationEndpoint struct { ID SafeID `json:"id"` Name string `json:"name"` New DiffNotificationEndpointValues `json:"new"` Old *DiffNotificationEndpointValues `json:"old"` }
DiffNotificationEndpoint is a diff of an individual notification endpoint.
func (DiffNotificationEndpoint) IsNew ¶
func (d DiffNotificationEndpoint) IsNew() bool
IsNew indicates if the resource will be new to the platform or if it edits an existing resource.
type DiffNotificationEndpointValues ¶
type DiffNotificationEndpointValues struct {
influxdb.NotificationEndpoint
}
DiffNotificationEndpointValues are the varying values for a notification endpoint.
func (*DiffNotificationEndpointValues) UnmarshalJSON ¶
func (d *DiffNotificationEndpointValues) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON decodes the notification endpoint. This is necessary unfortunately.
type DiffNotificationRule ¶
type DiffNotificationRule struct { Name string `json:"name"` Description string `json:"description"` // These 3 fields represent the relationship of the rule to the endpoint. EndpointID SafeID `json:"endpointID"` EndpointName string `json:"endpointName"` EndpointType string `json:"endpointType"` Every string `json:"every"` Offset string `json:"offset"` MessageTemplate string `json:"messageTemplate"` Status influxdb.Status `json:"status"` StatusRules []SummaryStatusRule `json:"statusRules"` TagRules []SummaryTagRule `json:"tagRules"` }
DiffNotificationRule is a diff of an individual notification rule. This resource is always new.
type DiffTask ¶
type DiffTask struct { Name string `json:"name"` Cron string `json:"cron"` Description string `json:"description"` Every string `json:"every"` Offset string `json:"offset"` Query string `json:"query"` Status influxdb.Status `json:"status"` }
DiffTask is a diff of an individual task. This resource is always new.
type DiffTelegraf ¶
type DiffTelegraf struct {
influxdb.TelegrafConfig
}
DiffTelegraf is a diff of an individual telegraf. This resource is always new.
type DiffVariable ¶
type DiffVariable struct { ID SafeID `json:"id"` Name string `json:"name"` New DiffVariableValues `json:"new"` Old *DiffVariableValues `json:"old,omitempty"` // using omitempty here to signal there was no prev state with a nil }
DiffVariable is a diff of an individual variable.
func (DiffVariable) IsNew ¶
func (d DiffVariable) IsNew() bool
IsNew indicates whether a pkg variable is going to be new to the platform.
type DiffVariableValues ¶
type DiffVariableValues struct { Description string `json:"description"` Args *influxdb.VariableArguments `json:"args"` }
DiffVariableValues are the varying values for a variable.
type Encoding ¶
type Encoding int
Encoding describes the encoding for the raw package data. The encoding determines how the raw data is parsed.
type HTTPRemoteService ¶
HTTPRemoteService provides an http client that is fluent in all things pkger.
func (*HTTPRemoteService) Apply ¶
func (s *HTTPRemoteService) Apply(ctx context.Context, orgID, userID influxdb.ID, pkg *Pkg, opts ...ApplyOptFn) (Summary, error)
Apply will apply all the resources identified in the provided pkg. The entire pkg will be applied in its entirety. If a failure happens midway then the entire pkg will be rolled back to the state from before the pkg was applied.
func (*HTTPRemoteService) CreatePkg ¶
func (s *HTTPRemoteService) CreatePkg(ctx context.Context, setters ...CreatePkgSetFn) (*Pkg, error)
CreatePkg will produce a pkg from the parameters provided.
func (*HTTPRemoteService) DryRun ¶
func (s *HTTPRemoteService) DryRun(ctx context.Context, orgID, userID influxdb.ID, pkg *Pkg, opts ...ApplyOptFn) (Summary, Diff, error)
DryRun provides a dry run of the pkg application. The pkg will be marked verified for later calls to Apply. This func will be run on an Apply if it has not been run already.
type HTTPServer ¶
HTTPServer is a server that manages the packages HTTP transport.
func NewHTTPServer ¶
func NewHTTPServer(log *zap.Logger, svc SVC) *HTTPServer
NewHTTPServer constructs a new http server.
func (*HTTPServer) Prefix ¶
func (s *HTTPServer) Prefix() string
Prefix provides the prefix to this route tree.
type Kind ¶
type Kind string
Kind is a resource kind.
const ( KindUnknown Kind = "" KindBucket Kind = "Bucket" KindCheck Kind = "Check" KindCheckDeadman Kind = "CheckDeadman" KindCheckThreshold Kind = "CheckThreshold" KindDashboard Kind = "Dashboard" KindLabel Kind = "Label" KindNotificationEndpoint Kind = "NotificationEndpoint" KindNotificationEndpointHTTP Kind = "NotificationEndpointHTTP" KindNotificationEndpointPagerDuty Kind = "NotificationEndpointPagerDuty" KindNotificationEndpointSlack Kind = "NotificationEndpointSlack" KindNotificationRule Kind = "NotificationRule" KindPackage Kind = "Package" KindTask Kind = "Task" KindTelegraf Kind = "Telegraf" KindVariable Kind = "Variable" )
Package kind types.
func (Kind) ResourceType ¶
func (k Kind) ResourceType() influxdb.ResourceType
ResourceType converts a kind to a known resource type (if applicable).
type Object ¶
type Object struct { APIVersion string `json:"apiVersion" yaml:"apiVersion"` Type Kind `json:"kind" yaml:"kind"` Metadata Resource `json:"metadata" yaml:"metadata"` Spec Resource `json:"spec" yaml:"spec"` }
Object describes the metadata and raw spec for an entity of a package kind.
func DashboardToObject ¶
DashboardToObject converts an influxdb.Dashboard to a pkger.Resource.
func VariableToObject ¶
VariableToObject converts an influxdb.Variable to a pkger.Object.
type ParseError ¶
type ParseError interface {
ValidationErrs() []ValidationErr
}
ParseError is the error from parsing the given package. The ParseError behavior provides a list of resources that failed and all validations that failed for that resource. A resource can multiple errors, and a parseErr can have multiple resources which themselves can have multiple validation failures.
type Pkg ¶
type Pkg struct { Objects []Object `json:"-" yaml:"-"` // contains filtered or unexported fields }
Pkg is the model for a package. The resources are more generic that one might expect at first glance. This was done on purpose. The way json/yaml/toml or w/e scripting you want to use, can have very different ways of parsing. The different parsers are limited for the parsers that do not come from the std lib (looking at you yaml/v2). This allows us to parse it and leave the matching to another power, the graphing of the package is handled within itself.
func Combine ¶
Combine combines pkgs together. Is useful when you want to take multiple disparate pkgs and compile them into one to take advantage of the parser and service guarantees.
func Parse ¶
func Parse(encoding Encoding, readerFn ReaderFn, opts ...ValidateOptFn) (*Pkg, error)
Parse parses a pkg defined by the encoding and readerFns. As of writing this we can parse both a YAML, JSON, and Jsonnet formats of the Pkg model.
func (*Pkg) Summary ¶
Summary returns a package Summary that describes all the resources and associations the pkg contains. It is very useful for informing users of the changes that will take place when this pkg would be applied.
func (*Pkg) Validate ¶
func (p *Pkg) Validate(opts ...ValidateOptFn) error
Validate will graph all resources and validate every thing is in a useful form.
type PkgRemote ¶
PkgRemote provides a package via a remote (i.e. a gist). If content type is not provided then the service will do its best to discern the content type of the contents.
type ReaderFn ¶
ReaderFn is used for functional inputs to abstract the individual entrypoints for the reader itself.
func FromHTTPRequest ¶
FromHTTPRequest parses a pkg from the request body of a HTTP request. This is very useful when using packages that are hosted..
func FromReader ¶
FromReader simply passes the reader along. Useful when consuming this from an HTTP request body. There are a number of other useful places for this functional input.
func FromString ¶
FromString parses a pkg from a raw string value. This is very useful in tests.
type ReqApplyPkg ¶
type ReqApplyPkg struct { DryRun bool `json:"dryRun" yaml:"dryRun"` OrgID string `json:"orgID" yaml:"orgID"` Remotes []PkgRemote `json:"remotes" yaml:"remotes"` RawPkgs []json.RawMessage `json:"packages" yaml:"packages"` RawPkg json.RawMessage `json:"package" yaml:"package"` EnvRefs map[string]string `json:"envRefs"` Secrets map[string]string `json:"secrets"` }
ReqApplyPkg is the request body for a json or yaml body for the apply pkg endpoint.
type ReqCreatePkg ¶
type ReqCreatePkg struct { OrgIDs []string `json:"orgIDs"` Resources []ResourceToClone `json:"resources"` }
ReqCreatePkg is a request body for the create pkg endpoint.
type Resource ¶
type Resource map[string]interface{}
Resource is a pkger Resource kind. It can be one of any of available kinds that are supported.
type ResourceToClone ¶
type ResourceToClone struct { Kind Kind `json:"kind"` ID influxdb.ID `json:"id"` Name string `json:"name"` }
ResourceToClone is a resource that will be cloned.
func (ResourceToClone) OK ¶
func (r ResourceToClone) OK() error
OK validates a resource clone is viable.
type RespApplyPkg ¶
type RespApplyPkg struct { Diff Diff `json:"diff" yaml:"diff"` Summary Summary `json:"summary" yaml:"summary"` Errors []ValidationErr `json:"errors,omitempty" yaml:"errors,omitempty"` }
RespApplyPkg is the response body for the apply pkg endpoint.
type RespCreatePkg ¶
type RespCreatePkg []Object
RespCreatePkg is a response body for the create pkg endpoint.
type SVC ¶
type SVC interface { CreatePkg(ctx context.Context, setters ...CreatePkgSetFn) (*Pkg, error) DryRun(ctx context.Context, orgID, userID influxdb.ID, pkg *Pkg, opts ...ApplyOptFn) (Summary, Diff, error) Apply(ctx context.Context, orgID, userID influxdb.ID, pkg *Pkg, opts ...ApplyOptFn) (Summary, error) }
SVC is the packages service interface.
type SVCMiddleware ¶
SVCMiddleware is a service middleware func.
func MWLogging ¶
func MWLogging(log *zap.Logger) SVCMiddleware
MWLogging adds logging functionality for the service.
func MWMetrics ¶
func MWMetrics(reg *prom.Registry) SVCMiddleware
MWMetrics is a metrics service middleware for the notification endpoint service.
func MWTracing ¶
func MWTracing() SVCMiddleware
MWTracing adds tracing functionality for the service.
type SafeID ¶
SafeID is an equivalent influxdb.ID that encodes safely with zero values (influxdb.ID == 0).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides the pkger business logic including all the dependencies to make this resource sausage.
func NewService ¶
func NewService(opts ...ServiceSetterFn) *Service
NewService is a constructor for a pkger Service.
func (*Service) Apply ¶
func (s *Service) Apply(ctx context.Context, orgID, userID influxdb.ID, pkg *Pkg, opts ...ApplyOptFn) (sum Summary, e error)
Apply will apply all the resources identified in the provided pkg. The entire pkg will be applied in its entirety. If a failure happens midway then the entire pkg will be rolled back to the state from before the pkg were applied.
func (*Service) DryRun ¶
func (s *Service) DryRun(ctx context.Context, orgID, userID influxdb.ID, pkg *Pkg, opts ...ApplyOptFn) (Summary, Diff, error)
DryRun provides a dry run of the pkg application. The pkg will be marked verified for later calls to Apply. This func will be run on an Apply if it has not been run already.
type ServiceSetterFn ¶
type ServiceSetterFn func(opt *serviceOpt)
ServiceSetterFn is a means of setting dependencies on the Service type.
func WithBucketSVC ¶
func WithBucketSVC(bktSVC influxdb.BucketService) ServiceSetterFn
WithBucketSVC sets the bucket service.
func WithCheckSVC ¶
func WithCheckSVC(checkSVC influxdb.CheckService) ServiceSetterFn
WithCheckSVC sets the check service.
func WithDashboardSVC ¶
func WithDashboardSVC(dashSVC influxdb.DashboardService) ServiceSetterFn
WithDashboardSVC sets the dashboard service.
func WithLabelSVC ¶
func WithLabelSVC(labelSVC influxdb.LabelService) ServiceSetterFn
WithLabelSVC sets the label service.
func WithLogger ¶
func WithLogger(log *zap.Logger) ServiceSetterFn
WithLogger sets the logger for the service.
func WithNotificationEndpointSVC ¶
func WithNotificationEndpointSVC(endpointSVC influxdb.NotificationEndpointService) ServiceSetterFn
WithNotificationEndpointSVC sets the endpoint notification service.
func WithNotificationRuleSVC ¶
func WithNotificationRuleSVC(ruleSVC influxdb.NotificationRuleStore) ServiceSetterFn
WithNotificationRuleSVC sets the endpoint rule service.
func WithSecretSVC ¶
func WithSecretSVC(secretSVC influxdb.SecretService) ServiceSetterFn
WithSecretSVC sets the secret service.
func WithTaskSVC ¶
func WithTaskSVC(taskSVC influxdb.TaskService) ServiceSetterFn
WithTaskSVC sets the task service.
func WithTelegrafSVC ¶
func WithTelegrafSVC(telegrafSVC influxdb.TelegrafConfigStore) ServiceSetterFn
WithTelegrafSVC sets the telegraf service.
func WithVariableSVC ¶
func WithVariableSVC(varSVC influxdb.VariableService) ServiceSetterFn
WithVariableSVC sets the variable service.
type Summary ¶
type Summary struct { Buckets []SummaryBucket `json:"buckets"` Checks []SummaryCheck `json:"checks"` Dashboards []SummaryDashboard `json:"dashboards"` NotificationEndpoints []SummaryNotificationEndpoint `json:"notificationEndpoints"` NotificationRules []SummaryNotificationRule `json:"notificationRules"` Labels []SummaryLabel `json:"labels"` LabelMappings []SummaryLabelMapping `json:"labelMappings"` MissingEnvs []string `json:"missingEnvRefs"` MissingSecrets []string `json:"missingSecrets"` Tasks []SummaryTask `json:"summaryTask"` TelegrafConfigs []SummaryTelegraf `json:"telegrafConfigs"` Variables []SummaryVariable `json:"variables"` }
Summary is a definition of all the resources that have or will be created from a pkg.
type SummaryBucket ¶
type SummaryBucket struct { ID SafeID `json:"id,omitempty"` OrgID SafeID `json:"orgID,omitempty"` Name string `json:"name"` Description string `json:"description"` // TODO: return retention rules? RetentionPeriod time.Duration `json:"retentionPeriod"` LabelAssociations []SummaryLabel `json:"labelAssociations"` }
SummaryBucket provides a summary of a pkg bucket.
type SummaryChart ¶
type SummaryChart struct { Properties influxdb.ViewProperties `json:"-"` XPosition int `json:"xPos"` YPosition int `json:"yPos"` Height int `json:"height"` Width int `json:"width"` }
SummaryChart provides a summary of a pkg dashboard's chart.
func (*SummaryChart) MarshalJSON ¶
func (s *SummaryChart) MarshalJSON() ([]byte, error)
MarshalJSON marshals a summary chart.
func (*SummaryChart) UnmarshalJSON ¶
func (s *SummaryChart) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals a view properities and other data.
type SummaryCheck ¶
type SummaryCheck struct { Check influxdb.Check `json:"check"` Status influxdb.Status `json:"status"` LabelAssociations []SummaryLabel `json:"labelAssociations"` }
SummaryCheck provides a summary of a pkg check.
func (*SummaryCheck) UnmarshalJSON ¶
func (s *SummaryCheck) UnmarshalJSON(b []byte) error
type SummaryDashboard ¶
type SummaryDashboard struct { ID SafeID `json:"id"` OrgID SafeID `json:"orgID"` Name string `json:"name"` Description string `json:"description"` Charts []SummaryChart `json:"charts"` LabelAssociations []SummaryLabel `json:"labelAssociations"` }
SummaryDashboard provides a summary of a pkg dashboard.
type SummaryLabel ¶
type SummaryLabel struct { ID SafeID `json:"id"` OrgID SafeID `json:"orgID"` Name string `json:"name"` Properties struct { Color string `json:"color"` Description string `json:"description"` } `json:"properties"` }
SummaryLabel provides a summary of a pkg label.
type SummaryLabelMapping ¶
type SummaryLabelMapping struct { ResourceID SafeID `json:"resourceID"` ResourceName string `json:"resourceName"` ResourceType influxdb.ResourceType `json:"resourceType"` LabelName string `json:"labelName"` LabelID SafeID `json:"labelID"` // contains filtered or unexported fields }
SummaryLabelMapping provides a summary of a label mapped with a single resource.
type SummaryNotificationEndpoint ¶
type SummaryNotificationEndpoint struct { NotificationEndpoint influxdb.NotificationEndpoint `json:"notificationEndpoint"` LabelAssociations []SummaryLabel `json:"labelAssociations"` }
SummaryNotificationEndpoint provides a summary of a pkg notification endpoint.
func (*SummaryNotificationEndpoint) UnmarshalJSON ¶
func (s *SummaryNotificationEndpoint) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the notificatio endpoint. This is necessary b/c of the notification endpoint does not have a means ot unmarshal itself.
type SummaryNotificationRule ¶
type SummaryNotificationRule struct { ID SafeID `json:"id"` Name string `json:"name"` Description string `json:"description"` // These 3 fields represent the relationship of the rule to the endpoint. EndpointID SafeID `json:"endpointID"` EndpointName string `json:"endpointName"` EndpointType string `json:"endpointType"` Every string `json:"every"` LabelAssociations []SummaryLabel `json:"labelAssociations"` Offset string `json:"offset"` MessageTemplate string `json:"messageTemplate"` Status influxdb.Status `json:"status"` StatusRules []SummaryStatusRule `json:"statusRules"` TagRules []SummaryTagRule `json:"tagRules"` }
Summary types for NotificationRules which provide a summary of a pkg notification rule.
type SummaryStatusRule ¶
type SummaryStatusRule struct { CurrentLevel string `json:"currentLevel"` PreviousLevel string `json:"previousLevel"` }
Summary types for NotificationRules which provide a summary of a pkg notification rule.
type SummaryTagRule ¶
type SummaryTagRule struct { Key string `json:"key"` Value string `json:"value"` Operator string `json:"operator"` }
Summary types for NotificationRules which provide a summary of a pkg notification rule.
type SummaryTask ¶
type SummaryTask struct { ID SafeID `json:"id"` Name string `json:"name"` Cron string `json:"cron"` Description string `json:"description"` Every string `json:"every"` Offset string `json:"offset"` Query string `json:"query"` Status influxdb.Status `json:"status"` LabelAssociations []SummaryLabel `json:"labelAssociations"` }
SummaryTask provides a summary of a task.
type SummaryTelegraf ¶
type SummaryTelegraf struct { TelegrafConfig influxdb.TelegrafConfig `json:"telegrafConfig"` LabelAssociations []SummaryLabel `json:"labelAssociations"` }
SummaryTelegraf provides a summary of a pkg telegraf config.
type SummaryVariable ¶
type SummaryVariable struct { ID SafeID `json:"id,omitempty"` OrgID SafeID `json:"orgID,omitempty"` Name string `json:"name"` Description string `json:"description"` Arguments *influxdb.VariableArguments `json:"arguments"` LabelAssociations []SummaryLabel `json:"labelAssociations"` }
SummaryVariable provides a summary of a pkg variable.
type ValidateOptFn ¶
type ValidateOptFn func(*validateOpt)
ValidateOptFn provides a means to disable desired validation checks.
func ValidSkipParseError ¶
func ValidSkipParseError() ValidateOptFn
ValidSkipParseError ignores the validation check from the of resources. This is useful for the service Create to ignore this and allow the creation of a pkg without resources.
func ValidWithoutResources ¶
func ValidWithoutResources() ValidateOptFn
ValidWithoutResources ignores the validation check for minimum number of resources. This is useful for the service Create to ignore this and allow the creation of a pkg without resources.
type ValidationErr ¶
type ValidationErr struct { Kind string `json:"kind" yaml:"kind"` Fields []string `json:"fields" yaml:"fields"` Indexes []*int `json:"idxs" yaml:"idxs"` Reason string `json:"reason" yaml:"reason"` }
ValidationErr represents an error during the parsing of a package.
func (ValidationErr) Error ¶
func (v ValidationErr) Error() string