parent
cb7ecace6f
commit
952007001b
|
@ -27,29 +27,29 @@ import (
|
|||
input "github.com/tcnksm/go-input"
|
||||
)
|
||||
|
||||
type pkgSVCsFn func() (pkger.SVC, influxdb.OrganizationService, error)
|
||||
type templateSVCsFn func() (pkger.SVC, influxdb.OrganizationService, error)
|
||||
|
||||
func cmdApply(f *globalFlags, opts genericCLIOpts) *cobra.Command {
|
||||
return newCmdPkgBuilder(newPkgerSVC, f, opts).cmdApply()
|
||||
return newCmdPkgerBuilder(newPkgerSVC, f, opts).cmdApply()
|
||||
}
|
||||
|
||||
func cmdExport(f *globalFlags, opts genericCLIOpts) *cobra.Command {
|
||||
return newCmdPkgBuilder(newPkgerSVC, f, opts).cmdExport()
|
||||
return newCmdPkgerBuilder(newPkgerSVC, f, opts).cmdExport()
|
||||
}
|
||||
|
||||
func cmdStack(f *globalFlags, opts genericCLIOpts) *cobra.Command {
|
||||
return newCmdPkgBuilder(newPkgerSVC, f, opts).cmdStacks()
|
||||
return newCmdPkgerBuilder(newPkgerSVC, f, opts).cmdStacks()
|
||||
}
|
||||
|
||||
func cmdTemplate(f *globalFlags, opts genericCLIOpts) *cobra.Command {
|
||||
return newCmdPkgBuilder(newPkgerSVC, f, opts).cmdTemplate()
|
||||
return newCmdPkgerBuilder(newPkgerSVC, f, opts).cmdTemplate()
|
||||
}
|
||||
|
||||
type cmdPkgBuilder struct {
|
||||
type cmdTemplateBuilder struct {
|
||||
genericCLIOpts
|
||||
*globalFlags
|
||||
|
||||
svcFn pkgSVCsFn
|
||||
svcFn templateSVCsFn
|
||||
|
||||
encoding string
|
||||
file string
|
||||
|
@ -93,19 +93,17 @@ type cmdPkgBuilder struct {
|
|||
}
|
||||
}
|
||||
|
||||
func newCmdPkgBuilder(svcFn pkgSVCsFn, f *globalFlags, opts genericCLIOpts) *cmdPkgBuilder {
|
||||
return &cmdPkgBuilder{
|
||||
func newCmdPkgerBuilder(svcFn templateSVCsFn, f *globalFlags, opts genericCLIOpts) *cmdTemplateBuilder {
|
||||
return &cmdTemplateBuilder{
|
||||
genericCLIOpts: opts,
|
||||
globalFlags: f,
|
||||
svcFn: svcFn,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdApply() *cobra.Command {
|
||||
cmd := b.cmdPkgApply()
|
||||
func (b *cmdTemplateBuilder) cmdApply() *cobra.Command {
|
||||
cmd := b.cmdTemplateApply()
|
||||
|
||||
// all these commands are deprecated under the old pkg cmds.
|
||||
// these are moving to root commands.
|
||||
deprecatedCmds := []*cobra.Command{
|
||||
b.cmdExport(),
|
||||
b.cmdTemplateSummary(),
|
||||
|
@ -121,7 +119,7 @@ func (b *cmdPkgBuilder) cmdApply() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdPkgApply() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdTemplateApply() *cobra.Command {
|
||||
cmd := b.newCmd("apply", b.applyRunEFn)
|
||||
cmd.Aliases = []string{"pkg"}
|
||||
cmd.Short = "Apply a template to manage resources"
|
||||
|
@ -182,11 +180,11 @@ func (b *cmdPkgBuilder) cmdPkgApply() *cobra.Command {
|
|||
`
|
||||
|
||||
b.org.register(cmd, false)
|
||||
b.registerPkgFileFlags(cmd)
|
||||
b.registerPkgPrintOpts(cmd)
|
||||
b.registerTemplateFileFlags(cmd)
|
||||
b.registerTemplatePrintOpts(cmd)
|
||||
cmd.Flags().BoolVarP(&b.quiet, "quiet", "q", false, "Disable output printing")
|
||||
cmd.Flags().StringVar(&b.applyOpts.force, "force", "", `TTY input, if template will have destructive changes, proceed if set "true"`)
|
||||
cmd.Flags().StringVar(&b.stackID, "stack-id", "", "Stack ID to associate pkg application")
|
||||
cmd.Flags().StringVar(&b.stackID, "stack-id", "", "Stack ID to associate template application")
|
||||
|
||||
b.applyOpts.secrets = []string{}
|
||||
cmd.Flags().StringSliceVar(&b.applyOpts.secrets, "secret", nil, "Secrets to provide alongside the template; format should --secret=SECRET_KEY=SECRET_VALUE --secret=SECRET_KEY_2=SECRET_VALUE_2")
|
||||
|
@ -196,7 +194,7 @@ func (b *cmdPkgBuilder) cmdPkgApply() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) applyRunEFn(cmd *cobra.Command, args []string) error {
|
||||
func (b *cmdTemplateBuilder) applyRunEFn(cmd *cobra.Command, args []string) error {
|
||||
if err := b.org.validOrgFlags(&flags); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -212,12 +210,12 @@ func (b *cmdPkgBuilder) applyRunEFn(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
pkg, isTTY, err := b.readPkg()
|
||||
template, isTTY, err := b.readTemplate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
providedEnvRefs := mapKeys(pkg.Summary().MissingEnvs, b.applyOpts.envRefs)
|
||||
providedEnvRefs := mapKeys(template.Summary().MissingEnvs, b.applyOpts.envRefs)
|
||||
if !isTTY {
|
||||
for _, envRef := range missingValKeys(providedEnvRefs) {
|
||||
prompt := "Please provide environment reference value for key " + envRef
|
||||
|
@ -233,7 +231,7 @@ func (b *cmdPkgBuilder) applyRunEFn(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
opts := []pkger.ApplyOptFn{
|
||||
pkger.ApplyWithPkg(pkg),
|
||||
pkger.ApplyWithPkg(template),
|
||||
pkger.ApplyWithEnvRefs(providedEnvRefs),
|
||||
pkger.ApplyWithStackID(stackID),
|
||||
}
|
||||
|
@ -261,7 +259,7 @@ func (b *cmdPkgBuilder) applyRunEFn(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
}
|
||||
|
||||
if err := b.printPkgDiff(dryRunImpact.Diff); err != nil {
|
||||
if err := b.printTemplateDiff(dryRunImpact.Diff); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -285,7 +283,7 @@ func (b *cmdPkgBuilder) applyRunEFn(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
b.printPkgSummary(impact.StackID, impact.Summary)
|
||||
b.printTemplateSummary(impact.StackID, impact.Summary)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -325,7 +323,7 @@ func parseTemplateActions(args []string) ([]pkger.ApplyOptFn, error) {
|
|||
return opts, nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdExport() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdExport() *cobra.Command {
|
||||
cmd := b.newCmd("export", b.exportRunEFn)
|
||||
cmd.Short = "Export existing resources as a template"
|
||||
cmd.Long = `
|
||||
|
@ -375,8 +373,8 @@ func (b *cmdPkgBuilder) cmdExport() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) exportRunEFn(cmd *cobra.Command, args []string) error {
|
||||
pkgSVC, _, err := b.svcFn()
|
||||
func (b *cmdTemplateBuilder) exportRunEFn(cmd *cobra.Command, args []string) error {
|
||||
templateSVC, _, err := b.svcFn()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -414,7 +412,7 @@ func (b *cmdPkgBuilder) exportRunEFn(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
if b.exportOpts.resourceType == "" {
|
||||
return b.exportTemplate(cmd.OutOrStdout(), pkgSVC, b.file, opts...)
|
||||
return b.exportTemplate(cmd.OutOrStdout(), templateSVC, b.file, opts...)
|
||||
}
|
||||
|
||||
resKind := templateKindFold(b.exportOpts.resourceType)
|
||||
|
@ -436,10 +434,10 @@ func (b *cmdPkgBuilder) exportRunEFn(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
opts = append(opts, resTypeOpt)
|
||||
|
||||
return b.exportTemplate(cmd.OutOrStdout(), pkgSVC, b.file, opts...)
|
||||
return b.exportTemplate(cmd.OutOrStdout(), templateSVC, b.file, opts...)
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdExportAll() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdExportAll() *cobra.Command {
|
||||
cmd := b.newCmd("all", b.exportAllRunEFn)
|
||||
cmd.Short = "Export all existing resources for an organization as a template"
|
||||
cmd.Long = `
|
||||
|
@ -448,7 +446,7 @@ func (b *cmdPkgBuilder) cmdExportAll() *cobra.Command {
|
|||
|
||||
Examples:
|
||||
# Export all resources for an organization
|
||||
influx pkg export all --org $ORG_NAME
|
||||
influx export all --org $ORG_NAME
|
||||
|
||||
# Export all bucket resources
|
||||
influx export all --org $ORG_NAME --filter=kind=Bucket
|
||||
|
@ -484,8 +482,8 @@ func (b *cmdPkgBuilder) cmdExportAll() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) exportAllRunEFn(cmd *cobra.Command, args []string) error {
|
||||
pkgSVC, orgSVC, err := b.svcFn()
|
||||
func (b *cmdTemplateBuilder) exportAllRunEFn(cmd *cobra.Command, args []string) error {
|
||||
templateSVC, orgSVC, err := b.svcFn()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -523,10 +521,10 @@ func (b *cmdPkgBuilder) exportAllRunEFn(cmd *cobra.Command, args []string) error
|
|||
LabelNames: labelNames,
|
||||
ResourceKinds: resourceKinds,
|
||||
})
|
||||
return b.exportTemplate(cmd.OutOrStdout(), pkgSVC, b.file, orgOpt)
|
||||
return b.exportTemplate(cmd.OutOrStdout(), templateSVC, b.file, orgOpt)
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdExportStack() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdExportStack() *cobra.Command {
|
||||
cmd := b.newCmd("stack $STACK_ID", b.exportStackRunEFn)
|
||||
cmd.Short = "Export all existing resources for associated with a stack as a template"
|
||||
cmd.Long = `
|
||||
|
@ -551,8 +549,8 @@ func (b *cmdPkgBuilder) cmdExportStack() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) exportStackRunEFn(cmd *cobra.Command, args []string) error {
|
||||
pkgSVC, _, err := b.svcFn()
|
||||
func (b *cmdTemplateBuilder) exportStackRunEFn(cmd *cobra.Command, args []string) error {
|
||||
templateSVC, _, err := b.svcFn()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -562,63 +560,63 @@ func (b *cmdPkgBuilder) exportStackRunEFn(cmd *cobra.Command, args []string) err
|
|||
return err
|
||||
}
|
||||
|
||||
pkg, err := pkgSVC.Export(context.Background(), pkger.ExportWithStackID(*stackID))
|
||||
template, err := templateSVC.Export(context.Background(), pkger.ExportWithStackID(*stackID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return b.writePkg(b.w, b.file, pkg)
|
||||
return b.writeTemplate(b.w, b.file, template)
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdTemplate() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdTemplate() *cobra.Command {
|
||||
cmd := b.newTemplateCmd("template")
|
||||
cmd.Short = "Summarize the provided template"
|
||||
cmd.AddCommand(b.cmdTemplateValidate())
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdTemplateSummary() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdTemplateSummary() *cobra.Command {
|
||||
cmd := b.newTemplateCmd("summary")
|
||||
cmd.Short = "Summarize the provided template"
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) newTemplateCmd(usage string) *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) newTemplateCmd(usage string) *cobra.Command {
|
||||
runE := func(cmd *cobra.Command, args []string) error {
|
||||
pkg, _, err := b.readPkg()
|
||||
template, _, err := b.readTemplate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return b.printPkgSummary(0, pkg.Summary())
|
||||
return b.printTemplateSummary(0, template.Summary())
|
||||
}
|
||||
|
||||
cmd := b.genericCLIOpts.newCmd(usage, runE, false)
|
||||
|
||||
b.registerPkgFileFlags(cmd)
|
||||
b.registerPkgPrintOpts(cmd)
|
||||
b.registerTemplateFileFlags(cmd)
|
||||
b.registerTemplatePrintOpts(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdTemplateValidate() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdTemplateValidate() *cobra.Command {
|
||||
runE := func(cmd *cobra.Command, args []string) error {
|
||||
pkg, _, err := b.readPkg()
|
||||
template, _, err := b.readTemplate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return pkg.Validate()
|
||||
return template.Validate()
|
||||
}
|
||||
|
||||
cmd := b.genericCLIOpts.newCmd("validate", runE, false)
|
||||
cmd.Short = "Validate the provided template"
|
||||
|
||||
b.registerPkgFileFlags(cmd)
|
||||
b.registerTemplateFileFlags(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdStacks() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdStacks() *cobra.Command {
|
||||
cmd := b.newCmdStackList("stacks")
|
||||
cmd.Short = "List stack(s) and associated templates. Subcommands manage stacks."
|
||||
cmd.Long = `
|
||||
|
@ -654,7 +652,7 @@ func (b *cmdPkgBuilder) cmdStacks() *cobra.Command {
|
|||
}
|
||||
|
||||
// TODO(jsteenb2): nuke the deprecated command here after OSS beta13 release.
|
||||
func (b *cmdPkgBuilder) cmdStackDeprecated() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdStackDeprecated() *cobra.Command {
|
||||
cmd := b.genericCLIOpts.newCmd("stack", nil, false)
|
||||
cmd.Short = "Stack management commands"
|
||||
cmd.AddCommand(
|
||||
|
@ -665,7 +663,7 @@ func (b *cmdPkgBuilder) cmdStackDeprecated() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdStackInit() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdStackInit() *cobra.Command {
|
||||
cmd := b.newCmd("init", b.stackInitRunEFn)
|
||||
cmd.Short = "Initialize a stack"
|
||||
cmd.Long = `
|
||||
|
@ -698,8 +696,8 @@ func (b *cmdPkgBuilder) cmdStackInit() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) stackInitRunEFn(cmd *cobra.Command, args []string) error {
|
||||
pkgSVC, orgSVC, err := b.svcFn()
|
||||
func (b *cmdTemplateBuilder) stackInitRunEFn(cmd *cobra.Command, args []string) error {
|
||||
templateSVC, orgSVC, err := b.svcFn()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -710,7 +708,7 @@ func (b *cmdPkgBuilder) stackInitRunEFn(cmd *cobra.Command, args []string) error
|
|||
}
|
||||
|
||||
const fakeUserID = 0 // is 0 because user is pulled from token...
|
||||
stack, err := pkgSVC.InitStack(context.Background(), fakeUserID, pkger.Stack{
|
||||
stack, err := templateSVC.InitStack(context.Background(), fakeUserID, pkger.Stack{
|
||||
OrgID: orgID,
|
||||
Name: b.name,
|
||||
Description: b.description,
|
||||
|
@ -720,17 +718,17 @@ func (b *cmdPkgBuilder) stackInitRunEFn(cmd *cobra.Command, args []string) error
|
|||
return err
|
||||
}
|
||||
|
||||
return b.writeStack(b.w, stack)
|
||||
return b.writeStack(stack)
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdStackList() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdStackList() *cobra.Command {
|
||||
cmd := b.newCmdStackList("list")
|
||||
cmd.Short = "List stack(s) and associated resources"
|
||||
cmd.Aliases = []string{"ls"}
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) newCmdStackList(cmdName string) *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) newCmdStackList(cmdName string) *cobra.Command {
|
||||
usage := fmt.Sprintf("%s [flags]", cmdName)
|
||||
cmd := b.newCmd(usage, b.stackListRunEFn)
|
||||
cmd.Flags().StringArrayVar(&b.stackIDs, "stack-id", nil, "Stack ID to filter by")
|
||||
|
@ -742,8 +740,8 @@ func (b *cmdPkgBuilder) newCmdStackList(cmdName string) *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) stackListRunEFn(cmd *cobra.Command, args []string) error {
|
||||
pkgSVC, orgSVC, err := b.svcFn()
|
||||
func (b *cmdTemplateBuilder) stackListRunEFn(cmd *cobra.Command, args []string) error {
|
||||
templateSVC, orgSVC, err := b.svcFn()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -762,7 +760,7 @@ func (b *cmdPkgBuilder) stackListRunEFn(cmd *cobra.Command, args []string) error
|
|||
stackIDs = append(stackIDs, *id)
|
||||
}
|
||||
|
||||
stacks, err := pkgSVC.ListStacks(context.Background(), orgID, pkger.ListFilter{
|
||||
stacks, err := templateSVC.ListStacks(context.Background(), orgID, pkger.ListFilter{
|
||||
StackIDs: stackIDs,
|
||||
Names: b.names,
|
||||
})
|
||||
|
@ -796,7 +794,7 @@ func (b *cmdPkgBuilder) stackListRunEFn(cmd *cobra.Command, args []string) error
|
|||
return nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdStackRemove() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdStackRemove() *cobra.Command {
|
||||
cmd := b.newCmd("rm [--stack-id=ID1 --stack-id=ID2]", b.stackRemoveRunEFn)
|
||||
cmd.Short = "Remove a stack(s) and all associated resources"
|
||||
cmd.Aliases = []string{"remove", "uninstall"}
|
||||
|
@ -810,8 +808,8 @@ func (b *cmdPkgBuilder) cmdStackRemove() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) stackRemoveRunEFn(cmd *cobra.Command, args []string) error {
|
||||
pkgSVC, orgSVC, err := b.svcFn()
|
||||
func (b *cmdTemplateBuilder) stackRemoveRunEFn(cmd *cobra.Command, args []string) error {
|
||||
templateSVC, orgSVC, err := b.svcFn()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -830,7 +828,7 @@ func (b *cmdPkgBuilder) stackRemoveRunEFn(cmd *cobra.Command, args []string) err
|
|||
stackIDs = append(stackIDs, *id)
|
||||
}
|
||||
|
||||
stacks, err := pkgSVC.ListStacks(context.Background(), orgID, pkger.ListFilter{
|
||||
stacks, err := templateSVC.ListStacks(context.Background(), orgID, pkger.ListFilter{
|
||||
StackIDs: stackIDs,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -877,7 +875,7 @@ func (b *cmdPkgBuilder) stackRemoveRunEFn(cmd *cobra.Command, args []string) err
|
|||
continue
|
||||
}
|
||||
|
||||
err := pkgSVC.DeleteStack(context.Background(), struct{ OrgID, UserID, StackID influxdb.ID }{
|
||||
err := templateSVC.DeleteStack(context.Background(), struct{ OrgID, UserID, StackID influxdb.ID }{
|
||||
OrgID: orgID,
|
||||
UserID: 0,
|
||||
StackID: stack.ID,
|
||||
|
@ -890,7 +888,7 @@ func (b *cmdPkgBuilder) stackRemoveRunEFn(cmd *cobra.Command, args []string) err
|
|||
return nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) cmdStackUpdate() *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) cmdStackUpdate() *cobra.Command {
|
||||
cmd := b.newCmd("update", b.stackUpdateRunEFn)
|
||||
cmd.Short = "Update a stack"
|
||||
cmd.Long = `
|
||||
|
@ -934,8 +932,8 @@ func (b *cmdPkgBuilder) cmdStackUpdate() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) stackUpdateRunEFn(cmd *cobra.Command, args []string) error {
|
||||
pkgSVC, _, err := b.svcFn()
|
||||
func (b *cmdTemplateBuilder) stackUpdateRunEFn(cmd *cobra.Command, args []string) error {
|
||||
templateSVC, _, err := b.svcFn()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -974,12 +972,12 @@ func (b *cmdPkgBuilder) stackUpdateRunEFn(cmd *cobra.Command, args []string) err
|
|||
})
|
||||
}
|
||||
|
||||
stack, err := pkgSVC.UpdateStack(context.Background(), update)
|
||||
stack, err := templateSVC.UpdateStack(context.Background(), update)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := b.writeStack(b.w, stack); err != nil {
|
||||
if err := b.writeStack(stack); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -1000,10 +998,10 @@ these updates. Export a new template with these updates to prevent accidental ch
|
|||
}
|
||||
}
|
||||
|
||||
return b.exportTemplate(cmd.OutOrStdout(), pkgSVC, b.file, pkger.ExportWithStackID(*stackID))
|
||||
return b.exportTemplate(cmd.OutOrStdout(), templateSVC, b.file, pkger.ExportWithStackID(*stackID))
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) writeStack(w io.Writer, stack pkger.Stack) error {
|
||||
func (b *cmdTemplateBuilder) writeStack(stack pkger.Stack) error {
|
||||
if b.json {
|
||||
return b.writeJSON(stack)
|
||||
}
|
||||
|
@ -1028,19 +1026,19 @@ func (b *cmdPkgBuilder) writeStack(w io.Writer, stack pkger.Stack) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) newCmd(use string, runE func(*cobra.Command, []string) error) *cobra.Command {
|
||||
func (b *cmdTemplateBuilder) newCmd(use string, runE func(*cobra.Command, []string) error) *cobra.Command {
|
||||
cmd := b.genericCLIOpts.newCmd(use, runE, true)
|
||||
b.globalFlags.registerFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) registerPkgPrintOpts(cmd *cobra.Command) {
|
||||
func (b *cmdTemplateBuilder) registerTemplatePrintOpts(cmd *cobra.Command) {
|
||||
cmd.Flags().BoolVarP(&b.disableColor, "disable-color", "c", false, "Disable color in output")
|
||||
cmd.Flags().BoolVar(&b.disableTableBorders, "disable-table-borders", false, "Disable table borders")
|
||||
registerPrintOptions(cmd, nil, &b.json)
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) registerPkgFileFlags(cmd *cobra.Command) {
|
||||
func (b *cmdTemplateBuilder) registerTemplateFileFlags(cmd *cobra.Command) {
|
||||
cmd.Flags().StringSliceVarP(&b.files, "file", "f", nil, "Path to template file; Supports HTTP(S) URLs or file paths.")
|
||||
cmd.MarkFlagFilename("file", "yaml", "yml", "json", "jsonnet")
|
||||
cmd.Flags().BoolVarP(&b.recurse, "recurse", "R", false, "Process the directory used in -f, --file recursively. Useful when you want to manage related templates organized within the same directory.")
|
||||
|
@ -1052,17 +1050,17 @@ func (b *cmdPkgBuilder) registerPkgFileFlags(cmd *cobra.Command) {
|
|||
cmd.MarkFlagFilename("encoding", "yaml", "yml", "json", "jsonnet")
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) exportTemplate(w io.Writer, pkgSVC pkger.SVC, outPath string, opts ...pkger.ExportOptFn) error {
|
||||
pkg, err := pkgSVC.Export(context.Background(), opts...)
|
||||
func (b *cmdTemplateBuilder) exportTemplate(w io.Writer, templateSVC pkger.SVC, outPath string, opts ...pkger.ExportOptFn) error {
|
||||
template, err := templateSVC.Export(context.Background(), opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return b.writePkg(w, outPath, pkg)
|
||||
return b.writeTemplate(w, outPath, template)
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) writePkg(w io.Writer, outPath string, pkg *pkger.Pkg) error {
|
||||
buf, err := createPkgBuf(pkg, outPath)
|
||||
func (b *cmdTemplateBuilder) writeTemplate(w io.Writer, outPath string, template *pkger.Pkg) error {
|
||||
buf, err := createTemplateBuf(template, outPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1075,7 +1073,7 @@ func (b *cmdPkgBuilder) writePkg(w io.Writer, outPath string, pkg *pkger.Pkg) er
|
|||
return ioutil.WriteFile(outPath, buf.Bytes(), os.ModePerm)
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) readRawPkgsFromFiles(filePaths []string, recurse bool) ([]*pkger.Pkg, error) {
|
||||
func (b *cmdTemplateBuilder) readRawTemplatesFromFiles(filePaths []string, recurse bool) ([]*pkger.Pkg, error) {
|
||||
mFiles := make(map[string]struct{})
|
||||
for _, f := range filePaths {
|
||||
files, err := readFilesFromPath(f, recurse)
|
||||
|
@ -1087,36 +1085,36 @@ func (b *cmdPkgBuilder) readRawPkgsFromFiles(filePaths []string, recurse bool) (
|
|||
}
|
||||
}
|
||||
|
||||
var rawPkgs []*pkger.Pkg
|
||||
var rawTemplates []*pkger.Pkg
|
||||
for f := range mFiles {
|
||||
pkg, err := pkger.Parse(b.convertFileEncoding(f), pkger.FromFile(f), pkger.ValidSkipParseError())
|
||||
template, err := pkger.Parse(b.convertFileEncoding(f), pkger.FromFile(f), pkger.ValidSkipParseError())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rawPkgs = append(rawPkgs, pkg)
|
||||
rawTemplates = append(rawTemplates, template)
|
||||
}
|
||||
|
||||
return rawPkgs, nil
|
||||
return rawTemplates, nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) readRawPkgsFromURLs(urls []string) ([]*pkger.Pkg, error) {
|
||||
func (b *cmdTemplateBuilder) readRawTemplatesFromURLs(urls []string) ([]*pkger.Pkg, error) {
|
||||
mURLs := make(map[string]struct{})
|
||||
for _, f := range urls {
|
||||
mURLs[f] = struct{}{}
|
||||
}
|
||||
|
||||
var rawPkgs []*pkger.Pkg
|
||||
var rawTemplates []*pkger.Pkg
|
||||
for u := range mURLs {
|
||||
pkg, err := pkger.Parse(b.convertURLEncoding(u), pkger.FromHTTPRequest(u), pkger.ValidSkipParseError())
|
||||
template, err := pkger.Parse(b.convertURLEncoding(u), pkger.FromHTTPRequest(u), pkger.ValidSkipParseError())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rawPkgs = append(rawPkgs, pkg)
|
||||
rawTemplates = append(rawTemplates, template)
|
||||
}
|
||||
return rawPkgs, nil
|
||||
return rawTemplates, nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) readPkg() (*pkger.Pkg, bool, error) {
|
||||
func (b *cmdTemplateBuilder) readTemplate() (*pkger.Pkg, bool, error) {
|
||||
var remotes, files []string
|
||||
for _, rawURL := range append(b.files, b.urls...) {
|
||||
u, err := url.Parse(rawURL)
|
||||
|
@ -1130,36 +1128,37 @@ func (b *cmdPkgBuilder) readPkg() (*pkger.Pkg, bool, error) {
|
|||
}
|
||||
}
|
||||
|
||||
pkgs, err := b.readRawPkgsFromFiles(files, b.recurse)
|
||||
templates, err := b.readRawTemplatesFromFiles(files, b.recurse)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
urlPkgs, err := b.readRawPkgsFromURLs(remotes)
|
||||
urlTemplates, err := b.readRawTemplatesFromURLs(remotes)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
pkgs = append(pkgs, urlPkgs...)
|
||||
templates = append(templates, urlTemplates...)
|
||||
|
||||
// the pkger.ValidSkipParseError option allows our server to be the one to validate the
|
||||
// the pkg is accurate. If a user has an older version of the CLI and cloud gets updated
|
||||
// the template is accurate. If a user has an older version of the CLI and cloud gets updated
|
||||
// with new validation rules,they'll get immediate access to that change without having to
|
||||
// rol their CLI build.
|
||||
|
||||
if _, err := b.inStdIn(); err != nil {
|
||||
pkg, err := pkger.Combine(pkgs, pkger.ValidSkipParseError())
|
||||
return pkg, false, err
|
||||
template, err := pkger.Combine(templates, pkger.ValidSkipParseError())
|
||||
return template, false, err
|
||||
}
|
||||
|
||||
stdinPkg, err := pkger.Parse(b.convertEncoding(), pkger.FromReader(b.in), pkger.ValidSkipParseError())
|
||||
stdinTemplate, err := pkger.Parse(b.convertEncoding(), pkger.FromReader(b.in), pkger.ValidSkipParseError())
|
||||
if err != nil {
|
||||
return nil, true, err
|
||||
}
|
||||
pkg, err := pkger.Combine(append(pkgs, stdinPkg), pkger.ValidSkipParseError())
|
||||
return pkg, true, err
|
||||
|
||||
template, err := pkger.Combine(append(templates, stdinTemplate), pkger.ValidSkipParseError())
|
||||
return template, true, err
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) inStdIn() (*os.File, error) {
|
||||
func (b *cmdTemplateBuilder) inStdIn() (*os.File, error) {
|
||||
stdin, _ := b.in.(*os.File)
|
||||
if stdin != os.Stdin {
|
||||
return nil, errors.New("input not stdIn")
|
||||
|
@ -1175,7 +1174,7 @@ func (b *cmdPkgBuilder) inStdIn() (*os.File, error) {
|
|||
return stdin, nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) readLines(r io.Reader) ([]string, error) {
|
||||
func (b *cmdTemplateBuilder) readLines(r io.Reader) ([]string, error) {
|
||||
bb, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1192,7 +1191,7 @@ func (b *cmdPkgBuilder) readLines(r io.Reader) ([]string, error) {
|
|||
return stdinInput, nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) getInput(msg, defaultVal string) string {
|
||||
func (b *cmdTemplateBuilder) getInput(msg, defaultVal string) string {
|
||||
ui := &input.UI{
|
||||
Writer: b.w,
|
||||
Reader: b.in,
|
||||
|
@ -1200,7 +1199,7 @@ func (b *cmdPkgBuilder) getInput(msg, defaultVal string) string {
|
|||
return getInput(ui, msg, defaultVal)
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) convertURLEncoding(url string) pkger.Encoding {
|
||||
func (b *cmdTemplateBuilder) convertURLEncoding(url string) pkger.Encoding {
|
||||
urlBase := path.Ext(url)
|
||||
switch {
|
||||
case strings.HasPrefix(urlBase, ".jsonnet"):
|
||||
|
@ -1213,7 +1212,7 @@ func (b *cmdPkgBuilder) convertURLEncoding(url string) pkger.Encoding {
|
|||
return b.convertEncoding()
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) convertFileEncoding(file string) pkger.Encoding {
|
||||
func (b *cmdTemplateBuilder) convertFileEncoding(file string) pkger.Encoding {
|
||||
ext := filepath.Ext(file)
|
||||
switch {
|
||||
case strings.HasPrefix(ext, ".jsonnet"):
|
||||
|
@ -1227,7 +1226,7 @@ func (b *cmdPkgBuilder) convertFileEncoding(file string) pkger.Encoding {
|
|||
return b.convertEncoding()
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) convertEncoding() pkger.Encoding {
|
||||
func (b *cmdTemplateBuilder) convertEncoding() pkger.Encoding {
|
||||
switch {
|
||||
case b.encoding == "json":
|
||||
return pkger.EncodingJSON
|
||||
|
@ -1281,7 +1280,7 @@ func toInfluxIDs(args []string) ([]influxdb.ID, error) {
|
|||
return ids, nil
|
||||
}
|
||||
|
||||
func createPkgBuf(pkg *pkger.Pkg, outPath string) (*bytes.Buffer, error) {
|
||||
func createTemplateBuf(template *pkger.Pkg, outPath string) (*bytes.Buffer, error) {
|
||||
var encoding pkger.Encoding
|
||||
switch ext := filepath.Ext(outPath); ext {
|
||||
case ".json":
|
||||
|
@ -1290,7 +1289,7 @@ func createPkgBuf(pkg *pkger.Pkg, outPath string) (*bytes.Buffer, error) {
|
|||
encoding = pkger.EncodingYAML
|
||||
}
|
||||
|
||||
b, err := pkg.Encode(encoding)
|
||||
b, err := template.Encode(encoding)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1310,7 +1309,7 @@ func newPkgerSVC() (pkger.SVC, influxdb.OrganizationService, error) {
|
|||
return &pkger.HTTPRemoteService{Client: httpClient}, orgSvc, nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
||||
func (b *cmdTemplateBuilder) printTemplateDiff(diff pkger.Diff) error {
|
||||
if b.quiet {
|
||||
return nil
|
||||
}
|
||||
|
@ -1320,7 +1319,7 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
}
|
||||
|
||||
diffPrinterGen := func(title string, headers []string) *diffPrinter {
|
||||
commonHeaders := []string{"Package Name", "ID", "Resource Name"}
|
||||
commonHeaders := []string{"Metadata Name", "ID", "Resource Name"}
|
||||
|
||||
printer := newDiffPrinter(b.w, !b.disableColor, !b.disableTableBorders)
|
||||
printer.
|
||||
|
@ -1332,17 +1331,17 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
if labels := diff.Labels; len(labels) > 0 {
|
||||
printer := diffPrinterGen("Labels", []string{"Color", "Description"})
|
||||
|
||||
appendValues := func(id pkger.SafeID, pkgName string, v pkger.DiffLabelValues) []string {
|
||||
return []string{pkgName, id.String(), v.Name, v.Color, v.Description}
|
||||
appendValues := func(id pkger.SafeID, metaName string, v pkger.DiffLabelValues) []string {
|
||||
return []string{metaName, id.String(), v.Name, v.Color, v.Description}
|
||||
}
|
||||
|
||||
for _, l := range labels {
|
||||
var oldRow []string
|
||||
if l.Old != nil {
|
||||
oldRow = appendValues(l.ID, l.PkgName, *l.Old)
|
||||
oldRow = appendValues(l.ID, l.MetaName, *l.Old)
|
||||
}
|
||||
|
||||
newRow := appendValues(l.ID, l.PkgName, l.New)
|
||||
newRow := appendValues(l.ID, l.MetaName, l.New)
|
||||
switch {
|
||||
case pkger.IsNew(l.StateStatus):
|
||||
printer.AppendDiff(nil, newRow)
|
||||
|
@ -1358,17 +1357,17 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
if bkts := diff.Buckets; len(bkts) > 0 {
|
||||
printer := diffPrinterGen("Buckets", []string{"Retention Period", "Description"})
|
||||
|
||||
appendValues := func(id pkger.SafeID, pkgName string, v pkger.DiffBucketValues) []string {
|
||||
return []string{pkgName, id.String(), v.Name, v.RetentionRules.RP().String(), v.Description}
|
||||
appendValues := func(id pkger.SafeID, metaName string, v pkger.DiffBucketValues) []string {
|
||||
return []string{metaName, id.String(), v.Name, v.RetentionRules.RP().String(), v.Description}
|
||||
}
|
||||
|
||||
for _, b := range bkts {
|
||||
var oldRow []string
|
||||
if b.Old != nil {
|
||||
oldRow = appendValues(b.ID, b.PkgName, *b.Old)
|
||||
oldRow = appendValues(b.ID, b.MetaName, *b.Old)
|
||||
}
|
||||
|
||||
newRow := appendValues(b.ID, b.PkgName, b.New)
|
||||
newRow := appendValues(b.ID, b.MetaName, b.New)
|
||||
switch {
|
||||
case pkger.IsNew(b.StateStatus):
|
||||
printer.AppendDiff(nil, newRow)
|
||||
|
@ -1384,8 +1383,8 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
if checks := diff.Checks; len(checks) > 0 {
|
||||
printer := diffPrinterGen("Checks", []string{"Description"})
|
||||
|
||||
appendValues := func(id pkger.SafeID, pkgName string, v pkger.DiffCheckValues) []string {
|
||||
out := []string{pkgName, id.String()}
|
||||
appendValues := func(id pkger.SafeID, metaName string, v pkger.DiffCheckValues) []string {
|
||||
out := []string{metaName, id.String()}
|
||||
if v.Check == nil {
|
||||
return append(out, "", "")
|
||||
}
|
||||
|
@ -1395,10 +1394,10 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
for _, c := range checks {
|
||||
var oldRow []string
|
||||
if c.Old != nil {
|
||||
oldRow = appendValues(c.ID, c.PkgName, *c.Old)
|
||||
oldRow = appendValues(c.ID, c.MetaName, *c.Old)
|
||||
}
|
||||
|
||||
newRow := appendValues(c.ID, c.PkgName, c.New)
|
||||
newRow := appendValues(c.ID, c.MetaName, c.New)
|
||||
switch {
|
||||
case pkger.IsNew(c.StateStatus):
|
||||
printer.AppendDiff(nil, newRow)
|
||||
|
@ -1414,17 +1413,17 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
if dashes := diff.Dashboards; len(dashes) > 0 {
|
||||
printer := diffPrinterGen("Dashboards", []string{"Description", "Num Charts"})
|
||||
|
||||
appendValues := func(id pkger.SafeID, pkgName string, v pkger.DiffDashboardValues) []string {
|
||||
return []string{pkgName, id.String(), v.Name, v.Desc, strconv.Itoa(len(v.Charts))}
|
||||
appendValues := func(id pkger.SafeID, metaName string, v pkger.DiffDashboardValues) []string {
|
||||
return []string{metaName, id.String(), v.Name, v.Desc, strconv.Itoa(len(v.Charts))}
|
||||
}
|
||||
|
||||
for _, d := range dashes {
|
||||
var oldRow []string
|
||||
if d.Old != nil {
|
||||
oldRow = appendValues(d.ID, d.PkgName, *d.Old)
|
||||
oldRow = appendValues(d.ID, d.MetaName, *d.Old)
|
||||
}
|
||||
|
||||
newRow := appendValues(d.ID, d.PkgName, d.New)
|
||||
newRow := appendValues(d.ID, d.MetaName, d.New)
|
||||
switch {
|
||||
case pkger.IsNew(d.StateStatus):
|
||||
printer.AppendDiff(nil, newRow)
|
||||
|
@ -1440,8 +1439,8 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
if endpoints := diff.NotificationEndpoints; len(endpoints) > 0 {
|
||||
printer := diffPrinterGen("Notification Endpoints", nil)
|
||||
|
||||
appendValues := func(id pkger.SafeID, pkgName string, v pkger.DiffNotificationEndpointValues) []string {
|
||||
out := []string{pkgName, id.String()}
|
||||
appendValues := func(id pkger.SafeID, metaName string, v pkger.DiffNotificationEndpointValues) []string {
|
||||
out := []string{metaName, id.String()}
|
||||
if v.NotificationEndpoint == nil {
|
||||
return append(out, "")
|
||||
}
|
||||
|
@ -1451,10 +1450,10 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
for _, e := range endpoints {
|
||||
var oldRow []string
|
||||
if e.Old != nil {
|
||||
oldRow = appendValues(e.ID, e.PkgName, *e.Old)
|
||||
oldRow = appendValues(e.ID, e.MetaName, *e.Old)
|
||||
}
|
||||
|
||||
newRow := appendValues(e.ID, e.PkgName, e.New)
|
||||
newRow := appendValues(e.ID, e.MetaName, e.New)
|
||||
switch {
|
||||
case pkger.IsNew(e.StateStatus):
|
||||
printer.AppendDiff(nil, newRow)
|
||||
|
@ -1477,9 +1476,9 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
"Endpoint Type",
|
||||
})
|
||||
|
||||
appendValues := func(id pkger.SafeID, pkgName string, v pkger.DiffNotificationRuleValues) []string {
|
||||
appendValues := func(id pkger.SafeID, metaName string, v pkger.DiffNotificationRuleValues) []string {
|
||||
return []string{
|
||||
pkgName,
|
||||
metaName,
|
||||
id.String(),
|
||||
v.Name,
|
||||
v.Every,
|
||||
|
@ -1493,10 +1492,10 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
for _, e := range rules {
|
||||
var oldRow []string
|
||||
if e.Old != nil {
|
||||
oldRow = appendValues(e.ID, e.PkgName, *e.Old)
|
||||
oldRow = appendValues(e.ID, e.MetaName, *e.Old)
|
||||
}
|
||||
|
||||
newRow := appendValues(e.ID, e.PkgName, e.New)
|
||||
newRow := appendValues(e.ID, e.MetaName, e.New)
|
||||
switch {
|
||||
case pkger.IsNew(e.StateStatus):
|
||||
printer.AppendDiff(nil, newRow)
|
||||
|
@ -1511,17 +1510,17 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
|
||||
if teles := diff.Telegrafs; len(teles) > 0 {
|
||||
printer := diffPrinterGen("Telegraf Configurations", []string{"Description"})
|
||||
appendValues := func(id pkger.SafeID, pkgName string, v influxdb.TelegrafConfig) []string {
|
||||
return []string{pkgName, id.String(), v.Name, v.Description}
|
||||
appendValues := func(id pkger.SafeID, metaName string, v influxdb.TelegrafConfig) []string {
|
||||
return []string{metaName, id.String(), v.Name, v.Description}
|
||||
}
|
||||
|
||||
for _, e := range teles {
|
||||
var oldRow []string
|
||||
if e.Old != nil {
|
||||
oldRow = appendValues(e.ID, e.PkgName, *e.Old)
|
||||
oldRow = appendValues(e.ID, e.MetaName, *e.Old)
|
||||
}
|
||||
|
||||
newRow := appendValues(e.ID, e.PkgName, e.New)
|
||||
newRow := appendValues(e.ID, e.MetaName, e.New)
|
||||
switch {
|
||||
case pkger.IsNew(e.StateStatus):
|
||||
printer.AppendDiff(nil, newRow)
|
||||
|
@ -1536,7 +1535,7 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
|
||||
if tasks := diff.Tasks; len(tasks) > 0 {
|
||||
printer := diffPrinterGen("Tasks", []string{"Description", "Cycle"})
|
||||
appendValues := func(id pkger.SafeID, pkgName string, v pkger.DiffTaskValues) []string {
|
||||
appendValues := func(id pkger.SafeID, metaName string, v pkger.DiffTaskValues) []string {
|
||||
timing := v.Cron
|
||||
if v.Cron == "" {
|
||||
if v.Offset == "" {
|
||||
|
@ -1544,16 +1543,16 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
}
|
||||
timing = fmt.Sprintf("every: %s offset: %s", v.Every, v.Offset)
|
||||
}
|
||||
return []string{pkgName, id.String(), v.Name, v.Description, timing}
|
||||
return []string{metaName, id.String(), v.Name, v.Description, timing}
|
||||
}
|
||||
|
||||
for _, e := range tasks {
|
||||
var oldRow []string
|
||||
if e.Old != nil {
|
||||
oldRow = appendValues(e.ID, e.PkgName, *e.Old)
|
||||
oldRow = appendValues(e.ID, e.MetaName, *e.Old)
|
||||
}
|
||||
|
||||
newRow := appendValues(e.ID, e.PkgName, e.New)
|
||||
newRow := appendValues(e.ID, e.MetaName, e.New)
|
||||
switch {
|
||||
case pkger.IsNew(e.StateStatus):
|
||||
printer.AppendDiff(nil, newRow)
|
||||
|
@ -1569,21 +1568,21 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
if vars := diff.Variables; len(vars) > 0 {
|
||||
printer := diffPrinterGen("Variables", []string{"Description", "Arg Type", "Arg Values"})
|
||||
|
||||
appendValues := func(id pkger.SafeID, pkgName string, v pkger.DiffVariableValues) []string {
|
||||
appendValues := func(id pkger.SafeID, metaName string, v pkger.DiffVariableValues) []string {
|
||||
var argType string
|
||||
if v.Args != nil {
|
||||
argType = v.Args.Type
|
||||
}
|
||||
return []string{pkgName, id.String(), v.Name, v.Description, argType, printVarArgs(v.Args)}
|
||||
return []string{metaName, id.String(), v.Name, v.Description, argType, printVarArgs(v.Args)}
|
||||
}
|
||||
|
||||
for _, v := range vars {
|
||||
var oldRow []string
|
||||
if v.Old != nil {
|
||||
oldRow = appendValues(v.ID, v.PkgName, *v.Old)
|
||||
oldRow = appendValues(v.ID, v.MetaName, *v.Old)
|
||||
}
|
||||
|
||||
newRow := appendValues(v.ID, v.PkgName, v.New)
|
||||
newRow := appendValues(v.ID, v.MetaName, v.New)
|
||||
switch {
|
||||
case pkger.IsNew(v.StateStatus):
|
||||
printer.AppendDiff(nil, newRow)
|
||||
|
@ -1609,8 +1608,8 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
for _, m := range diff.LabelMappings {
|
||||
newRow := []string{
|
||||
string(m.ResType),
|
||||
m.ResPkgName, m.ResName, m.ResID.String(),
|
||||
m.LabelPkgName, m.LabelName, m.LabelID.String(),
|
||||
m.ResMetaName, m.ResName, m.ResID.String(),
|
||||
m.LabelMetaName, m.LabelName, m.LabelID.String(),
|
||||
}
|
||||
switch {
|
||||
case pkger.IsNew(m.StateStatus):
|
||||
|
@ -1627,7 +1626,7 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary) error {
|
||||
func (b *cmdTemplateBuilder) printTemplateSummary(stackID influxdb.ID, sum pkger.Summary) error {
|
||||
if b.quiet {
|
||||
return nil
|
||||
}
|
||||
|
@ -1650,7 +1649,7 @@ func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary)
|
|||
tablePrintFn("LABELS", headers, len(labels), func(i int) []string {
|
||||
l := labels[i]
|
||||
return []string{
|
||||
l.PkgName,
|
||||
l.MetaName,
|
||||
l.ID.String(),
|
||||
l.Name,
|
||||
l.Properties.Description,
|
||||
|
@ -1664,7 +1663,7 @@ func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary)
|
|||
tablePrintFn("BUCKETS", headers, len(buckets), func(i int) []string {
|
||||
bucket := buckets[i]
|
||||
return []string{
|
||||
bucket.PkgName,
|
||||
bucket.MetaName,
|
||||
bucket.ID.String(),
|
||||
bucket.Name,
|
||||
formatDuration(bucket.RetentionPeriod),
|
||||
|
@ -1678,7 +1677,7 @@ func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary)
|
|||
tablePrintFn("CHECKS", headers, len(checks), func(i int) []string {
|
||||
c := checks[i].Check
|
||||
return []string{
|
||||
checks[i].PkgName,
|
||||
checks[i].MetaName,
|
||||
c.GetID().String(),
|
||||
c.GetName(),
|
||||
c.GetDescription(),
|
||||
|
@ -1690,7 +1689,7 @@ func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary)
|
|||
headers := append(commonHeaders, "Description")
|
||||
tablePrintFn("DASHBOARDS", headers, len(dashes), func(i int) []string {
|
||||
d := dashes[i]
|
||||
return []string{d.PkgName, d.ID.String(), d.Name, d.Description}
|
||||
return []string{d.MetaName, d.ID.String(), d.Name, d.Description}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1699,7 +1698,7 @@ func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary)
|
|||
tablePrintFn("NOTIFICATION ENDPOINTS", headers, len(endpoints), func(i int) []string {
|
||||
v := endpoints[i]
|
||||
return []string{
|
||||
v.PkgName,
|
||||
v.MetaName,
|
||||
v.NotificationEndpoint.GetID().String(),
|
||||
v.NotificationEndpoint.GetName(),
|
||||
v.NotificationEndpoint.GetDescription(),
|
||||
|
@ -1713,7 +1712,7 @@ func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary)
|
|||
tablePrintFn("NOTIFICATION RULES", headers, len(rules), func(i int) []string {
|
||||
v := rules[i]
|
||||
return []string{
|
||||
v.PkgName,
|
||||
v.MetaName,
|
||||
v.ID.String(),
|
||||
v.Name,
|
||||
v.Description,
|
||||
|
@ -1735,7 +1734,7 @@ func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary)
|
|||
timing = t.Cron
|
||||
}
|
||||
return []string{
|
||||
t.PkgName,
|
||||
t.MetaName,
|
||||
t.ID.String(),
|
||||
t.Name,
|
||||
t.Description,
|
||||
|
@ -1749,7 +1748,7 @@ func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary)
|
|||
tablePrintFn("TELEGRAF CONFIGS", headers, len(teles), func(i int) []string {
|
||||
t := teles[i]
|
||||
return []string{
|
||||
t.PkgName,
|
||||
t.MetaName,
|
||||
t.TelegrafConfig.ID.String(),
|
||||
t.TelegrafConfig.Name,
|
||||
t.TelegrafConfig.Description,
|
||||
|
@ -1763,7 +1762,7 @@ func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary)
|
|||
v := vars[i]
|
||||
args := v.Arguments
|
||||
return []string{
|
||||
v.PkgName,
|
||||
v.MetaName,
|
||||
v.ID.String(),
|
||||
v.Name,
|
||||
v.Description,
|
||||
|
@ -1801,7 +1800,7 @@ func (b *cmdPkgBuilder) printPkgSummary(stackID influxdb.ID, sum pkger.Summary)
|
|||
return nil
|
||||
}
|
||||
|
||||
func (b *cmdPkgBuilder) tablePrinterGen() func(table string, headers []string, count int, rowFn func(i int) []string) {
|
||||
func (b *cmdTemplateBuilder) tablePrinterGen() func(table string, headers []string, count int, rowFn func(i int) []string) {
|
||||
return func(table string, headers []string, count int, rowFn func(i int) []string) {
|
||||
tablePrinter(b.w, table, headers, count, !b.disableColor, !b.disableTableBorders, rowFn)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
)
|
||||
|
||||
func Test_Template_Commands(t *testing.T) {
|
||||
fakeSVCFn := func(svc pkger.SVC) pkgSVCsFn {
|
||||
fakeSVCFn := func(svc pkger.SVC) templateSVCsFn {
|
||||
return func() (pkger.SVC, influxdb.OrganizationService, error) {
|
||||
return svc, &mock.OrganizationService{
|
||||
FindOrganizationF: func(ctx context.Context, filter influxdb.OrganizationFilter) (*influxdb.Organization, error) {
|
||||
|
@ -228,7 +228,7 @@ func Test_Template_Commands(t *testing.T) {
|
|||
return &pkg, nil
|
||||
},
|
||||
}
|
||||
return newCmdPkgBuilder(fakeSVCFn(pkgSVC), f, opt).cmdExport()
|
||||
return newCmdPkgerBuilder(fakeSVCFn(pkgSVC), f, opt).cmdExport()
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
@ -349,7 +349,7 @@ func Test_Template_Commands(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
builder := newCmdPkgBuilder(fakeSVCFn(pkgSVC), f, opt)
|
||||
builder := newCmdPkgerBuilder(fakeSVCFn(pkgSVC), f, opt)
|
||||
return builder.cmdExport()
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@ -440,7 +440,7 @@ func Test_Template_Commands(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
builder := newCmdPkgBuilder(fakeSVCFn(pkgSVC), f, opt)
|
||||
builder := newCmdPkgerBuilder(fakeSVCFn(pkgSVC), f, opt)
|
||||
return builder.cmdExport()
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ func Test_Template_Commands(t *testing.T) {
|
|||
out(ioutil.Discard),
|
||||
)
|
||||
cmd := builder.cmd(func(f *globalFlags, opt genericCLIOpts) *cobra.Command {
|
||||
return newCmdPkgBuilder(fakeSVCFn(new(fakePkgSVC)), f, opt).cmdTemplate()
|
||||
return newCmdPkgerBuilder(fakeSVCFn(new(fakePkgSVC)), f, opt).cmdTemplate()
|
||||
})
|
||||
|
||||
cmd.SetArgs([]string{
|
||||
|
@ -490,7 +490,7 @@ func Test_Template_Commands(t *testing.T) {
|
|||
out(ioutil.Discard),
|
||||
)
|
||||
cmd := builder.cmd(func(f *globalFlags, opt genericCLIOpts) *cobra.Command {
|
||||
return newCmdPkgBuilder(fakeSVCFn(new(fakePkgSVC)), f, opt).cmdTemplate()
|
||||
return newCmdPkgerBuilder(fakeSVCFn(new(fakePkgSVC)), f, opt).cmdTemplate()
|
||||
})
|
||||
cmd.SetArgs([]string{"template", "validate"})
|
||||
|
||||
|
@ -588,7 +588,7 @@ func Test_Template_Commands(t *testing.T) {
|
|||
return stack, nil
|
||||
},
|
||||
}
|
||||
return newCmdPkgBuilder(fakeSVCFn(echoSVC), f, opt).cmdStacks()
|
||||
return newCmdPkgerBuilder(fakeSVCFn(echoSVC), f, opt).cmdStacks()
|
||||
})
|
||||
|
||||
baseArgs := []string{"stacks", "init", "--json"}
|
||||
|
|
|
@ -494,9 +494,9 @@ func TestLauncher_Pkger(t *testing.T) {
|
|||
|
||||
sum := impact.Summary
|
||||
require.Len(t, sum.Buckets, 2)
|
||||
assert.Equal(t, "bucket-0", sum.Buckets[0].PkgName)
|
||||
assert.Equal(t, "bucket-0", sum.Buckets[0].MetaName)
|
||||
assert.Equal(t, "bucket-0", sum.Buckets[0].Name)
|
||||
assert.Equal(t, "bucket-1", sum.Buckets[1].PkgName)
|
||||
assert.Equal(t, "bucket-1", sum.Buckets[1].MetaName)
|
||||
assert.Equal(t, "bucket-1", sum.Buckets[1].Name)
|
||||
}
|
||||
|
||||
|
@ -850,21 +850,21 @@ func TestLauncher_Pkger(t *testing.T) {
|
|||
updateVariableName = "new variable"
|
||||
)
|
||||
updatedPkg := newTemplate(
|
||||
newBucketObject(initialSum.Buckets[0].PkgName, updateBucketName, ""),
|
||||
newCheckDeadmanObject(t, initialSum.Checks[0].PkgName, updateCheckName, time.Hour),
|
||||
newDashObject(initialSum.Dashboards[0].PkgName, updateDashName, ""),
|
||||
newEndpointHTTP(initialSum.NotificationEndpoints[0].PkgName, updateEndpointName, ""),
|
||||
newLabelObject(initialSum.Labels[0].PkgName, updateLabelName, "", ""),
|
||||
newBucketObject(initialSum.Buckets[0].MetaName, updateBucketName, ""),
|
||||
newCheckDeadmanObject(t, initialSum.Checks[0].MetaName, updateCheckName, time.Hour),
|
||||
newDashObject(initialSum.Dashboards[0].MetaName, updateDashName, ""),
|
||||
newEndpointHTTP(initialSum.NotificationEndpoints[0].MetaName, updateEndpointName, ""),
|
||||
newLabelObject(initialSum.Labels[0].MetaName, updateLabelName, "", ""),
|
||||
newRuleObject(
|
||||
t,
|
||||
initialSum.NotificationRules[0].PkgName,
|
||||
initialSum.NotificationRules[0].MetaName,
|
||||
updateRuleName,
|
||||
initialSum.NotificationEndpoints[0].PkgName,
|
||||
initialSum.NotificationEndpoints[0].MetaName,
|
||||
"",
|
||||
),
|
||||
newTaskObject(initialSum.Tasks[0].PkgName, updateTaskName, ""),
|
||||
newTelegrafObject(initialSum.TelegrafConfigs[0].PkgName, updateTelegrafName, ""),
|
||||
newVariableObject(initialSum.Variables[0].PkgName, updateVariableName, ""),
|
||||
newTaskObject(initialSum.Tasks[0].MetaName, updateTaskName, ""),
|
||||
newTelegrafObject(initialSum.TelegrafConfigs[0].MetaName, updateTelegrafName, ""),
|
||||
newVariableObject(initialSum.Variables[0].MetaName, updateVariableName, ""),
|
||||
)
|
||||
impact, err := svc.Apply(ctx, l.Org.ID, l.User.ID,
|
||||
pkger.ApplyWithPkg(updatedPkg),
|
||||
|
@ -1844,7 +1844,7 @@ func TestLauncher_Pkger(t *testing.T) {
|
|||
hasAssociation := func(t *testing.T, actual []pkger.SummaryLabel) {
|
||||
t.Helper()
|
||||
require.Len(t, actual, 1, "unexpected number of label mappings")
|
||||
assert.Equal(t, actual[0].PkgName, labelObj.Name())
|
||||
assert.Equal(t, actual[0].MetaName, labelObj.Name())
|
||||
}
|
||||
|
||||
require.Len(t, summary.Buckets, 1)
|
||||
|
@ -1945,49 +1945,49 @@ func TestLauncher_Pkger(t *testing.T) {
|
|||
if len(actual) != 1 {
|
||||
return
|
||||
}
|
||||
assert.Equal(t, actual[0].PkgName, initialSum.Labels[0].PkgName)
|
||||
assert.Equal(t, actual[0].MetaName, initialSum.Labels[0].MetaName)
|
||||
}
|
||||
|
||||
sum := exportedTemplate.Summary()
|
||||
|
||||
require.Len(t, sum.Buckets, 1, "missing required buckets")
|
||||
assert.Equal(t, initialSum.Buckets[0].PkgName, sum.Buckets[0].PkgName)
|
||||
assert.Equal(t, initialSum.Buckets[0].MetaName, sum.Buckets[0].MetaName)
|
||||
assert.Equal(t, initialSum.Buckets[0].Name, sum.Buckets[0].Name)
|
||||
hasAssociation(t, sum.Buckets[0].LabelAssociations)
|
||||
|
||||
require.Len(t, sum.Checks, 1, "missing required checks")
|
||||
assert.Equal(t, initialSum.Checks[0].PkgName, sum.Checks[0].PkgName)
|
||||
assert.Equal(t, initialSum.Checks[0].MetaName, sum.Checks[0].MetaName)
|
||||
assert.Equal(t, initialSum.Checks[0].Check.GetName(), sum.Checks[0].Check.GetName())
|
||||
hasAssociation(t, sum.Checks[0].LabelAssociations)
|
||||
|
||||
require.Len(t, sum.Dashboards, 1, "missing required dashboards")
|
||||
assert.Equal(t, initialSum.Dashboards[0].PkgName, sum.Dashboards[0].PkgName)
|
||||
assert.Equal(t, initialSum.Dashboards[0].MetaName, sum.Dashboards[0].MetaName)
|
||||
assert.Equal(t, initialSum.Dashboards[0].Name, sum.Dashboards[0].Name)
|
||||
hasAssociation(t, sum.Dashboards[0].LabelAssociations)
|
||||
|
||||
require.Len(t, sum.Labels, 1, "missing required labels")
|
||||
assert.Equal(t, initialSum.Labels[0].PkgName, sum.Labels[0].PkgName)
|
||||
assert.Equal(t, initialSum.Labels[0].MetaName, sum.Labels[0].MetaName)
|
||||
assert.Equal(t, initialSum.Labels[0].Name, sum.Labels[0].Name)
|
||||
|
||||
require.Len(t, sum.NotificationRules, 1, "missing required rules")
|
||||
assert.Equal(t, initialSum.NotificationRules[0].PkgName, sum.NotificationRules[0].PkgName)
|
||||
assert.Equal(t, initialSum.NotificationRules[0].MetaName, sum.NotificationRules[0].MetaName)
|
||||
assert.Equal(t, initialSum.NotificationRules[0].Name, sum.NotificationRules[0].Name)
|
||||
assert.Equal(t, initialSum.NotificationRules[0].EndpointPkgName, sum.NotificationRules[0].EndpointPkgName)
|
||||
assert.Equal(t, initialSum.NotificationRules[0].EndpointType, sum.NotificationRules[0].EndpointType)
|
||||
hasAssociation(t, sum.NotificationRules[0].LabelAssociations)
|
||||
|
||||
require.Len(t, sum.Tasks, 1, "missing required tasks")
|
||||
assert.Equal(t, initialSum.Tasks[0].PkgName, sum.Tasks[0].PkgName)
|
||||
assert.Equal(t, initialSum.Tasks[0].MetaName, sum.Tasks[0].MetaName)
|
||||
assert.Equal(t, initialSum.Tasks[0].Name, sum.Tasks[0].Name)
|
||||
hasAssociation(t, sum.Tasks[0].LabelAssociations)
|
||||
|
||||
require.Len(t, sum.TelegrafConfigs, 1, "missing required telegraf configs")
|
||||
assert.Equal(t, initialSum.TelegrafConfigs[0].PkgName, sum.TelegrafConfigs[0].PkgName)
|
||||
assert.Equal(t, initialSum.TelegrafConfigs[0].MetaName, sum.TelegrafConfigs[0].MetaName)
|
||||
assert.Equal(t, initialSum.TelegrafConfigs[0].TelegrafConfig.Name, sum.TelegrafConfigs[0].TelegrafConfig.Name)
|
||||
hasAssociation(t, sum.TelegrafConfigs[0].LabelAssociations)
|
||||
|
||||
require.Len(t, sum.Variables, 1, "missing required variables")
|
||||
assert.Equal(t, initialSum.Variables[0].PkgName, sum.Variables[0].PkgName)
|
||||
assert.Equal(t, initialSum.Variables[0].MetaName, sum.Variables[0].MetaName)
|
||||
assert.Equal(t, initialSum.Variables[0].Name, sum.Variables[0].Name)
|
||||
hasAssociation(t, sum.Variables[0].LabelAssociations)
|
||||
})
|
||||
|
@ -2635,7 +2635,7 @@ spec:
|
|||
bkts := sum1.Buckets
|
||||
require.Len(t, bkts, 1)
|
||||
assert.NotZero(t, bkts[0].ID)
|
||||
assert.NotEmpty(t, bkts[0].PkgName)
|
||||
assert.NotEmpty(t, bkts[0].MetaName)
|
||||
assert.Equal(t, "rucketeer", bkts[0].Name)
|
||||
hasLabelAssociations(t, bkts[0].LabelAssociations, 2, "label-1", "the 2nd label")
|
||||
|
||||
|
@ -2712,7 +2712,7 @@ spec:
|
|||
ResourceType: rt,
|
||||
ResourcePkgName: pkgName,
|
||||
ResourceName: name,
|
||||
LabelPkgName: labels[0].PkgName,
|
||||
LabelPkgName: labels[0].MetaName,
|
||||
LabelName: labels[0].Name,
|
||||
LabelID: labels[0].ID,
|
||||
}
|
||||
|
@ -2726,14 +2726,14 @@ spec:
|
|||
}
|
||||
|
||||
require.Len(t, mappings, 11)
|
||||
mappingsContain(t, bkts[0].ID, bkts[0].PkgName, bkts[0].Name, influxdb.BucketsResourceType)
|
||||
mappingsContain(t, pkger.SafeID(checks[0].Check.GetID()), checks[0].PkgName, checks[0].Check.GetName(), influxdb.ChecksResourceType)
|
||||
mappingsContain(t, dashs[0].ID, dashs[0].PkgName, dashs[0].Name, influxdb.DashboardsResourceType)
|
||||
mappingsContain(t, pkger.SafeID(endpoints[0].NotificationEndpoint.GetID()), endpoints[0].PkgName, endpoints[0].NotificationEndpoint.GetName(), influxdb.NotificationEndpointResourceType)
|
||||
mappingsContain(t, rule.ID, rule.PkgName, rule.Name, influxdb.NotificationRuleResourceType)
|
||||
mappingsContain(t, task.ID, task.PkgName, task.Name, influxdb.TasksResourceType)
|
||||
mappingsContain(t, pkger.SafeID(teles[0].TelegrafConfig.ID), teles[0].PkgName, teles[0].TelegrafConfig.Name, influxdb.TelegrafsResourceType)
|
||||
mappingsContain(t, vars[0].ID, vars[0].PkgName, vars[0].Name, influxdb.VariablesResourceType)
|
||||
mappingsContain(t, bkts[0].ID, bkts[0].MetaName, bkts[0].Name, influxdb.BucketsResourceType)
|
||||
mappingsContain(t, pkger.SafeID(checks[0].Check.GetID()), checks[0].MetaName, checks[0].Check.GetName(), influxdb.ChecksResourceType)
|
||||
mappingsContain(t, dashs[0].ID, dashs[0].MetaName, dashs[0].Name, influxdb.DashboardsResourceType)
|
||||
mappingsContain(t, pkger.SafeID(endpoints[0].NotificationEndpoint.GetID()), endpoints[0].MetaName, endpoints[0].NotificationEndpoint.GetName(), influxdb.NotificationEndpointResourceType)
|
||||
mappingsContain(t, rule.ID, rule.MetaName, rule.Name, influxdb.NotificationRuleResourceType)
|
||||
mappingsContain(t, task.ID, task.MetaName, task.Name, influxdb.TasksResourceType)
|
||||
mappingsContain(t, pkger.SafeID(teles[0].TelegrafConfig.ID), teles[0].MetaName, teles[0].TelegrafConfig.Name, influxdb.TelegrafsResourceType)
|
||||
mappingsContain(t, vars[0].ID, vars[0].MetaName, vars[0].Name, influxdb.VariablesResourceType)
|
||||
|
||||
var (
|
||||
// used in dependent subtests
|
||||
|
@ -2767,7 +2767,7 @@ spec:
|
|||
|
||||
bkts := sum.Buckets
|
||||
require.Len(t, bkts, 1)
|
||||
assert.NotEmpty(t, bkts[0].PkgName)
|
||||
assert.NotEmpty(t, bkts[0].MetaName)
|
||||
assert.Equal(t, "rucketeer", bkts[0].Name)
|
||||
hasLabelAssociations(t, bkts[0].LabelAssociations, 2, "label-1", "the 2nd label")
|
||||
|
||||
|
@ -2831,7 +2831,7 @@ spec:
|
|||
ResourceType: rt,
|
||||
ResourcePkgName: pkgName,
|
||||
ResourceName: name,
|
||||
LabelPkgName: labels[0].PkgName,
|
||||
LabelPkgName: labels[0].MetaName,
|
||||
LabelName: labels[0].Name,
|
||||
LabelID: labels[0].ID,
|
||||
}
|
||||
|
@ -2839,22 +2839,22 @@ spec:
|
|||
|
||||
mappings := sum.LabelMappings
|
||||
require.Len(t, mappings, 11)
|
||||
assert.Contains(t, mappings, newSumMapping(bkts[0].ID, bkts[0].PkgName, bkts[0].Name, influxdb.BucketsResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(bkts[0].ID, bkts[0].MetaName, bkts[0].Name, influxdb.BucketsResourceType))
|
||||
|
||||
ch0 := checks[0]
|
||||
assert.Contains(t, mappings, newSumMapping(pkger.SafeID(ch0.Check.GetID()), ch0.PkgName, ch0.Check.GetName(), influxdb.ChecksResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(pkger.SafeID(ch0.Check.GetID()), ch0.MetaName, ch0.Check.GetName(), influxdb.ChecksResourceType))
|
||||
|
||||
ch1 := checks[0]
|
||||
assert.Contains(t, mappings, newSumMapping(pkger.SafeID(ch1.Check.GetID()), ch1.PkgName, ch1.Check.GetName(), influxdb.ChecksResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(pkger.SafeID(ch1.Check.GetID()), ch1.MetaName, ch1.Check.GetName(), influxdb.ChecksResourceType))
|
||||
|
||||
ne := endpoints[0]
|
||||
assert.Contains(t, mappings, newSumMapping(pkger.SafeID(ne.NotificationEndpoint.GetID()), ne.PkgName, ne.NotificationEndpoint.GetName(), influxdb.NotificationEndpointResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(pkger.SafeID(ne.NotificationEndpoint.GetID()), ne.MetaName, ne.NotificationEndpoint.GetName(), influxdb.NotificationEndpointResourceType))
|
||||
|
||||
assert.Contains(t, mappings, newSumMapping(dashs[0].ID, dashs[0].PkgName, dashs[0].Name, influxdb.DashboardsResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(rule.ID, rule.PkgName, rule.Name, influxdb.NotificationRuleResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(task.ID, task.PkgName, task.Name, influxdb.TasksResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(pkger.SafeID(teles[0].TelegrafConfig.ID), teles[0].PkgName, teles[0].TelegrafConfig.Name, influxdb.TelegrafsResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(vars[0].ID, vars[0].PkgName, vars[0].Name, influxdb.VariablesResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(dashs[0].ID, dashs[0].MetaName, dashs[0].Name, influxdb.DashboardsResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(rule.ID, rule.MetaName, rule.Name, influxdb.NotificationRuleResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(task.ID, task.MetaName, task.Name, influxdb.TasksResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(pkger.SafeID(teles[0].TelegrafConfig.ID), teles[0].MetaName, teles[0].TelegrafConfig.Name, influxdb.TelegrafsResourceType))
|
||||
assert.Contains(t, mappings, newSumMapping(vars[0].ID, vars[0].MetaName, vars[0].Name, influxdb.VariablesResourceType))
|
||||
})
|
||||
|
||||
t.Run("filtered by resource types", func(t *testing.T) {
|
||||
|
|
136
http/swagger.yml
136
http/swagger.yml
|
@ -4628,17 +4628,17 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgCreate"
|
||||
$ref: "#/components/schemas/TemplateExport"
|
||||
responses:
|
||||
"200":
|
||||
description: Influx package created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pkg"
|
||||
$ref: "#/components/schemas/Template"
|
||||
application/x-yaml:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pkg"
|
||||
$ref: "#/components/schemas/Template"
|
||||
default:
|
||||
description: Unexpected error
|
||||
content:
|
||||
|
@ -4654,13 +4654,13 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgApply"
|
||||
$ref: "#/components/schemas/TemplateApply"
|
||||
application/x-jsonnet:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgApply"
|
||||
$ref: "#/components/schemas/TemplateApply"
|
||||
text/yml:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgApply"
|
||||
$ref: "#/components/schemas/TemplateApply"
|
||||
responses:
|
||||
"200":
|
||||
description: >
|
||||
|
@ -4670,7 +4670,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgSummary"
|
||||
$ref: "#/components/schemas/TemplateSummary"
|
||||
"201":
|
||||
description: >
|
||||
Influx package applied successfully. Newly created resources created
|
||||
|
@ -4680,7 +4680,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgSummary"
|
||||
$ref: "#/components/schemas/TemplateSummary"
|
||||
default:
|
||||
description: Unexpected error
|
||||
content:
|
||||
|
@ -5054,13 +5054,13 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgApply"
|
||||
$ref: "#/components/schemas/TemplateApply"
|
||||
application/x-jsonnet:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgApply"
|
||||
$ref: "#/components/schemas/TemplateApply"
|
||||
text/yml:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgApply"
|
||||
$ref: "#/components/schemas/TemplateApply"
|
||||
responses:
|
||||
"200":
|
||||
description: >
|
||||
|
@ -5070,7 +5070,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgSummary"
|
||||
$ref: "#/components/schemas/TemplateSummary"
|
||||
"201":
|
||||
description: >
|
||||
Influx package applied successfully. Newly created resources created
|
||||
|
@ -5080,7 +5080,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgSummary"
|
||||
$ref: "#/components/schemas/TemplateSummary"
|
||||
default:
|
||||
description: Unexpected error
|
||||
content:
|
||||
|
@ -5099,17 +5099,17 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/PkgCreate"
|
||||
$ref: "#/components/schemas/TemplateExport"
|
||||
responses:
|
||||
"200":
|
||||
description: InfluxDB template created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pkg"
|
||||
$ref: "#/components/schemas/Template"
|
||||
application/x-yaml:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pkg"
|
||||
$ref: "#/components/schemas/Template"
|
||||
default:
|
||||
description: Unexpected error
|
||||
content:
|
||||
|
@ -7863,7 +7863,7 @@ components:
|
|||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Organization"
|
||||
PkgApply:
|
||||
TemplateApply:
|
||||
type: object
|
||||
properties:
|
||||
dryRun:
|
||||
|
@ -7882,7 +7882,7 @@ components:
|
|||
items:
|
||||
type: string
|
||||
package:
|
||||
$ref: "#/components/schemas/Pkg"
|
||||
$ref: "#/components/schemas/Template"
|
||||
templates:
|
||||
type: array
|
||||
items:
|
||||
|
@ -7895,7 +7895,7 @@ components:
|
|||
items:
|
||||
type: string
|
||||
package:
|
||||
$ref: "#/components/schemas/Pkg"
|
||||
$ref: "#/components/schemas/Template"
|
||||
secrets:
|
||||
type: object
|
||||
additionalProperties:
|
||||
|
@ -7955,7 +7955,7 @@ components:
|
|||
- Task
|
||||
- Telegraf
|
||||
- Variable
|
||||
PkgCreate:
|
||||
TemplateExport:
|
||||
type: object
|
||||
properties:
|
||||
stackID:
|
||||
|
@ -7988,7 +7988,7 @@ components:
|
|||
name:
|
||||
type: string
|
||||
required: [id, kind]
|
||||
Pkg:
|
||||
Template:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
|
@ -8004,7 +8004,7 @@ components:
|
|||
type: string
|
||||
spec:
|
||||
type: object
|
||||
PkgEnvReferences:
|
||||
TemplateEnvReferences:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
|
@ -8022,7 +8022,7 @@ components:
|
|||
type: string
|
||||
description: Default value that will be provided for the reference when no value is provided
|
||||
required: [resourceField, envRefKey, defaultValue]
|
||||
PkgSummary:
|
||||
TemplateSummary:
|
||||
type: object
|
||||
properties:
|
||||
sources:
|
||||
|
@ -8043,7 +8043,7 @@ components:
|
|||
type: string
|
||||
orgID:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
|
@ -8054,9 +8054,9 @@ components:
|
|||
labelAssociations:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgSummaryLabel"
|
||||
$ref: "#/components/schemas/TemplateSummaryLabel"
|
||||
envReferences:
|
||||
$ref: "#/components/schemas/PkgEnvReferences"
|
||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||
checks:
|
||||
type: array
|
||||
items:
|
||||
|
@ -8064,18 +8064,18 @@ components:
|
|||
- $ref: "#/components/schemas/CheckDiscriminator"
|
||||
- type: object
|
||||
properties:
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
labelAssociations:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgSummaryLabel"
|
||||
$ref: "#/components/schemas/TemplateSummaryLabel"
|
||||
envReferences:
|
||||
$ref: "#/components/schemas/PkgEnvReferences"
|
||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||
labels:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgSummaryLabel"
|
||||
$ref: "#/components/schemas/TemplateSummaryLabel"
|
||||
dashboards:
|
||||
type: array
|
||||
items:
|
||||
|
@ -8085,7 +8085,7 @@ components:
|
|||
type: "string"
|
||||
orgID:
|
||||
type: "string"
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
name:
|
||||
type: "string"
|
||||
|
@ -8094,13 +8094,13 @@ components:
|
|||
labelAssociations:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgSummaryLabel"
|
||||
$ref: "#/components/schemas/TemplateSummaryLabel"
|
||||
charts:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgChart"
|
||||
$ref: "#/components/schemas/TemplateChart"
|
||||
envReferences:
|
||||
$ref: "#/components/schemas/PkgEnvReferences"
|
||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||
labelMappings:
|
||||
type: array
|
||||
items:
|
||||
|
@ -8108,7 +8108,7 @@ components:
|
|||
properties:
|
||||
status:
|
||||
type: string
|
||||
resourcePkgName:
|
||||
resourceTemplateMetaName:
|
||||
type: string
|
||||
resourceName:
|
||||
type: string
|
||||
|
@ -8116,7 +8116,7 @@ components:
|
|||
type: string
|
||||
resourceType:
|
||||
type: string
|
||||
labelPkgName:
|
||||
labelTemplateMetaName:
|
||||
type: string
|
||||
labelName:
|
||||
type: string
|
||||
|
@ -8137,26 +8137,26 @@ components:
|
|||
- $ref: "#/components/schemas/NotificationEndpointDiscrimator"
|
||||
- type: object
|
||||
properties:
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
labelAssociations:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgSummaryLabel"
|
||||
$ref: "#/components/schemas/TemplateSummaryLabel"
|
||||
envReferences:
|
||||
$ref: "#/components/schemas/PkgEnvReferences"
|
||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||
notificationRules:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
endpointPkgName:
|
||||
endpointTemplateMetaName:
|
||||
type: string
|
||||
endpointID:
|
||||
type: string
|
||||
|
@ -8193,15 +8193,15 @@ components:
|
|||
labelAssociations:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgSummaryLabel"
|
||||
$ref: "#/components/schemas/TemplateSummaryLabel"
|
||||
envReferences:
|
||||
$ref: "#/components/schemas/PkgEnvReferences"
|
||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||
tasks:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
|
@ -8220,7 +8220,7 @@ components:
|
|||
status:
|
||||
type: string
|
||||
envReferences:
|
||||
$ref: "#/components/schemas/PkgEnvReferences"
|
||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||
telegrafConfigs:
|
||||
type: array
|
||||
items:
|
||||
|
@ -8228,20 +8228,20 @@ components:
|
|||
- $ref: "#/components/schemas/TelegrafRequest"
|
||||
- type: object
|
||||
properties:
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
labelAssociations:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgSummaryLabel"
|
||||
$ref: "#/components/schemas/TemplateSummaryLabel"
|
||||
envReferences:
|
||||
$ref: "#/components/schemas/PkgEnvReferences"
|
||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||
variables:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
|
@ -8256,9 +8256,9 @@ components:
|
|||
labelAssociations:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgSummaryLabel"
|
||||
$ref: "#/components/schemas/TemplateSummaryLabel"
|
||||
envReferences:
|
||||
$ref: "#/components/schemas/PkgEnvReferences"
|
||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||
diff:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -8271,7 +8271,7 @@ components:
|
|||
type: string
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
new:
|
||||
type: object
|
||||
|
@ -8300,7 +8300,7 @@ components:
|
|||
type: string
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
new:
|
||||
$ref: "#/components/schemas/CheckDiscriminator"
|
||||
|
@ -8315,7 +8315,7 @@ components:
|
|||
type: string
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
new:
|
||||
type: object
|
||||
|
@ -8327,7 +8327,7 @@ components:
|
|||
charts:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgChart"
|
||||
$ref: "#/components/schemas/TemplateChart"
|
||||
old:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -8338,7 +8338,7 @@ components:
|
|||
charts:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgChart"
|
||||
$ref: "#/components/schemas/TemplateChart"
|
||||
labels:
|
||||
type: array
|
||||
items:
|
||||
|
@ -8348,7 +8348,7 @@ components:
|
|||
type: string
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
new:
|
||||
type: object
|
||||
|
@ -8379,13 +8379,13 @@ components:
|
|||
type: string
|
||||
resourceID:
|
||||
type: string
|
||||
resourcePkgName:
|
||||
resourceTemplateMetaName:
|
||||
type: string
|
||||
resourceName:
|
||||
type: string
|
||||
labelID:
|
||||
type: string
|
||||
labelPkgName:
|
||||
labelTemplateMetaName:
|
||||
type: string
|
||||
labelName:
|
||||
type: string
|
||||
|
@ -8398,7 +8398,7 @@ components:
|
|||
type: string
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
new:
|
||||
$ref: "#/components/schemas/NotificationEndpointDiscrimator"
|
||||
|
@ -8413,7 +8413,7 @@ components:
|
|||
type: string
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
new:
|
||||
type: object
|
||||
|
@ -8506,7 +8506,7 @@ components:
|
|||
type: string
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
new:
|
||||
type: object
|
||||
|
@ -8551,7 +8551,7 @@ components:
|
|||
type: string
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
new:
|
||||
$ref: "#/components/schemas/TelegrafRequest"
|
||||
|
@ -8566,7 +8566,7 @@ components:
|
|||
type: string
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
new:
|
||||
type: object
|
||||
|
@ -8603,14 +8603,14 @@ components:
|
|||
type: array
|
||||
items:
|
||||
type: integer
|
||||
PkgSummaryLabel:
|
||||
TemplateSummaryLabel:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
orgID:
|
||||
type: string
|
||||
pkgName:
|
||||
templateMetaName:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
|
@ -8622,8 +8622,8 @@ components:
|
|||
description:
|
||||
type: string
|
||||
envReferences:
|
||||
$ref: "#/components/schemas/PkgEnvReferences"
|
||||
PkgChart:
|
||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||
TemplateChart:
|
||||
type: object
|
||||
properties:
|
||||
xPos:
|
||||
|
|
|
@ -172,7 +172,7 @@ func TestPkgerHTTPServer(t *testing.T) {
|
|||
for _, b := range sum.Buckets {
|
||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||
DiffIdentifier: pkger.DiffIdentifier{
|
||||
PkgName: b.Name,
|
||||
MetaName: b.Name,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ func TestPkgerHTTPServer(t *testing.T) {
|
|||
for _, b := range sum.Buckets {
|
||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||
DiffIdentifier: pkger.DiffIdentifier{
|
||||
PkgName: b.Name,
|
||||
MetaName: b.Name,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ func TestPkgerHTTPServer(t *testing.T) {
|
|||
for _, b := range sum.Buckets {
|
||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||
DiffIdentifier: pkger.DiffIdentifier{
|
||||
PkgName: b.Name,
|
||||
MetaName: b.Name,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ func TestPkgerHTTPServer(t *testing.T) {
|
|||
for _, b := range sum.Buckets {
|
||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||
DiffIdentifier: pkger.DiffIdentifier{
|
||||
PkgName: b.Name,
|
||||
MetaName: b.Name,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ func TestPkgerHTTPServerTemplate(t *testing.T) {
|
|||
for _, b := range sum.Buckets {
|
||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||
DiffIdentifier: pkger.DiffIdentifier{
|
||||
PkgName: b.Name,
|
||||
MetaName: b.Name,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ func TestPkgerHTTPServerTemplate(t *testing.T) {
|
|||
for _, b := range sum.Buckets {
|
||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||
DiffIdentifier: pkger.DiffIdentifier{
|
||||
PkgName: b.Name,
|
||||
MetaName: b.Name,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ func TestPkgerHTTPServerTemplate(t *testing.T) {
|
|||
for _, b := range sum.Buckets {
|
||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||
DiffIdentifier: pkger.DiffIdentifier{
|
||||
PkgName: b.Name,
|
||||
MetaName: b.Name,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ func TestPkgerHTTPServerTemplate(t *testing.T) {
|
|||
for _, b := range sum.Buckets {
|
||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||
DiffIdentifier: pkger.DiffIdentifier{
|
||||
PkgName: b.Name,
|
||||
MetaName: b.Name,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ func (s SafeID) String() string {
|
|||
type DiffIdentifier struct {
|
||||
ID SafeID `json:"id"`
|
||||
StateStatus StateStatus `json:"stateStatus"`
|
||||
PkgName string `json:"pkgName"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
}
|
||||
|
||||
// IsNew indicates the resource is new to the platform.
|
||||
|
@ -309,14 +309,14 @@ const (
|
|||
type DiffLabelMapping struct {
|
||||
StateStatus StateStatus `json:"stateStatus"`
|
||||
|
||||
ResType influxdb.ResourceType `json:"resourceType"`
|
||||
ResID SafeID `json:"resourceID"`
|
||||
ResName string `json:"resourceName"`
|
||||
ResPkgName string `json:"resourcePkgName"`
|
||||
ResType influxdb.ResourceType `json:"resourceType"`
|
||||
ResID SafeID `json:"resourceID"`
|
||||
ResName string `json:"resourceName"`
|
||||
ResMetaName string `json:"resourceTemplateMetaName"`
|
||||
|
||||
LabelID SafeID `json:"labelID"`
|
||||
LabelName string `json:"labelName"`
|
||||
LabelPkgName string `json:"labelPkgName"`
|
||||
LabelID SafeID `json:"labelID"`
|
||||
LabelName string `json:"labelName"`
|
||||
LabelMetaName string `json:"labelTemplateMetaName"`
|
||||
}
|
||||
|
||||
//func (d DiffLabelMapping) IsNew() bool {
|
||||
|
@ -452,7 +452,7 @@ type SummaryBucket struct {
|
|||
ID SafeID `json:"id,omitempty"`
|
||||
OrgID SafeID `json:"orgID,omitempty"`
|
||||
Name string `json:"name"`
|
||||
PkgName string `json:"pkgName"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
Description string `json:"description"`
|
||||
// TODO: return retention rules?
|
||||
RetentionPeriod time.Duration `json:"retentionPeriod"`
|
||||
|
@ -463,9 +463,9 @@ type SummaryBucket struct {
|
|||
|
||||
// SummaryCheck provides a summary of a pkg check.
|
||||
type SummaryCheck struct {
|
||||
PkgName string `json:"pkgName"`
|
||||
Check influxdb.Check `json:"check"`
|
||||
Status influxdb.Status `json:"status"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
Check influxdb.Check `json:"check"`
|
||||
Status influxdb.Status `json:"status"`
|
||||
|
||||
EnvReferences []SummaryReference `json:"envReferences"`
|
||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||
|
@ -473,7 +473,7 @@ type SummaryCheck struct {
|
|||
|
||||
func (s *SummaryCheck) UnmarshalJSON(b []byte) error {
|
||||
var out struct {
|
||||
PkgName string `json:"pkgName"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
Status string `json:"status"`
|
||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||
Check json.RawMessage `json:"check"`
|
||||
|
@ -481,7 +481,7 @@ func (s *SummaryCheck) UnmarshalJSON(b []byte) error {
|
|||
if err := json.Unmarshal(b, &out); err != nil {
|
||||
return err
|
||||
}
|
||||
s.PkgName = out.PkgName
|
||||
s.MetaName = out.MetaName
|
||||
s.Status = influxdb.Status(out.Status)
|
||||
s.LabelAssociations = out.LabelAssociations
|
||||
|
||||
|
@ -494,7 +494,7 @@ func (s *SummaryCheck) UnmarshalJSON(b []byte) error {
|
|||
type SummaryDashboard struct {
|
||||
ID SafeID `json:"id"`
|
||||
OrgID SafeID `json:"orgID"`
|
||||
PkgName string `json:"pkgName"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Charts []SummaryChart `json:"charts"`
|
||||
|
@ -554,7 +554,7 @@ func (s *SummaryChart) UnmarshalJSON(b []byte) error {
|
|||
|
||||
// SummaryNotificationEndpoint provides a summary of a pkg notification endpoint.
|
||||
type SummaryNotificationEndpoint struct {
|
||||
PkgName string `json:"pkgName"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
NotificationEndpoint influxdb.NotificationEndpoint `json:"notificationEndpoint"`
|
||||
|
||||
EnvReferences []SummaryReference `json:"envReferences"`
|
||||
|
@ -565,14 +565,14 @@ type SummaryNotificationEndpoint struct {
|
|||
// the notification endpoint does not have a means ot unmarshal itself.
|
||||
func (s *SummaryNotificationEndpoint) UnmarshalJSON(b []byte) error {
|
||||
var a struct {
|
||||
PkgName string `json:"pkgName"`
|
||||
PkgName string `json:"templateMetaName"`
|
||||
NotificationEndpoint json.RawMessage `json:"notificationEndpoint"`
|
||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||
}
|
||||
if err := json.Unmarshal(b, &a); err != nil {
|
||||
return err
|
||||
}
|
||||
s.PkgName = a.PkgName
|
||||
s.MetaName = a.PkgName
|
||||
s.LabelAssociations = a.LabelAssociations
|
||||
|
||||
e, err := endpoint.UnmarshalJSON(a.NotificationEndpoint)
|
||||
|
@ -584,13 +584,13 @@ func (s *SummaryNotificationEndpoint) UnmarshalJSON(b []byte) error {
|
|||
type (
|
||||
SummaryNotificationRule struct {
|
||||
ID SafeID `json:"id"`
|
||||
PkgName string `json:"pkgName"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
|
||||
// These fields represent the relationship of the rule to the endpoint.
|
||||
EndpointID SafeID `json:"endpointID"`
|
||||
EndpointPkgName string `json:"endpointPkgName"`
|
||||
EndpointPkgName string `json:"endpointTemplateMetaName"`
|
||||
EndpointType string `json:"endpointType"`
|
||||
|
||||
Every string `json:"every"`
|
||||
|
@ -620,7 +620,7 @@ type (
|
|||
type SummaryLabel struct {
|
||||
ID SafeID `json:"id"`
|
||||
OrgID SafeID `json:"orgID"`
|
||||
PkgName string `json:"pkgName"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
Name string `json:"name"`
|
||||
Properties struct {
|
||||
Color string `json:"color"`
|
||||
|
@ -635,10 +635,10 @@ type SummaryLabelMapping struct {
|
|||
exists bool
|
||||
Status StateStatus `json:"status,omitempty"`
|
||||
ResourceID SafeID `json:"resourceID"`
|
||||
ResourcePkgName string `json:"resourcePkgName"`
|
||||
ResourcePkgName string `json:"resourceTemplateMetaName"`
|
||||
ResourceName string `json:"resourceName"`
|
||||
ResourceType influxdb.ResourceType `json:"resourceType"`
|
||||
LabelPkgName string `json:"labelPkgName"`
|
||||
LabelPkgName string `json:"labelTemplateMetaName"`
|
||||
LabelName string `json:"labelName"`
|
||||
LabelID SafeID `json:"labelID"`
|
||||
}
|
||||
|
@ -655,7 +655,7 @@ type SummaryReference struct {
|
|||
// SummaryTask provides a summary of a task.
|
||||
type SummaryTask struct {
|
||||
ID SafeID `json:"id"`
|
||||
PkgName string `json:"pkgName"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
Name string `json:"name"`
|
||||
Cron string `json:"cron"`
|
||||
Description string `json:"description"`
|
||||
|
@ -670,7 +670,7 @@ type SummaryTask struct {
|
|||
|
||||
// SummaryTelegraf provides a summary of a pkg telegraf config.
|
||||
type SummaryTelegraf struct {
|
||||
PkgName string `json:"pkgName"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
TelegrafConfig influxdb.TelegrafConfig `json:"telegrafConfig"`
|
||||
|
||||
EnvReferences []SummaryReference `json:"envReferences"`
|
||||
|
@ -680,7 +680,7 @@ type SummaryTelegraf struct {
|
|||
// SummaryVariable provides a summary of a pkg variable.
|
||||
type SummaryVariable struct {
|
||||
ID SafeID `json:"id,omitempty"`
|
||||
PkgName string `json:"pkgName"`
|
||||
MetaName string `json:"templateMetaName"`
|
||||
OrgID SafeID `json:"orgID,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
|
|
|
@ -35,7 +35,7 @@ func TestPkg(t *testing.T) {
|
|||
assert.Zero(t, buck.ID)
|
||||
assert.Zero(t, buck.OrgID)
|
||||
assert.Equal(t, "desc"+strconv.Itoa(i), buck.Description)
|
||||
assert.Equal(t, "pkgName"+strconv.Itoa(i), buck.PkgName)
|
||||
assert.Equal(t, "pkgName"+strconv.Itoa(i), buck.MetaName)
|
||||
assert.Equal(t, "name"+strconv.Itoa(i), buck.Name)
|
||||
assert.Equal(t, time.Duration(i)*time.Hour, buck.RetentionPeriod)
|
||||
}
|
||||
|
@ -61,13 +61,13 @@ func TestPkg(t *testing.T) {
|
|||
|
||||
require.Len(t, summary.Labels, len(pkg.mLabels))
|
||||
label1 := summary.Labels[0]
|
||||
assert.Equal(t, "pkgName1", label1.PkgName)
|
||||
assert.Equal(t, "pkgName1", label1.MetaName)
|
||||
assert.Equal(t, "name1", label1.Name)
|
||||
assert.Equal(t, "desc1", label1.Properties.Description)
|
||||
assert.Equal(t, "peru", label1.Properties.Color)
|
||||
|
||||
label2 := summary.Labels[1]
|
||||
assert.Equal(t, "pkgName2", label2.PkgName)
|
||||
assert.Equal(t, "pkgName2", label2.MetaName)
|
||||
assert.Equal(t, "name2", label2.Name)
|
||||
assert.Equal(t, "desc2", label2.Properties.Description)
|
||||
assert.Equal(t, "blurple", label2.Properties.Color)
|
||||
|
@ -124,7 +124,7 @@ func TestPkg(t *testing.T) {
|
|||
name: "new bucket",
|
||||
resource: DiffBucket{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
PkgName: "new bucket",
|
||||
MetaName: "new bucket",
|
||||
},
|
||||
New: DiffBucketValues{
|
||||
Description: "new desc",
|
||||
|
@ -136,8 +136,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing bucket with no changes",
|
||||
resource: DiffBucket{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 3,
|
||||
PkgName: "new bucket",
|
||||
ID: 3,
|
||||
MetaName: "new bucket",
|
||||
},
|
||||
New: DiffBucketValues{
|
||||
Description: "new desc",
|
||||
|
@ -160,8 +160,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing bucket with desc changes",
|
||||
resource: DiffBucket{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 3,
|
||||
PkgName: "existing bucket",
|
||||
ID: 3,
|
||||
MetaName: "existing bucket",
|
||||
},
|
||||
New: DiffBucketValues{
|
||||
Description: "new desc",
|
||||
|
@ -184,8 +184,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing bucket with retention changes",
|
||||
resource: DiffBucket{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 3,
|
||||
PkgName: "existing bucket",
|
||||
ID: 3,
|
||||
MetaName: "existing bucket",
|
||||
},
|
||||
New: DiffBucketValues{
|
||||
Description: "new desc",
|
||||
|
@ -204,8 +204,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing bucket with retention changes",
|
||||
resource: DiffBucket{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 3,
|
||||
PkgName: "existing bucket",
|
||||
ID: 3,
|
||||
MetaName: "existing bucket",
|
||||
},
|
||||
New: DiffBucketValues{
|
||||
Description: "new desc",
|
||||
|
@ -228,8 +228,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing bucket with retention changes",
|
||||
resource: DiffBucket{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 3,
|
||||
PkgName: "existing bucket",
|
||||
ID: 3,
|
||||
MetaName: "existing bucket",
|
||||
},
|
||||
New: DiffBucketValues{
|
||||
Description: "new desc",
|
||||
|
@ -258,7 +258,7 @@ func TestPkg(t *testing.T) {
|
|||
name: "new label",
|
||||
resource: DiffLabel{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
PkgName: "new label",
|
||||
MetaName: "new label",
|
||||
},
|
||||
New: DiffLabelValues{
|
||||
Name: "new label",
|
||||
|
@ -272,8 +272,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing label with no changes",
|
||||
resource: DiffLabel{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 1,
|
||||
PkgName: "existing label",
|
||||
ID: 1,
|
||||
MetaName: "existing label",
|
||||
},
|
||||
New: DiffLabelValues{
|
||||
Name: "existing label",
|
||||
|
@ -292,8 +292,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing label with changes",
|
||||
resource: DiffLabel{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 1,
|
||||
PkgName: "existing label",
|
||||
ID: 1,
|
||||
MetaName: "existing label",
|
||||
},
|
||||
New: DiffLabelValues{
|
||||
Name: "existing label",
|
||||
|
@ -312,7 +312,7 @@ func TestPkg(t *testing.T) {
|
|||
name: "new variable",
|
||||
resource: DiffVariable{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
PkgName: "new var",
|
||||
MetaName: "new var",
|
||||
},
|
||||
New: DiffVariableValues{
|
||||
Name: "new var",
|
||||
|
@ -329,8 +329,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing variable no changes",
|
||||
resource: DiffVariable{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 2,
|
||||
PkgName: "new var",
|
||||
ID: 2,
|
||||
MetaName: "new var",
|
||||
},
|
||||
New: DiffVariableValues{
|
||||
Name: "new var",
|
||||
|
@ -355,8 +355,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing variable with desc changes",
|
||||
resource: DiffVariable{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 3,
|
||||
PkgName: "new var",
|
||||
ID: 3,
|
||||
MetaName: "new var",
|
||||
},
|
||||
New: DiffVariableValues{
|
||||
Name: "new var",
|
||||
|
@ -380,8 +380,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing variable with constant arg changes",
|
||||
resource: DiffVariable{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 3,
|
||||
PkgName: "new var",
|
||||
ID: 3,
|
||||
MetaName: "new var",
|
||||
},
|
||||
New: DiffVariableValues{
|
||||
Name: "new var",
|
||||
|
@ -405,8 +405,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing variable with map arg changes",
|
||||
resource: DiffVariable{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 3,
|
||||
PkgName: "new var",
|
||||
ID: 3,
|
||||
MetaName: "new var",
|
||||
},
|
||||
New: DiffVariableValues{
|
||||
Name: "new var",
|
||||
|
@ -430,8 +430,8 @@ func TestPkg(t *testing.T) {
|
|||
name: "existing variable with query arg changes",
|
||||
resource: DiffVariable{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 3,
|
||||
PkgName: "new var",
|
||||
ID: 3,
|
||||
MetaName: "new var",
|
||||
},
|
||||
New: DiffVariableValues{
|
||||
Name: "new var",
|
||||
|
|
|
@ -90,7 +90,7 @@ type bucket struct {
|
|||
func (b *bucket) summarize() SummaryBucket {
|
||||
return SummaryBucket{
|
||||
Name: b.Name(),
|
||||
PkgName: b.PkgName(),
|
||||
MetaName: b.PkgName(),
|
||||
Description: b.Description,
|
||||
RetentionPeriod: b.RetentionRules.RP(),
|
||||
LabelAssociations: toSummaryLabels(b.labels...),
|
||||
|
@ -248,7 +248,7 @@ func (c *check) summarize() SummaryCheck {
|
|||
}
|
||||
|
||||
sum := SummaryCheck{
|
||||
PkgName: c.PkgName(),
|
||||
MetaName: c.PkgName(),
|
||||
Status: c.Status(),
|
||||
LabelAssociations: toSummaryLabels(c.labels...),
|
||||
EnvReferences: summarizeCommonReferences(c.identity, c.labels),
|
||||
|
@ -463,7 +463,7 @@ func (d *dashboard) ResourceType() influxdb.ResourceType {
|
|||
|
||||
func (d *dashboard) summarize() SummaryDashboard {
|
||||
iDash := SummaryDashboard{
|
||||
PkgName: d.PkgName(),
|
||||
MetaName: d.PkgName(),
|
||||
Name: d.Name(),
|
||||
Description: d.Description,
|
||||
LabelAssociations: toSummaryLabels(d.labels...),
|
||||
|
@ -1131,8 +1131,8 @@ type label struct {
|
|||
|
||||
func (l *label) summarize() SummaryLabel {
|
||||
return SummaryLabel{
|
||||
PkgName: l.PkgName(),
|
||||
Name: l.Name(),
|
||||
MetaName: l.PkgName(),
|
||||
Name: l.Name(),
|
||||
Properties: struct {
|
||||
Color string `json:"color"`
|
||||
Description string `json:"description"`
|
||||
|
@ -1284,7 +1284,7 @@ func (n *notificationEndpoint) base() endpoint.Base {
|
|||
func (n *notificationEndpoint) summarize() SummaryNotificationEndpoint {
|
||||
base := n.base()
|
||||
sum := SummaryNotificationEndpoint{
|
||||
PkgName: n.PkgName(),
|
||||
MetaName: n.PkgName(),
|
||||
LabelAssociations: toSummaryLabels(n.labels...),
|
||||
EnvReferences: summarizeCommonReferences(n.identity, n.labels),
|
||||
}
|
||||
|
@ -1487,7 +1487,7 @@ func (r *notificationRule) summarize() SummaryNotificationRule {
|
|||
}
|
||||
|
||||
return SummaryNotificationRule{
|
||||
PkgName: r.PkgName(),
|
||||
MetaName: r.PkgName(),
|
||||
Name: r.Name(),
|
||||
EndpointPkgName: endpointPkgName,
|
||||
EndpointType: endpointType,
|
||||
|
@ -1721,7 +1721,7 @@ func (t *task) flux() string {
|
|||
|
||||
func (t *task) summarize() SummaryTask {
|
||||
return SummaryTask{
|
||||
PkgName: t.PkgName(),
|
||||
MetaName: t.PkgName(),
|
||||
Name: t.Name(),
|
||||
Cron: t.cron,
|
||||
Description: t.description,
|
||||
|
@ -1856,7 +1856,7 @@ func (t *telegraf) summarize() SummaryTelegraf {
|
|||
cfg := t.config
|
||||
cfg.Name = t.Name()
|
||||
return SummaryTelegraf{
|
||||
PkgName: t.PkgName(),
|
||||
MetaName: t.PkgName(),
|
||||
TelegrafConfig: cfg,
|
||||
LabelAssociations: toSummaryLabels(t.labels...),
|
||||
EnvReferences: summarizeCommonReferences(t.identity, t.labels),
|
||||
|
@ -1935,7 +1935,7 @@ func (v *variable) summarize() SummaryVariable {
|
|||
}
|
||||
|
||||
return SummaryVariable{
|
||||
PkgName: v.PkgName(),
|
||||
MetaName: v.PkgName(),
|
||||
Name: v.Name(),
|
||||
Description: v.Description,
|
||||
Selected: v.Selected(),
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestParse(t *testing.T) {
|
|||
|
||||
actual := buckets[0]
|
||||
expectedBucket := SummaryBucket{
|
||||
PkgName: "rucket-11",
|
||||
MetaName: "rucket-11",
|
||||
Name: "rucket-11",
|
||||
Description: "bucket 1 description",
|
||||
RetentionPeriod: time.Hour,
|
||||
|
@ -41,7 +41,7 @@ func TestParse(t *testing.T) {
|
|||
|
||||
actual = buckets[1]
|
||||
expectedBucket = SummaryBucket{
|
||||
PkgName: "rucket-22",
|
||||
MetaName: "rucket-22",
|
||||
Name: "display name",
|
||||
Description: "bucket 2 description",
|
||||
LabelAssociations: []SummaryLabel{},
|
||||
|
@ -1525,7 +1525,7 @@ spec:
|
|||
require.Len(t, sum.Dashboards, 2)
|
||||
|
||||
actual := sum.Dashboards[0]
|
||||
assert.Equal(t, "dash-1", actual.PkgName)
|
||||
assert.Equal(t, "dash-1", actual.MetaName)
|
||||
assert.Equal(t, "display name", actual.Name)
|
||||
assert.Equal(t, "desc1", actual.Description)
|
||||
|
||||
|
@ -1562,7 +1562,7 @@ spec:
|
|||
assert.Equal(t, 3.0, c.Value)
|
||||
|
||||
actual2 := sum.Dashboards[1]
|
||||
assert.Equal(t, "dash-2", actual2.PkgName)
|
||||
assert.Equal(t, "dash-2", actual2.MetaName)
|
||||
assert.Equal(t, "dash-2", actual2.Name)
|
||||
assert.Equal(t, "desc", actual2.Description)
|
||||
})
|
||||
|
@ -2432,7 +2432,7 @@ spec:
|
|||
testfileRunner(t, "testdata/notification_endpoint", func(t *testing.T, pkg *Pkg) {
|
||||
expectedEndpoints := []SummaryNotificationEndpoint{
|
||||
{
|
||||
PkgName: "http-basic-auth-notification-endpoint",
|
||||
MetaName: "http-basic-auth-notification-endpoint",
|
||||
NotificationEndpoint: &endpoint.HTTP{
|
||||
Base: endpoint.Base{
|
||||
Name: "basic endpoint name",
|
||||
|
@ -2447,7 +2447,7 @@ spec:
|
|||
},
|
||||
},
|
||||
{
|
||||
PkgName: "http-bearer-auth-notification-endpoint",
|
||||
MetaName: "http-bearer-auth-notification-endpoint",
|
||||
NotificationEndpoint: &endpoint.HTTP{
|
||||
Base: endpoint.Base{
|
||||
Name: "http-bearer-auth-notification-endpoint",
|
||||
|
@ -2461,7 +2461,7 @@ spec:
|
|||
},
|
||||
},
|
||||
{
|
||||
PkgName: "http-none-auth-notification-endpoint",
|
||||
MetaName: "http-none-auth-notification-endpoint",
|
||||
NotificationEndpoint: &endpoint.HTTP{
|
||||
Base: endpoint.Base{
|
||||
Name: "http-none-auth-notification-endpoint",
|
||||
|
@ -2474,7 +2474,7 @@ spec:
|
|||
},
|
||||
},
|
||||
{
|
||||
PkgName: "pager-duty-notification-endpoint",
|
||||
MetaName: "pager-duty-notification-endpoint",
|
||||
NotificationEndpoint: &endpoint.PagerDuty{
|
||||
Base: endpoint.Base{
|
||||
Name: "pager duty name",
|
||||
|
@ -2486,7 +2486,7 @@ spec:
|
|||
},
|
||||
},
|
||||
{
|
||||
PkgName: "slack-notification-endpoint",
|
||||
MetaName: "slack-notification-endpoint",
|
||||
NotificationEndpoint: &endpoint.Slack{
|
||||
Base: endpoint.Base{
|
||||
Name: "slack name",
|
||||
|
@ -2513,7 +2513,7 @@ spec:
|
|||
assert.Contains(t, sum.LabelMappings, SummaryLabelMapping{
|
||||
Status: StateStatusNew,
|
||||
ResourceType: influxdb.NotificationEndpointResourceType,
|
||||
ResourcePkgName: expected.PkgName,
|
||||
ResourcePkgName: expected.MetaName,
|
||||
ResourceName: expected.NotificationEndpoint.GetName(),
|
||||
LabelPkgName: "label-1",
|
||||
LabelName: "label-1",
|
||||
|
@ -2841,8 +2841,8 @@ spec:
|
|||
|
||||
require.Len(t, sum.Labels, 2)
|
||||
require.Len(t, rule.LabelAssociations, 2)
|
||||
assert.Equal(t, "label-1", rule.LabelAssociations[0].PkgName)
|
||||
assert.Equal(t, "label-2", rule.LabelAssociations[1].PkgName)
|
||||
assert.Equal(t, "label-1", rule.LabelAssociations[0].MetaName)
|
||||
assert.Equal(t, "label-2", rule.LabelAssociations[1].MetaName)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -3153,7 +3153,7 @@ spec:
|
|||
tasks := sum.Tasks
|
||||
require.Len(t, tasks, 2)
|
||||
sort.Slice(tasks, func(i, j int) bool {
|
||||
return tasks[i].PkgName < tasks[j].PkgName
|
||||
return tasks[i].MetaName < tasks[j].MetaName
|
||||
})
|
||||
|
||||
baseEqual := func(t *testing.T, i int, status influxdb.Status, actual SummaryTask) {
|
||||
|
@ -3869,7 +3869,7 @@ spec:
|
|||
|
||||
bkts := []SummaryBucket{
|
||||
{
|
||||
PkgName: "rucket-1",
|
||||
MetaName: "rucket-1",
|
||||
Name: "rucket-1",
|
||||
Description: "desc_1",
|
||||
RetentionPeriod: 10000 * time.Second,
|
||||
|
@ -3877,7 +3877,7 @@ spec:
|
|||
EnvReferences: []SummaryReference{},
|
||||
},
|
||||
{
|
||||
PkgName: "rucket-2",
|
||||
MetaName: "rucket-2",
|
||||
Name: "rucket-2",
|
||||
Description: "desc-2",
|
||||
RetentionPeriod: 20000 * time.Second,
|
||||
|
@ -3885,7 +3885,7 @@ spec:
|
|||
EnvReferences: []SummaryReference{},
|
||||
},
|
||||
{
|
||||
PkgName: "rucket-3",
|
||||
MetaName: "rucket-3",
|
||||
Name: "rucket-3",
|
||||
Description: "desc_3",
|
||||
RetentionPeriod: 30000 * time.Second,
|
||||
|
@ -4424,8 +4424,8 @@ func sumLabelGen(pkgName, name, color, desc string, envRefs ...SummaryReference)
|
|||
envRefs = make([]SummaryReference, 0)
|
||||
}
|
||||
return SummaryLabel{
|
||||
PkgName: pkgName,
|
||||
Name: name,
|
||||
MetaName: pkgName,
|
||||
Name: name,
|
||||
Properties: struct {
|
||||
Color string `json:"color"`
|
||||
Description string `json:"description"`
|
||||
|
|
|
@ -211,63 +211,63 @@ func (s *stateCoordinator) diff() Diff {
|
|||
diff.Buckets = append(diff.Buckets, b.diffBucket())
|
||||
}
|
||||
sort.Slice(diff.Buckets, func(i, j int) bool {
|
||||
return diff.Buckets[i].PkgName < diff.Buckets[j].PkgName
|
||||
return diff.Buckets[i].MetaName < diff.Buckets[j].MetaName
|
||||
})
|
||||
|
||||
for _, c := range s.mChecks {
|
||||
diff.Checks = append(diff.Checks, c.diffCheck())
|
||||
}
|
||||
sort.Slice(diff.Checks, func(i, j int) bool {
|
||||
return diff.Checks[i].PkgName < diff.Checks[j].PkgName
|
||||
return diff.Checks[i].MetaName < diff.Checks[j].MetaName
|
||||
})
|
||||
|
||||
for _, d := range s.mDashboards {
|
||||
diff.Dashboards = append(diff.Dashboards, d.diffDashboard())
|
||||
}
|
||||
sort.Slice(diff.Dashboards, func(i, j int) bool {
|
||||
return diff.Dashboards[i].PkgName < diff.Dashboards[j].PkgName
|
||||
return diff.Dashboards[i].MetaName < diff.Dashboards[j].MetaName
|
||||
})
|
||||
|
||||
for _, e := range s.mEndpoints {
|
||||
diff.NotificationEndpoints = append(diff.NotificationEndpoints, e.diffEndpoint())
|
||||
}
|
||||
sort.Slice(diff.NotificationEndpoints, func(i, j int) bool {
|
||||
return diff.NotificationEndpoints[i].PkgName < diff.NotificationEndpoints[j].PkgName
|
||||
return diff.NotificationEndpoints[i].MetaName < diff.NotificationEndpoints[j].MetaName
|
||||
})
|
||||
|
||||
for _, l := range s.mLabels {
|
||||
diff.Labels = append(diff.Labels, l.diffLabel())
|
||||
}
|
||||
sort.Slice(diff.Labels, func(i, j int) bool {
|
||||
return diff.Labels[i].PkgName < diff.Labels[j].PkgName
|
||||
return diff.Labels[i].MetaName < diff.Labels[j].MetaName
|
||||
})
|
||||
|
||||
for _, r := range s.mRules {
|
||||
diff.NotificationRules = append(diff.NotificationRules, r.diffRule())
|
||||
}
|
||||
sort.Slice(diff.NotificationRules, func(i, j int) bool {
|
||||
return diff.NotificationRules[i].PkgName < diff.NotificationRules[j].PkgName
|
||||
return diff.NotificationRules[i].MetaName < diff.NotificationRules[j].MetaName
|
||||
})
|
||||
|
||||
for _, t := range s.mTasks {
|
||||
diff.Tasks = append(diff.Tasks, t.diffTask())
|
||||
}
|
||||
sort.Slice(diff.Tasks, func(i, j int) bool {
|
||||
return diff.Tasks[i].PkgName < diff.Tasks[j].PkgName
|
||||
return diff.Tasks[i].MetaName < diff.Tasks[j].MetaName
|
||||
})
|
||||
|
||||
for _, t := range s.mTelegrafs {
|
||||
diff.Telegrafs = append(diff.Telegrafs, t.diffTelegraf())
|
||||
}
|
||||
sort.Slice(diff.Telegrafs, func(i, j int) bool {
|
||||
return diff.Telegrafs[i].PkgName < diff.Telegrafs[j].PkgName
|
||||
return diff.Telegrafs[i].MetaName < diff.Telegrafs[j].MetaName
|
||||
})
|
||||
|
||||
for _, v := range s.mVariables {
|
||||
diff.Variables = append(diff.Variables, v.diffVariable())
|
||||
}
|
||||
sort.Slice(diff.Variables, func(i, j int) bool {
|
||||
return diff.Variables[i].PkgName < diff.Variables[j].PkgName
|
||||
return diff.Variables[i].MetaName < diff.Variables[j].MetaName
|
||||
})
|
||||
|
||||
for _, m := range s.labelMappings {
|
||||
|
@ -285,10 +285,10 @@ func (s *stateCoordinator) diff() Diff {
|
|||
if n.ResType > m.ResType {
|
||||
return false
|
||||
}
|
||||
if n.ResPkgName < m.ResPkgName {
|
||||
if n.ResMetaName < m.ResMetaName {
|
||||
return true
|
||||
}
|
||||
if n.ResPkgName > m.ResPkgName {
|
||||
if n.ResMetaName > m.ResMetaName {
|
||||
return false
|
||||
}
|
||||
return n.LabelName < m.LabelName
|
||||
|
@ -306,7 +306,7 @@ func (s *stateCoordinator) summary() Summary {
|
|||
sum.Buckets = append(sum.Buckets, v.summarize())
|
||||
}
|
||||
sort.Slice(sum.Buckets, func(i, j int) bool {
|
||||
return sum.Buckets[i].PkgName < sum.Buckets[j].PkgName
|
||||
return sum.Buckets[i].MetaName < sum.Buckets[j].MetaName
|
||||
})
|
||||
|
||||
for _, c := range s.mChecks {
|
||||
|
@ -316,7 +316,7 @@ func (s *stateCoordinator) summary() Summary {
|
|||
sum.Checks = append(sum.Checks, c.summarize())
|
||||
}
|
||||
sort.Slice(sum.Checks, func(i, j int) bool {
|
||||
return sum.Checks[i].PkgName < sum.Checks[j].PkgName
|
||||
return sum.Checks[i].MetaName < sum.Checks[j].MetaName
|
||||
})
|
||||
|
||||
for _, d := range s.mDashboards {
|
||||
|
@ -326,7 +326,7 @@ func (s *stateCoordinator) summary() Summary {
|
|||
sum.Dashboards = append(sum.Dashboards, d.summarize())
|
||||
}
|
||||
sort.Slice(sum.Dashboards, func(i, j int) bool {
|
||||
return sum.Dashboards[i].PkgName < sum.Dashboards[j].PkgName
|
||||
return sum.Dashboards[i].MetaName < sum.Dashboards[j].MetaName
|
||||
})
|
||||
|
||||
for _, e := range s.mEndpoints {
|
||||
|
@ -336,7 +336,7 @@ func (s *stateCoordinator) summary() Summary {
|
|||
sum.NotificationEndpoints = append(sum.NotificationEndpoints, e.summarize())
|
||||
}
|
||||
sort.Slice(sum.NotificationEndpoints, func(i, j int) bool {
|
||||
return sum.NotificationEndpoints[i].PkgName < sum.NotificationEndpoints[j].PkgName
|
||||
return sum.NotificationEndpoints[i].MetaName < sum.NotificationEndpoints[j].MetaName
|
||||
})
|
||||
|
||||
for _, v := range s.mLabels {
|
||||
|
@ -346,7 +346,7 @@ func (s *stateCoordinator) summary() Summary {
|
|||
sum.Labels = append(sum.Labels, v.summarize())
|
||||
}
|
||||
sort.Slice(sum.Labels, func(i, j int) bool {
|
||||
return sum.Labels[i].PkgName < sum.Labels[j].PkgName
|
||||
return sum.Labels[i].MetaName < sum.Labels[j].MetaName
|
||||
})
|
||||
|
||||
for _, v := range s.mRules {
|
||||
|
@ -356,7 +356,7 @@ func (s *stateCoordinator) summary() Summary {
|
|||
sum.NotificationRules = append(sum.NotificationRules, v.summarize())
|
||||
}
|
||||
sort.Slice(sum.NotificationRules, func(i, j int) bool {
|
||||
return sum.NotificationRules[i].PkgName < sum.NotificationRules[j].PkgName
|
||||
return sum.NotificationRules[i].MetaName < sum.NotificationRules[j].MetaName
|
||||
})
|
||||
|
||||
for _, t := range s.mTasks {
|
||||
|
@ -366,7 +366,7 @@ func (s *stateCoordinator) summary() Summary {
|
|||
sum.Tasks = append(sum.Tasks, t.summarize())
|
||||
}
|
||||
sort.Slice(sum.Tasks, func(i, j int) bool {
|
||||
return sum.Tasks[i].PkgName < sum.Tasks[j].PkgName
|
||||
return sum.Tasks[i].MetaName < sum.Tasks[j].MetaName
|
||||
})
|
||||
|
||||
for _, t := range s.mTelegrafs {
|
||||
|
@ -376,7 +376,7 @@ func (s *stateCoordinator) summary() Summary {
|
|||
sum.TelegrafConfigs = append(sum.TelegrafConfigs, t.summarize())
|
||||
}
|
||||
sort.Slice(sum.TelegrafConfigs, func(i, j int) bool {
|
||||
return sum.TelegrafConfigs[i].PkgName < sum.TelegrafConfigs[j].PkgName
|
||||
return sum.TelegrafConfigs[i].MetaName < sum.TelegrafConfigs[j].MetaName
|
||||
})
|
||||
|
||||
for _, v := range s.mVariables {
|
||||
|
@ -386,7 +386,7 @@ func (s *stateCoordinator) summary() Summary {
|
|||
sum.Variables = append(sum.Variables, v.summarize())
|
||||
}
|
||||
sort.Slice(sum.Variables, func(i, j int) bool {
|
||||
return sum.Variables[i].PkgName < sum.Variables[j].PkgName
|
||||
return sum.Variables[i].MetaName < sum.Variables[j].MetaName
|
||||
})
|
||||
|
||||
for _, v := range s.labelMappings {
|
||||
|
@ -726,7 +726,7 @@ func (b *stateBucket) diffBucket() DiffBucket {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(b.ID()),
|
||||
StateStatus: b.stateStatus,
|
||||
PkgName: b.parserBkt.PkgName(),
|
||||
MetaName: b.parserBkt.PkgName(),
|
||||
},
|
||||
New: DiffBucketValues{
|
||||
Name: b.parserBkt.Name(),
|
||||
|
@ -834,7 +834,7 @@ func (c *stateCheck) diffCheck() DiffCheck {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(c.ID()),
|
||||
StateStatus: c.stateStatus,
|
||||
PkgName: c.parserCheck.PkgName(),
|
||||
MetaName: c.parserCheck.PkgName(),
|
||||
},
|
||||
}
|
||||
if newCheck := c.summarize(); newCheck.Check != nil {
|
||||
|
@ -898,7 +898,7 @@ func (d *stateDashboard) diffDashboard() DiffDashboard {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(d.ID()),
|
||||
StateStatus: d.stateStatus,
|
||||
PkgName: d.parserDash.PkgName(),
|
||||
MetaName: d.parserDash.PkgName(),
|
||||
},
|
||||
New: DiffDashboardValues{
|
||||
Name: d.parserDash.Name(),
|
||||
|
@ -966,7 +966,7 @@ func (l *stateLabel) diffLabel() DiffLabel {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(l.ID()),
|
||||
StateStatus: l.stateStatus,
|
||||
PkgName: l.parserLabel.PkgName(),
|
||||
MetaName: l.parserLabel.PkgName(),
|
||||
},
|
||||
New: DiffLabelValues{
|
||||
Name: l.parserLabel.Name(),
|
||||
|
@ -1043,14 +1043,14 @@ type stateLabelMapping struct {
|
|||
func (lm stateLabelMapping) diffLabelMapping() DiffLabelMapping {
|
||||
ident := lm.resource.stateIdentity()
|
||||
return DiffLabelMapping{
|
||||
StateStatus: lm.status,
|
||||
ResType: ident.resourceType,
|
||||
ResID: SafeID(ident.id),
|
||||
ResPkgName: ident.pkgName,
|
||||
ResName: ident.name,
|
||||
LabelID: SafeID(lm.label.ID()),
|
||||
LabelPkgName: lm.label.parserLabel.PkgName(),
|
||||
LabelName: lm.label.parserLabel.Name(),
|
||||
StateStatus: lm.status,
|
||||
ResType: ident.resourceType,
|
||||
ResID: SafeID(ident.id),
|
||||
ResMetaName: ident.pkgName,
|
||||
ResName: ident.name,
|
||||
LabelID: SafeID(lm.label.ID()),
|
||||
LabelMetaName: lm.label.parserLabel.PkgName(),
|
||||
LabelName: lm.label.parserLabel.Name(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1087,12 +1087,12 @@ type stateLabelMappingForRemoval struct {
|
|||
|
||||
func (m *stateLabelMappingForRemoval) diffLabelMapping() DiffLabelMapping {
|
||||
return DiffLabelMapping{
|
||||
StateStatus: StateStatusRemove,
|
||||
ResType: m.ResourceType,
|
||||
ResID: SafeID(m.ResourceID),
|
||||
ResPkgName: m.ResourcePkgName,
|
||||
LabelID: SafeID(m.LabelID),
|
||||
LabelPkgName: m.LabelPkgName,
|
||||
StateStatus: StateStatusRemove,
|
||||
ResType: m.ResourceType,
|
||||
ResID: SafeID(m.ResourceID),
|
||||
ResMetaName: m.ResourcePkgName,
|
||||
LabelID: SafeID(m.LabelID),
|
||||
LabelMetaName: m.LabelPkgName,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1117,7 +1117,7 @@ func (e *stateEndpoint) diffEndpoint() DiffNotificationEndpoint {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(e.ID()),
|
||||
StateStatus: e.stateStatus,
|
||||
PkgName: e.parserEndpoint.PkgName(),
|
||||
MetaName: e.parserEndpoint.PkgName(),
|
||||
},
|
||||
}
|
||||
if sum := e.summarize(); sum.NotificationEndpoint != nil {
|
||||
|
@ -1197,7 +1197,7 @@ func (r *stateRule) diffRule() DiffNotificationRule {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(r.ID()),
|
||||
StateStatus: r.stateStatus,
|
||||
PkgName: r.parserRule.PkgName(),
|
||||
MetaName: r.parserRule.PkgName(),
|
||||
},
|
||||
New: DiffNotificationRuleValues{
|
||||
Name: r.parserRule.Name(),
|
||||
|
@ -1352,7 +1352,7 @@ func (t *stateTask) diffTask() DiffTask {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(t.ID()),
|
||||
StateStatus: t.stateStatus,
|
||||
PkgName: t.parserTask.PkgName(),
|
||||
MetaName: t.parserTask.PkgName(),
|
||||
},
|
||||
New: DiffTaskValues{
|
||||
Name: t.parserTask.Name(),
|
||||
|
@ -1428,7 +1428,7 @@ func (t *stateTelegraf) diffTelegraf() DiffTelegraf {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(t.ID()),
|
||||
StateStatus: t.stateStatus,
|
||||
PkgName: t.parserTelegraf.PkgName(),
|
||||
MetaName: t.parserTelegraf.PkgName(),
|
||||
},
|
||||
New: t.parserTelegraf.config,
|
||||
Old: t.existing,
|
||||
|
@ -1482,7 +1482,7 @@ func (v *stateVariable) diffVariable() DiffVariable {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(v.ID()),
|
||||
StateStatus: v.stateStatus,
|
||||
PkgName: v.parserVar.PkgName(),
|
||||
MetaName: v.parserVar.PkgName(),
|
||||
},
|
||||
New: DiffVariableValues{
|
||||
Name: v.parserVar.Name(),
|
||||
|
|
|
@ -171,7 +171,7 @@ func TestService(t *testing.T) {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(1),
|
||||
StateStatus: StateStatusExists,
|
||||
PkgName: "rucket-11",
|
||||
MetaName: "rucket-11",
|
||||
},
|
||||
|
||||
Old: &DiffBucketValues{
|
||||
|
@ -204,7 +204,7 @@ func TestService(t *testing.T) {
|
|||
|
||||
expected := DiffBucket{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
PkgName: "rucket-11",
|
||||
MetaName: "rucket-11",
|
||||
StateStatus: StateStatusNew,
|
||||
},
|
||||
New: DiffBucketValues{
|
||||
|
@ -266,13 +266,13 @@ func TestService(t *testing.T) {
|
|||
require.Len(t, checks, 2)
|
||||
check0 := checks[0]
|
||||
assert.True(t, check0.IsNew())
|
||||
assert.Equal(t, "check-0", check0.PkgName)
|
||||
assert.Equal(t, "check-0", check0.MetaName)
|
||||
assert.Zero(t, check0.ID)
|
||||
assert.Nil(t, check0.Old)
|
||||
|
||||
check1 := checks[1]
|
||||
assert.False(t, check1.IsNew())
|
||||
assert.Equal(t, "check-1", check1.PkgName)
|
||||
assert.Equal(t, "check-1", check1.MetaName)
|
||||
assert.Equal(t, "display name", check1.New.GetName())
|
||||
assert.NotZero(t, check1.ID)
|
||||
assert.Equal(t, existing, check1.Old.Check)
|
||||
|
@ -349,7 +349,7 @@ func TestService(t *testing.T) {
|
|||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(1),
|
||||
StateStatus: StateStatusExists,
|
||||
PkgName: "label-1",
|
||||
MetaName: "label-1",
|
||||
},
|
||||
Old: &DiffLabelValues{
|
||||
Name: "label-1",
|
||||
|
@ -364,7 +364,7 @@ func TestService(t *testing.T) {
|
|||
}
|
||||
assert.Contains(t, impact.Diff.Labels, expected)
|
||||
|
||||
expected.PkgName = "label-2"
|
||||
expected.MetaName = "label-2"
|
||||
expected.New.Name = "label-2"
|
||||
expected.New.Color = "#000000"
|
||||
expected.New.Description = "label 2 description"
|
||||
|
@ -389,7 +389,7 @@ func TestService(t *testing.T) {
|
|||
|
||||
expected := DiffLabel{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
PkgName: "label-1",
|
||||
MetaName: "label-1",
|
||||
StateStatus: StateStatusNew,
|
||||
},
|
||||
New: DiffLabelValues{
|
||||
|
@ -400,7 +400,7 @@ func TestService(t *testing.T) {
|
|||
}
|
||||
assert.Contains(t, labels, expected)
|
||||
|
||||
expected.PkgName = "label-2"
|
||||
expected.MetaName = "label-2"
|
||||
expected.New.Name = "label-2"
|
||||
expected.New.Color = "#000000"
|
||||
expected.New.Description = "label 2 description"
|
||||
|
@ -477,7 +477,7 @@ func TestService(t *testing.T) {
|
|||
expected := DiffNotificationEndpoint{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 1,
|
||||
PkgName: "http-none-auth-notification-endpoint",
|
||||
MetaName: "http-none-auth-notification-endpoint",
|
||||
StateStatus: StateStatusExists,
|
||||
},
|
||||
Old: &DiffNotificationEndpointValues{
|
||||
|
@ -690,7 +690,7 @@ func TestService(t *testing.T) {
|
|||
expected := DiffVariable{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: 1,
|
||||
PkgName: "var-const-3",
|
||||
MetaName: "var-const-3",
|
||||
StateStatus: StateStatusExists,
|
||||
},
|
||||
Old: &DiffVariableValues{
|
||||
|
@ -711,7 +711,7 @@ func TestService(t *testing.T) {
|
|||
expected = DiffVariable{
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
// no ID here since this one would be new
|
||||
PkgName: "var-map-4",
|
||||
MetaName: "var-map-4",
|
||||
StateStatus: StateStatusNew,
|
||||
},
|
||||
New: DiffVariableValues{
|
||||
|
@ -787,7 +787,7 @@ func TestService(t *testing.T) {
|
|||
expected := SummaryBucket{
|
||||
ID: SafeID(time.Hour),
|
||||
OrgID: SafeID(orgID),
|
||||
PkgName: "rucket-11",
|
||||
MetaName: "rucket-11",
|
||||
Name: "rucket-11",
|
||||
Description: "bucket 1 description",
|
||||
RetentionPeriod: time.Hour,
|
||||
|
@ -839,7 +839,7 @@ func TestService(t *testing.T) {
|
|||
expected := SummaryBucket{
|
||||
ID: SafeID(3),
|
||||
OrgID: SafeID(orgID),
|
||||
PkgName: "rucket-11",
|
||||
MetaName: "rucket-11",
|
||||
Name: "rucket-11",
|
||||
Description: "bucket 1 description",
|
||||
RetentionPeriod: time.Hour,
|
||||
|
@ -1092,13 +1092,13 @@ func TestService(t *testing.T) {
|
|||
dash1 := sum.Dashboards[0]
|
||||
assert.NotZero(t, dash1.ID)
|
||||
assert.NotZero(t, dash1.OrgID)
|
||||
assert.Equal(t, "dash-1", dash1.PkgName)
|
||||
assert.Equal(t, "dash-1", dash1.MetaName)
|
||||
assert.Equal(t, "display name", dash1.Name)
|
||||
require.Len(t, dash1.Charts, 1)
|
||||
|
||||
dash2 := sum.Dashboards[1]
|
||||
assert.NotZero(t, dash2.ID)
|
||||
assert.Equal(t, "dash-2", dash2.PkgName)
|
||||
assert.Equal(t, "dash-2", dash2.MetaName)
|
||||
assert.Equal(t, "dash-2", dash2.Name)
|
||||
require.Empty(t, dash2.Charts)
|
||||
})
|
||||
|
@ -1475,7 +1475,7 @@ func TestService(t *testing.T) {
|
|||
|
||||
sum := impact.Summary
|
||||
require.Len(t, sum.NotificationRules, 1)
|
||||
assert.Equal(t, "rule-uuid", sum.NotificationRules[0].PkgName)
|
||||
assert.Equal(t, "rule-uuid", sum.NotificationRules[0].MetaName)
|
||||
assert.Equal(t, "rule_0", sum.NotificationRules[0].Name)
|
||||
assert.Equal(t, "desc_0", sum.NotificationRules[0].Description)
|
||||
assert.Equal(t, SafeID(1), sum.NotificationRules[0].EndpointID)
|
||||
|
@ -1553,12 +1553,12 @@ func TestService(t *testing.T) {
|
|||
sum := impact.Summary
|
||||
require.Len(t, sum.Tasks, 2)
|
||||
assert.NotZero(t, sum.Tasks[0].ID)
|
||||
assert.Equal(t, "task-1", sum.Tasks[0].PkgName)
|
||||
assert.Equal(t, "task-1", sum.Tasks[0].MetaName)
|
||||
assert.Equal(t, "task-1", sum.Tasks[0].Name)
|
||||
assert.Equal(t, "desc_1", sum.Tasks[0].Description)
|
||||
|
||||
assert.NotZero(t, sum.Tasks[1].ID)
|
||||
assert.Equal(t, "task-uuid", sum.Tasks[1].PkgName)
|
||||
assert.Equal(t, "task-uuid", sum.Tasks[1].MetaName)
|
||||
assert.Equal(t, "task-0", sum.Tasks[1].Name)
|
||||
assert.Equal(t, "desc_0", sum.Tasks[1].Description)
|
||||
})
|
||||
|
|
|
@ -30,7 +30,11 @@ import {
|
|||
getTemplateNameFromGithubUrl,
|
||||
} from 'src/templates/utils'
|
||||
|
||||
import {Error as PkgError, PkgSummary, postPackagesApply} from 'src/client'
|
||||
import {
|
||||
Error as PkgError,
|
||||
TemplateSummary,
|
||||
postTemplatesApply,
|
||||
} from 'src/client'
|
||||
|
||||
// Types
|
||||
import {AppState, Organization} from 'src/types'
|
||||
|
@ -156,12 +160,12 @@ class UnconnectedTemplatesIndex extends Component<Props> {
|
|||
},
|
||||
}
|
||||
try {
|
||||
const resp = await postPackagesApply(params)
|
||||
const resp = await postTemplatesApply(params)
|
||||
if (resp.status >= 300) {
|
||||
throw new Error((resp.data as PkgError).message)
|
||||
}
|
||||
|
||||
const summary = (resp.data as PkgSummary).summary
|
||||
const summary = (resp.data as TemplateSummary).summary
|
||||
this.props.setActiveCommunityTemplate(summary)
|
||||
return summary
|
||||
} catch (err) {
|
||||
|
|
Loading…
Reference in New Issue