Skip to content

Commit 0064b4f

Browse files
committed
fix: fix immudb and immugw version and mangen commands errors
Without this change, while immuclient and immuadmin still worked as expected, immudb and immugw version and mangen commands were throwing the following error: ./immugw version Error: flag accessed but not defined: config Usage: immugw version [flags] Flags: -h, --help help for version flag accessed but not defined: config
1 parent 2dd75b4 commit 0064b4f

File tree

8 files changed

+28
-22
lines changed

8 files changed

+28
-22
lines changed

cmd/helper/config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ limitations under the License.
1717
package helper
1818

1919
import (
20+
"os"
21+
"strings"
22+
2023
service "github.com/codenotary/immudb/cmd/immuclient/service/constants"
2124
"github.com/mitchellh/go-homedir"
2225
"github.com/spf13/cobra"
2326
"github.com/spf13/viper"
24-
"os"
25-
"strings"
2627
)
2728

2829
// Options cmd options
@@ -59,10 +60,9 @@ func (c *Config) Init(name string) error {
5960
return nil
6061
}
6162

63+
// LoadConfig loads the config file (if any) and initializes the config
6264
func (c *Config) LoadConfig(cmd *cobra.Command) (err error) {
63-
if c.CfgFn, err = cmd.Flags().GetString("config"); err != nil {
64-
return err
65-
}
65+
c.CfgFn, _ = cmd.Flags().GetString("config")
6666
if err = c.Init(c.Name); err != nil {
6767
if !strings.Contains(err.Error(), "Not Found") {
6868
return err

cmd/helper/config_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ limitations under the License.
1717
package helper
1818

1919
import (
20-
"github.com/mitchellh/go-homedir"
21-
"github.com/spf13/cobra"
22-
"github.com/spf13/viper"
23-
"github.com/stretchr/testify/assert"
2420
"io/ioutil"
2521
"log"
2622
"os"
2723
"testing"
24+
25+
"github.com/mitchellh/go-homedir"
26+
"github.com/spf13/cobra"
27+
"github.com/spf13/viper"
28+
"github.com/stretchr/testify/assert"
2829
)
2930

3031
func TestOptions_InitConfig(t *testing.T) {
@@ -85,7 +86,7 @@ func TestConfig_LoadError(t *testing.T) {
8586
assert.NotNil(t, address)
8687
cmd := cobra.Command{}
8788
err := o.LoadConfig(&cmd)
88-
assert.Error(t, err)
89+
assert.NoError(t, err)
8990
}
9091

9192
func TestConfig_LoadError2(t *testing.T) {

cmd/immuadmin/command/backup_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23-
"github.com/codenotary/immudb/cmd/helper"
24-
"github.com/stretchr/testify/assert"
2523
"io"
2624
"io/ioutil"
2725
stdos "os"
2826
"path/filepath"
2927
"testing"
3028

29+
"github.com/codenotary/immudb/cmd/helper"
30+
"github.com/stretchr/testify/assert"
31+
3132
"github.com/codenotary/immudb/cmd/cmdtest"
3233
"github.com/codenotary/immudb/pkg/api/schema"
3334
"github.com/codenotary/immudb/pkg/client"
@@ -854,5 +855,5 @@ func TestCommandlineBck_ConfigChainErr(t *testing.T) {
854855
cc := c.ConfigChain(f)
855856

856857
err := cc(cmd, []string{})
857-
assert.Error(t, err)
858+
assert.NoError(t, err)
858859
}

cmd/immuadmin/command/commandline_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ package immuadmin
1919
import (
2020
"context"
2121
"errors"
22+
"testing"
23+
2224
"github.com/codenotary/immudb/cmd/helper"
2325
"github.com/stretchr/testify/assert"
24-
"testing"
2526

2627
"github.com/codenotary/immudb/pkg/client/clienttest"
2728
"github.com/stretchr/testify/require"
@@ -138,5 +139,5 @@ func TestCommandline_ConfigChainErr(t *testing.T) {
138139
cc := c.ConfigChain(f)
139140

140141
err := cc(cmd, []string{})
141-
assert.Error(t, err)
142+
assert.NoError(t, err)
142143
}

cmd/immuclient/audit/auditor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestInitAgent(t *testing.T) {
5656
_, err = ad.InitAgent()
5757
os.RemoveAll(pidPath)
5858
require.Error(t, err)
59-
require.Contains(t, err.Error(), "invalid duration X")
59+
require.Contains(t, err.Error(), "invalid duration")
6060
os.Unsetenv("audit-agent-interval")
6161

6262
auditPassword := viper.GetString("audit-password")

cmd/immuclient/command/commandline_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ limitations under the License.
1717
package immuclient
1818

1919
import (
20+
"testing"
21+
2022
"github.com/codenotary/immudb/cmd/helper"
2123
"github.com/stretchr/testify/assert"
22-
"testing"
2324

2425
"github.com/spf13/cobra"
2526
)
@@ -60,5 +61,5 @@ func TestCommandline_ConfigChainErr(t *testing.T) {
6061
cc := c.ConfigChain(f)
6162

6263
err := cc(cmd, []string{})
63-
assert.Error(t, err)
64+
assert.NoError(t, err)
6465
}

cmd/immudb/command/commandline_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ limitations under the License.
1717
package immudb
1818

1919
import (
20+
"testing"
21+
2022
"github.com/codenotary/immudb/cmd/helper"
2123
"github.com/spf13/cobra"
2224
"github.com/stretchr/testify/assert"
23-
"testing"
2425
)
2526

2627
func TestCommandline_Immudb(t *testing.T) {
@@ -58,5 +59,5 @@ func TestCommandline_ConfigChainErr(t *testing.T) {
5859
cc := c.ConfigChain(f)
5960

6061
err := cc(cmd, []string{})
61-
assert.Error(t, err)
62+
assert.NoError(t, err)
6263
}

cmd/immugw/command/commandline_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ limitations under the License.
1717
package immugw
1818

1919
import (
20+
"testing"
21+
2022
"github.com/codenotary/immudb/cmd/helper"
2123
"github.com/stretchr/testify/assert"
22-
"testing"
2324

2425
"github.com/spf13/cobra"
2526
)
@@ -49,5 +50,5 @@ func TestCommandline_ConfigChainErr(t *testing.T) {
4950
cc := c.ConfigChain(f)
5051

5152
err := cc(cmd, []string{})
52-
assert.Error(t, err)
53+
assert.NoError(t, err)
5354
}

0 commit comments

Comments
 (0)