Skip to content

Commit

Permalink
Merge pull request #351 from nats-io/js-fix
Browse files Browse the repository at this point in the history
Minor fixes to make js work when only js params are provided
  • Loading branch information
matthiashanel authored Jan 25, 2021
2 parents 15848a4 + b340ab2 commit 1fe1b68
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
4 changes: 1 addition & 3 deletions cmd/adduser.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 The NATS Authors
* Copyright 2018-2021 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -465,8 +465,6 @@ func (p *PermissionsParams) Run(perms *jwt.Permissions, ctx ActionCtx) (*store.R
return r, nil
}

fmt.Printf("%v\n", ctx.CurrentCmd().Flag("max-responses").Value)

if ctx.CurrentCmd().Flag("max-responses").Changed || p.respMax != 0 {
if perms.Resp == nil {
perms.Resp = &jwt.ResponsePermission{}
Expand Down
8 changes: 4 additions & 4 deletions cmd/common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 The NATS Authors
* Copyright 2018-2021 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -165,13 +165,13 @@ func ParseNumber(s string) (int64, error) {
return v, nil
}
if m[2] == "K" {
return v * 1000, nil
return v * 1024, nil
}
if m[2] == "M" {
return v * 1000000, nil
return v * 1024 * 1024, nil
}
if m[2] == "G" {
return v * 1000000000, nil
return v * 1024 * 1024 * 1024, nil
}
}
return 0, fmt.Errorf("couldn't parse number: %v", s)
Expand Down
14 changes: 7 additions & 7 deletions cmd/common_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 The NATS Authors
* Copyright 2018-2021 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -168,12 +168,12 @@ func TestCommon_ParseNumber(t *testing.T) {
{"", 0, false},
{"0", 0, false},
{"1000", 1000, false},
{"1K", 1000, false},
{"1k", 1000, false},
{"1M", 1000000, false},
{"1m", 1000000, false},
{"1G", 1000000000, false},
{"1g", 1000000000, false},
{"1K", 1024, false},
{"1k", 1024, false},
{"1M", 1024 * 1024, false},
{"1m", 1024 * 1024, false},
{"1G", 1024 * 1024 * 1024, false},
{"1g", 1024 * 1024 * 1024, false},
{"32a", 0, true},
}
for _, d := range tests {
Expand Down
4 changes: 2 additions & 2 deletions cmd/editaccount.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2019 The NATS Authors
* Copyright 2018-2021 The NATS Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -122,7 +122,7 @@ func (p *EditAccountParams) SetDefaults(ctx ActionCtx) error {
"start", "expiry", "tag", "rm-tag", "conns", "leaf-conns", "exports", "imports", "subscriptions",
"payload", "data", "wildcard-exports", "sk", "rm-sk", "description", "info-url", "response-ttl", "allow-pub-response",
"allow-pub-response", "allow-pub", "allow-pubsub", "allow-sub", "deny-pub", "deny-pubsub", "deny-sub",
"rm-response-perms", "rm", "max-responses") {
"rm-response-perms", "rm", "max-responses", "mem-storage", "disk-storage", "streams", "consumer") {
ctx.CurrentCmd().SilenceUsage = false
return fmt.Errorf("specify an edit option")
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/editaccount_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* * Copyright 2018-2019 The NATS Authors
* * Copyright 2018-2021 The NATS Authors
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
Expand Down Expand Up @@ -123,10 +123,10 @@ func Test_EditAccountLimits(t *testing.T) {
require.NoError(t, err)
require.Equal(t, int64(5), ac.Limits.Conn)
require.Equal(t, int64(31), ac.Limits.LeafNodeConn)
require.Equal(t, int64(1000*1000*10), ac.Limits.Data)
require.Equal(t, int64(1024*1024*10), ac.Limits.Data)
require.Equal(t, int64(15), ac.Limits.Exports)
require.Equal(t, int64(20), ac.Limits.Imports)
require.Equal(t, int64(1000), ac.Limits.Payload)
require.Equal(t, int64(1024), ac.Limits.Payload)
require.Equal(t, int64(30), ac.Limits.Subs)
require.Equal(t, int64(5), ac.Limits.Streams)
require.Equal(t, int64(6), ac.Limits.Consumer)
Expand Down

0 comments on commit 1fe1b68

Please sign in to comment.