-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add ark-network/ark and gitignore volumes dir * mount both ark and arkd as volumes * Bump go; Add Docker mock client; test all combinations * go mod tidy * start: Show only running services * nigiri ark & nigiri arkd * Improve README with ark instructions * cleanup use only yaml pkg
- Loading branch information
Showing
19 changed files
with
878 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.DS_Store | ||
.env | ||
|
||
cmd/nigiri/resources/volumes/ | ||
vendor/ | ||
build/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
var ark = cli.Command{ | ||
Name: "ark", | ||
Usage: "invoke ark client commands", | ||
Action: arkAction, | ||
Flags: []cli.Flag{ | ||
&cli.BoolFlag{ | ||
Name: "version", | ||
Aliases: []string{"v"}, | ||
Usage: "print version", | ||
}, | ||
}, | ||
} | ||
|
||
var arkd = cli.Command{ | ||
Name: "arkd", | ||
Usage: "invoke arkd client commands", | ||
Action: arkdAction, | ||
Flags: []cli.Flag{ | ||
&cli.BoolFlag{ | ||
Name: "version", | ||
Aliases: []string{"v"}, | ||
Usage: "print version", | ||
}, | ||
}, | ||
} | ||
|
||
func arkAction(ctx *cli.Context) error { | ||
if ctx.Bool("version") { | ||
return runArkCommand(ctx, "ark", "--version") | ||
} | ||
return runArkCommand(ctx, "ark", ctx.Args().Slice()...) | ||
} | ||
|
||
func arkdAction(ctx *cli.Context) error { | ||
if ctx.Bool("version") { | ||
return runArkCommand(ctx, "arkd", "--version") | ||
} | ||
args := ctx.Args().Slice() | ||
// Add default flags | ||
args = append([]string{"--no-macaroon"}, args...) | ||
return runArkCommand(ctx, "arkd", args...) | ||
} | ||
|
||
func runArkCommand(ctx *cli.Context, binary string, args ...string) error { | ||
if isRunning, _ := nigiriState.GetBool("running"); !isRunning { | ||
return errors.New("nigiri is not running") | ||
} | ||
|
||
isArkEnabled, _ := nigiriState.GetBool("ark") | ||
if !isArkEnabled { | ||
return errors.New("ark is not enabled. Start nigiri with --ark flag") | ||
} | ||
|
||
// Build the docker exec command | ||
cmd := []string{"exec", "ark", binary} | ||
|
||
// Pass through all arguments | ||
cmd = append(cmd, args...) | ||
|
||
// Run the command | ||
dockerCmd := exec.Command("docker", cmd...) | ||
dockerCmd.Stdout = os.Stdout | ||
dockerCmd.Stderr = os.Stderr | ||
|
||
if err := dockerCmd.Run(); err != nil { | ||
// The error is already printed to stderr | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.