Skip to content

Commit

Permalink
resolve some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tok-kkk committed Nov 14, 2021
1 parent 067a2c5 commit 6bbf625
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,7 @@ or a script file
```sh
darknode exec YOUR-DARKNODE-NAME --file test.sh
```

### Github rate limiting

You can set the `GITHUB_TOKEN` environment variable to increase your github rate limit.
4 changes: 2 additions & 2 deletions cmd/down.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (s status) err() string {
func destroyNode(ctx *cli.Context) error {
force := ctx.Bool("force")
name := ctx.Args().First()
if err := util.NodeExistence(name); err != nil {
if err := util.ValidateNodeExistence(name); err != nil {
return err
}
path := util.NodePath(name)
Expand Down Expand Up @@ -103,7 +103,7 @@ func withdraw(ctx *cli.Context) error {

// Parse the input parameters
name := ctx.Args().First()
if err := util.NodeExistence(name); err != nil {
if err := util.ValidateNodeExistence(name); err != nil {
return err
}
withdrawAddress := ctx.String("address")
Expand Down
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func main() {
Usage: "SSH into one of your Darknode",
Action: func(c *cli.Context) error {
name := c.Args().First()
if err := util.NodeExistence(name); err != nil {
if err := util.ValidateNodeExistence(name); err != nil {
return err
}
ip, err := util.IP(name)
Expand Down Expand Up @@ -151,7 +151,7 @@ func main() {
Flags: []cli.Flag{},
Action: func(c *cli.Context) error {
name := c.Args().First()
if err := util.NodeExistence(name); err != nil {
if err := util.ValidateNodeExistence(name); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func validateCommonParams(ctx *cli.Context) error {
if err := util.ValidateName(name); err != nil {
return err
}
if err := util.NodeExistence(name); err == nil {
if err := util.ValidateNodeExistence(name); err == nil {
return fmt.Errorf("node [%v] already exist", name)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (

func resize(ctx *cli.Context) error {
name := ctx.Args().Get(0)
if err := util.NodeExistence(name); err != nil {
if err := util.ValidateNodeExistence(name); err != nil {
return err
}
newSize := ctx.Args().Get(1)
Expand Down
6 changes: 3 additions & 3 deletions util/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func ParseNodesFromNameAndTags(name, tags string) ([]string, error) {
} else if name == "" && tags != "" {
return GetNodesByTags(tags)
} else if name != "" && tags == "" {
return []string{name}, NodeExistence(name)
return []string{name}, ValidateNodeExistence(name)
} else {
return nil, ErrTooManyArguments
}
Expand All @@ -59,8 +59,8 @@ func ValidateName(name string) error {
return nil
}

// NodeExistence checks if there exists a node with given name.
func NodeExistence(name string) error {
// ValidateNodeExistence checks if there exists a node with given name.
func ValidateNodeExistence(name string) error {
path := filepath.Join(Directory, "darknodes", name)
_, err := os.Stat(path)
return err
Expand Down

0 comments on commit 6bbf625

Please sign in to comment.