Skip to content

Commit

Permalink
refactoring(rpc): remove authEnvKey (celestiaorg#2810)
Browse files Browse the repository at this point in the history
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

- [ ] New and updated code has appropriate documentation
- [ ] New and updated code has new and/or updated testing
- [ ] Required CI checks are passing
- [ ] Visual proof for any user facing features like CLI or
documentation updates
- [ ] Linked issues closed with keywords
  • Loading branch information
vgonkivs committed Oct 5, 2023
1 parent 76ced90 commit 9ef7594
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions cmd/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"os"

"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
Expand All @@ -17,7 +16,6 @@ import (
const (
// defaultRPCAddress is a default address to dial to
defaultRPCAddress = "http://localhost:26658"
authEnvKey = "CELESTIA_NODE_AUTH_TOKEN" //nolint:gosec
)

var (
Expand All @@ -39,7 +37,7 @@ func RPCFlags() *flag.FlagSet {
&authTokenFlag,
"token",
"",
"Authorization token (if not provided, the "+authEnvKey+" environment variable will be used)",
"Authorization token",
)

storeFlag := NodeFlags().Lookup(nodeStoreFlag)
Expand All @@ -48,15 +46,12 @@ func RPCFlags() *flag.FlagSet {
}

func InitClient(cmd *cobra.Command, _ []string) error {
if authTokenFlag == "" {
authTokenFlag = os.Getenv(authEnvKey)
}

if authTokenFlag == "" {
storePath := ""
if cmd.Flag(nodeStoreFlag).Changed {
storePath = cmd.Flag(nodeStoreFlag).Value.String()
if !cmd.Flag(nodeStoreFlag).Changed {
return fmt.Errorf("cant get the access to the auth token: token/node-store flag was not specified")
}
storePath = cmd.Flag(nodeStoreFlag).Value.String()
token, err := getToken(storePath)
if err != nil {
return fmt.Errorf("cant get the access to the auth token: %v", err)
Expand Down

0 comments on commit 9ef7594

Please sign in to comment.