diff --git a/build/Dockerfile.immuadmin b/build/Dockerfile.immuadmin index 05905cacfa..ebda4847c9 100644 --- a/build/Dockerfile.immuadmin +++ b/build/Dockerfile.immuadmin @@ -11,16 +11,17 @@ COPY --from=build /src/immuadmin /usr/local/bin/immuadmin ARG IMMU_UID="3322" ARG IMMU_GID="3322" +ARG IMMUADMIN_TOKENFILE_PATH=/var/lib/immudb ENV IMMUADMIN_IMMUDB_ADDRESS="127.0.0.1" \ IMMUADMIN_IMMUDB_PORT="3322" \ IMMUADMIN_MTLS="false" \ - IMMUADMIN_TOKENFILE="/var/lib/immudb" + IMMUADMIN_TOKENFILE="$IMMUADMIN_TOKENFILE_PATH/token_admin" RUN addgroup --system --gid $IMMU_GID immu && \ adduser --system --uid $IMMU_UID --no-create-home --ingroup immu immu && \ - mkdir -p "$IMMUADMIN_TOKENFILE" && \ - chown -R immu:immu "$IMMUADMIN_TOKENFILE" && \ + mkdir -p "$IMMUADMIN_TOKENFILE_PATH" && \ + chown -R immu:immu "$IMMUADMIN_TOKENFILE_PATH" && \ chmod +x /usr/local/bin/immuadmin USER immu diff --git a/cmd/immuadmin/command/commandline.go b/cmd/immuadmin/command/commandline.go index 77660c6aa4..adab90fb63 100644 --- a/cmd/immuadmin/command/commandline.go +++ b/cmd/immuadmin/command/commandline.go @@ -118,9 +118,8 @@ func (cl *commandline) connect(cmd *cobra.Command, args []string) (err error) { if cl.immuClient, err = client.NewImmuClient(cl.options); err != nil { cl.quit(err) } - cl.immuClient.WithTokenService(tokenservice.NewFileTokenService().WithTokenFileName("token_admin")) + cl.immuClient.WithTokenService(cl.ts) return - } func (cl *commandline) checkLoggedIn(cmd *cobra.Command, args []string) (err error) { diff --git a/pkg/client/tokenservice/file.go b/pkg/client/tokenservice/file.go index 1ef2baaa04..9d6999b2f4 100644 --- a/pkg/client/tokenservice/file.go +++ b/pkg/client/tokenservice/file.go @@ -32,7 +32,7 @@ type file struct { hds homedir.HomedirService } -//NewFileTokenService ... +// NewFileTokenService ... func NewFileTokenService() *file { return &file{ tokenFileName: "token", @@ -50,7 +50,7 @@ func (ts *file) GetToken() (string, error) { return token, nil } -//SetToken ... +// SetToken ... func (ts *file) SetToken(database string, token string) error { ts.Lock() defer ts.Unlock() @@ -78,7 +78,7 @@ func (ts *file) DeleteToken() error { return ts.hds.DeleteFileFromUserHomeDir(ts.tokenFileName) } -//IsTokenPresent ... +// IsTokenPresent ... func (ts *file) IsTokenPresent() (bool, error) { ts.Lock() defer ts.Unlock()