Skip to content

Commit

Permalink
Merge branch 'master' into feat/conditionally-query-cell
Browse files Browse the repository at this point in the history
  • Loading branch information
asalem1 authored Jun 18, 2020
2 parents 8d8517f + 8d9e3bb commit 5a61d99
Show file tree
Hide file tree
Showing 31 changed files with 1,512 additions and 951 deletions.
22 changes: 10 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,30 +175,28 @@ jobs:
docker --version
google-chrome --version && which google-chrome && chromedriver --version && which chromedriver
timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9999)" != "200" ]]; do sleep 5; done' || false
- run:
name: Checkout Tests
command: git clone --single-branch --branch 2.0-Beta https://github.com/bonitoo-io/selenium-accept-infl2.git
- run:
name: Selenium tests
command: |
set +e
cd selenium-accept-infl2
cd e2e
npm install
sed -i "s/\"headless\": false/\"headless\": true/g" e2e.conf.json
npm test; TEST_RESULT=$?
npm run report:html
npm run report:junit
mkdir -p ~/test-results/cucumber
mkdir -p ~/artifacts/html
cp ~/project/selenium-accept-infl2/report/cucumber_report.html ~/artifacts/html/cucumber_report.html
cp ~/project/selenium-accept-infl2/report/cucumber_junit.xml ~/test-results/cucumber/report.xml
cp ~/project/selenium-accept-infl2/report/cucumber_junit.xml ~/artifacts/report.xml
cp -r ~/project/selenium-accept-infl2/screenshots ~/artifacts
mkdir -p ~/e2e/test-results/cucumber
mkdir -p ~/e2e/artifacts/html
cp ~/project/e2e/report/cucumber_report.html ~/e2e/artifacts/html/cucumber_report.html
cp ~/project/e2e/report/cucumber_junit.xml ~/e2e/test-results/cucumber/report.xml
cp ~/project/e2e/report/cucumber_junit.xml ~/e2e/artifacts/report.xml
cp -r ~/project/e2e/screenshots ~/e2e/artifacts
ls -al
exit $TEST_RESULT
- store_test_results:
path: ~/test-results
path: ~/e2e/test-results
- store_artifacts:
path: ~/artifacts
path: ~/e2e/artifacts
jstest:
docker:
- image: circleci/golang:1.13-node-browsers
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
1. [18568](https://github.com/influxdata/influxdb/pull/18568): Add support for config files to influxd and any cli.NewCommand use case
1. [18573](https://github.com/influxdata/influxdb/pull/18573): Extend influx stacks cmd with new influx stacks update cmd
1. [18581](https://github.com/influxdata/influxdb/pull/18581): Cache dashboard cell query results to use as a reference for cell configurations
1. [18595](https://github.com/influxdata/influxdb/pull/18595): Add ability to skip resources in a template by kind or by metadata.name
1. [18600](https://github.com/influxdata/influxdb/pull/18600): Extend influx apply with resource filter capabilities
1. [18601](https://github.com/influxdata/influxdb/pull/18601): Provide active config running influx config without args

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

Expand Down Expand Up @@ -41,6 +44,7 @@
1. [18361](https://github.com/influxdata/influxdb/pull/18361): Tokens list is now consistent with the other resource lists
1. [18346](https://github.com/influxdata/influxdb/pull/18346): Reduce the number of variables being hydrated when toggling variables
1. [18447](https://github.com/influxdata/influxdb/pull/18447): Redesign dashboard cell loading indicator to be more obvious
1. [18593](https://github.com/influxdata/influxdb/pull/18593): Add copyable User and Organization Ids to About page

## v2.0.0-beta.11 [2020-05-26]

Expand Down
28 changes: 25 additions & 3 deletions cmd/influx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type cmdConfigBuilder struct {
func (b *cmdConfigBuilder) cmd() *cobra.Command {
cmd := b.newCmd("config [config name]", b.cmdSwitchActiveRunEFn, false)
cmd.Short = "Config management commands"
cmd.Args = cobra.ExactArgs(1)
cmd.Args = cobra.ArbitraryArgs

cmd.AddCommand(
b.cmdCreate(),
Expand All @@ -50,13 +50,35 @@ func (b *cmdConfigBuilder) cmd() *cobra.Command {
}

func (b *cmdConfigBuilder) cmdSwitchActiveRunEFn(cmd *cobra.Command, args []string) error {
cfg, err := b.svc.SwitchActive(args[0])
if len(args) > 0 {
cfg, err := b.svc.SwitchActive(args[0])
if err != nil {
return err
}

return b.printConfigs(configPrintOpts{
config: cfg,
})
}

configs, err := b.svc.ListConfigs()
if err != nil {
return err
}

var active config.Config
for _, cfg := range configs {
if cfg.Active {
active = cfg
break
}
}
if !active.Active {
return nil
}

return b.printConfigs(configPrintOpts{
config: cfg,
config: active,
})
}

Expand Down
1 change: 0 additions & 1 deletion cmd/influx/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

func TestCmdConfig(t *testing.T) {

t.Run("create", func(t *testing.T) {
tests := []struct {
name string
Expand Down
63 changes: 58 additions & 5 deletions cmd/influx/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ func (b *cmdPkgBuilder) cmdPkgApply() *cobra.Command {
# Applying directories from many sources, file and URL
influx apply -f $PATH_TO_TEMPLATE/template.yml -f $URL_TO_TEMPLATE
# Applying a template with actions to skip resources applied. The
# following example skips all buckets and the dashboard whose
# metadata.name field matches the provided $DASHBOARD_TMPL_NAME.
# format for filters:
# --filter=kind=Bucket
# --filter=resource=Label:$Label_TMPL_NAME
influx apply \
-f $PATH_TO_TEMPLATE/template.yml \
--filter kind=Bucket \
--filter resource=Dashboard:$DASHBOARD_TMPL_NAME
For information about finding and using InfluxDB templates, see
https://v2.docs.influxdata.com/v2.0/reference/cli/influx/apply/.
Expand All @@ -174,6 +185,7 @@ func (b *cmdPkgBuilder) cmdPkgApply() *cobra.Command {
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")
cmd.Flags().StringSliceVar(&b.applyOpts.envRefs, "env-ref", nil, "Environment references to provide alongside the template; format should --env-ref=REF_KEY=REF_VALUE --env-ref=REF_KEY_2=REF_VALUE_2")
cmd.Flags().StringSliceVar(&b.filters, "filter", nil, "Resources to skip when applying the template. Filter out by ‘kind’ or by ‘resource’")

return cmd
}
Expand Down Expand Up @@ -220,6 +232,12 @@ func (b *cmdPkgBuilder) pkgApplyRunEFn(cmd *cobra.Command, args []string) error
pkger.ApplyWithStackID(stackID),
}

actionOpts, err := parseTemplateActions(b.filters)
if err != nil {
return err
}
opts = append(opts, actionOpts...)

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

func parseTemplateActions(args []string) ([]pkger.ApplyOptFn, error) {
var opts []pkger.ApplyOptFn
for _, rawAct := range args {
pair := strings.SplitN(rawAct, "=", 2)
if len(pair) < 2 {
continue
}
key, val := pair[0], pair[1]
switch strings.ToLower(key) {
case "kind":
opts = append(opts, pkger.ApplyWithKindSkip(pkger.ActionSkipKind{
Kind: pkger.Kind(val),
}))
case "resource":
pp := strings.SplitN(val, ":", 2)
if len(pair) != 2 {
return nil, fmt.Errorf(`invalid skipResource action provided: %q;
Expected format --action=skipResource=Label:$LABEL_ID`, rawAct)
}
kind, metaName := pp[0], pp[1]
opts = append(opts, pkger.ApplyWithResourceSkip(pkger.ActionSkipResource{
Kind: pkger.Kind(kind),
MetaName: metaName,
}))
default:
return nil, fmt.Errorf(`invalid action provided: %q;
Expected format --action=skipResource=Label:$LABEL_ID
or
Expected format --action=skipKind=Bucket`, rawAct)
}
}

return opts, nil
}

func (b *cmdPkgBuilder) cmdPkgExport() *cobra.Command {
cmd := b.newCmd("export", b.pkgExportRunEFn, true)
cmd.Short = "Export existing resources as a package"
Expand Down Expand Up @@ -383,23 +436,23 @@ func (b *cmdPkgBuilder) cmdPkgExportAll() *cobra.Command {
influx pkg export all --org $ORG_NAME
# Export all bucket resources
influx export all --org $ORG_NAME --filter=resourceKind=Bucket
influx export all --org $ORG_NAME --filter=kind=Bucket
# Export all resources associated with label Foo
influx export all --org $ORG_NAME --filter=labelName=Foo
# Export all bucket resources and filter by label Foo
influx export all --org $ORG_NAME \
--filter=resourceKind=Bucket \
--filter=kind=Bucket \
--filter=labelName=Foo
# Export all bucket or dashboard resources and filter by label Foo.
# note: like filters are unioned and filter types are intersections.
# This example will export a resource if it is a dashboard or
# bucket and has an associated label of Foo.
influx export all --org $ORG_NAME \
--filter=resourceKind=Bucket \
--filter=resourceKind=Dashboard \
--filter=kind=Bucket \
--filter=kind=Dashboard \
--filter=labelName=Foo
For information about exporting InfluxDB templates, see
Expand Down Expand Up @@ -439,7 +492,7 @@ func (b *cmdPkgBuilder) pkgExportAllRunEFn(cmd *cobra.Command, args []string) er
switch key, val := pair[0], pair[1]; key {
case "labelName":
labelNames = append(labelNames, val)
case "resourceKind":
case "kind", "resourceKind":
k := pkger.Kind(val)
if err := k.OK(); err != nil {
return err
Expand Down
Loading

0 comments on commit 5a61d99

Please sign in to comment.