Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic when running 'axiom ingest' without dataset argument #71

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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