Skip to content

Commit

Permalink
Fix panic when running 'axiom ingest' without dataset argument
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmalkmus committed Apr 9, 2021
1 parent 1d124f1 commit 5ba0542
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cmd/axiom/ingest/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewIngestCmd(f *cmdutil.Factory) *cobra.Command {
}

cmd := &cobra.Command{
Use: "ingest <dataset-name> [(-f|--file) <filename> [ ...]] [--timestamp-field <timestamp-field>] [--timestamp-format <timestamp-format>] [--flush-every <duration>] [(-c|--compression=)TRUE|FALSE]",
Use: "ingest <dataset-name> [(-f|--file) <filename> [ ...]] [--timestamp-field <timestamp-field>] [--timestamp-format <timestamp-format>] [--flush-every <duration>]",
Short: "Ingest data",
Long: heredoc.Doc(`
Ingest data into an Axiom dataset.
Expand Down Expand Up @@ -83,10 +83,6 @@ func NewIngestCmd(f *cmdutil.Factory) *cobra.Command {
# "nginx-logs":
$ axiom ingest nginx-logs -f nginx-logs.json
# Ingest the contents of all files inside /var/logs/nginx with
# extension ".log" into a dataset named "nginx-logs":
$ axiom ingest nginx-logs -f /var/logs/nginx/*.log
# Pipe the contents of a log generator into a dataset named
# "gen-logs". If the length of the data stream is unknown, the
# "--flush-every" flag can be tweaked to optimize shipping the data
Expand Down Expand Up @@ -146,7 +142,7 @@ func complete(ctx context.Context, opts *options) error {

// Just fetch a list of available datasets if a Personal Access Token is
// used.
datasetNames := make([]string, 0)
var datasetNames []string
if dep, ok := opts.Config.GetActiveDeployment(); ok && client.IsPersonalToken(dep.Token) {
client, err := opts.Client()
if err != nil {
Expand All @@ -163,6 +159,7 @@ func complete(ctx context.Context, opts *options) error {

stop()

datasetNames = make([]string, len(datasets))
for i, dataset := range datasets {
datasetNames[i] = dataset.Name
}
Expand Down

0 comments on commit 5ba0542

Please sign in to comment.