Skip to content

Commit

Permalink
feat(pkger): extend pkger to provide sources of templates to each tem…
Browse files Browse the repository at this point in the history
…plate
  • Loading branch information
jsteenb2 committed Jun 16, 2020
1 parent 4ea5895 commit bfd4fbe
Show file tree
Hide file tree
Showing 18 changed files with 407 additions and 201 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Features

1. [18515](https://github.com/influxdata/influxdb/pull/18515): Extend templates with the source file|url|reader.

## v2.0.0-beta.12 [2020-06-12]

### Features
Expand Down
5 changes: 3 additions & 2 deletions cmd/influx/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,12 @@ func (b *cmdPkgBuilder) pkgApplyRunEFn(cmd *cobra.Command, args []string) error
}

opts := []pkger.ApplyOptFn{
pkger.ApplyWithPkg(pkg),
pkger.ApplyWithEnvRefs(providedEnvRefs),
pkger.ApplyWithStackID(stackID),
}

dryRunImpact, err := svc.DryRun(context.Background(), influxOrgID, 0, pkg, opts...)
dryRunImpact, err := svc.DryRun(context.Background(), influxOrgID, 0, opts...)
if err != nil {
return err
}
Expand Down Expand Up @@ -254,7 +255,7 @@ func (b *cmdPkgBuilder) pkgApplyRunEFn(cmd *cobra.Command, args []string) error

opts = append(opts, pkger.ApplyWithSecrets(providedSecrets))

impact, err := svc.Apply(context.Background(), influxOrgID, 0, pkg, opts...)
impact, err := svc.Apply(context.Background(), influxOrgID, 0, opts...)
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/influx/pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,8 @@ func testPkgWritesToBuffer(newCmdFn func(w io.Writer) *cobra.Command, args pkgFi
type fakePkgSVC struct {
initStackFn func(ctx context.Context, userID influxdb.ID, stack pkger.Stack) (pkger.Stack, error)
createFn func(ctx context.Context, setters ...pkger.CreatePkgSetFn) (*pkger.Pkg, error)
dryRunFn func(ctx context.Context, orgID, userID influxdb.ID, pkg *pkger.Pkg) (pkger.PkgImpactSummary, error)
applyFn func(ctx context.Context, orgID, userID influxdb.ID, pkg *pkger.Pkg, opts ...pkger.ApplyOptFn) (pkger.PkgImpactSummary, error)
dryRunFn func(ctx context.Context, orgID, userID influxdb.ID, opts ...pkger.ApplyOptFn) (pkger.PkgImpactSummary, error)
applyFn func(ctx context.Context, orgID, userID influxdb.ID, opts ...pkger.ApplyOptFn) (pkger.PkgImpactSummary, error)
}

var _ pkger.SVC = (*fakePkgSVC)(nil)
Expand Down Expand Up @@ -740,16 +740,16 @@ func (f *fakePkgSVC) CreatePkg(ctx context.Context, setters ...pkger.CreatePkgSe
panic("not implemented")
}

func (f *fakePkgSVC) DryRun(ctx context.Context, orgID, userID influxdb.ID, pkg *pkger.Pkg, opts ...pkger.ApplyOptFn) (pkger.PkgImpactSummary, error) {
func (f *fakePkgSVC) DryRun(ctx context.Context, orgID, userID influxdb.ID, opts ...pkger.ApplyOptFn) (pkger.PkgImpactSummary, error) {
if f.dryRunFn != nil {
return f.dryRunFn(ctx, orgID, userID, pkg)
return f.dryRunFn(ctx, orgID, userID, opts...)
}
panic("not implemented")
}

func (f *fakePkgSVC) Apply(ctx context.Context, orgID, userID influxdb.ID, pkg *pkger.Pkg, opts ...pkger.ApplyOptFn) (pkger.PkgImpactSummary, error) {
func (f *fakePkgSVC) Apply(ctx context.Context, orgID, userID influxdb.ID, opts ...pkger.ApplyOptFn) (pkger.PkgImpactSummary, error) {
if f.applyFn != nil {
return f.applyFn(ctx, orgID, userID, pkg, opts...)
return f.applyFn(ctx, orgID, userID, opts...)
}
panic("not implemented")
}
Expand Down
Loading

0 comments on commit bfd4fbe

Please sign in to comment.