Skip to content

Commit ae66401

Browse files
authored
cli: add multiple modes (interactive, text, json) (#378)
* session: add Mode and helpers to interact * add-pkg: cmd/akash/deployment * select the key as default signer when a single key is present locally
1 parent 06d7998 commit ae66401

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2248
-669
lines changed

_integration/cmp/account.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
)
1010

1111
func accountBalance(key key, amount int64) gestalt.Component {
12-
parse := js.Do(js.Int(amount, "balance"))
12+
parse := js.Do(js.Int(amount, "result", "[0]", "balance"))
1313

1414
return akash("account-balance",
15-
"query", "account", key.addr.Var()).
15+
"query", "account", "-m", "json", key.addr.Var()).
1616
FN(parse).
1717
WithMeta(g.Require(key.addr.Name()))
1818
}

_integration/cmp/key.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,16 @@ import (
44
"github.com/ovrclk/gestalt"
55
g "github.com/ovrclk/gestalt/builder"
66
gx "github.com/ovrclk/gestalt/exec"
7+
"github.com/ovrclk/gestalt/exec/js"
78
"github.com/ovrclk/gestalt/vars"
89
)
910

10-
func keyCreate(root vars.Ref, key key) gestalt.Component {
11-
return akash_(root, "key-create", "key", "create", key.name.Name()).
12-
FN(gx.Capture(key.addr.Name())).
13-
WithMeta(g.Export(key.addr.Name()))
14-
}
15-
1611
func keyList(root vars.Ref, key key) gestalt.Component {
17-
1812
parse := gx.ParseColumns("name", "address").
1913
GrepField("name", key.name.Name()).
2014
GrepField("address", key.addr.Var()).
2115
EnsureCount(1).
2216
Done()
23-
2417
return akash_(root, "key-list", "key", "list").
2518
FN(parse).
2619
WithMeta(g.Require(key.addr.Name()))
@@ -36,3 +29,11 @@ func groupKey_(root vars.Ref, key key) gestalt.Component {
3629
Run(keyList(root, key)).
3730
WithMeta(g.Export(key.addr.Name()))
3831
}
32+
33+
func keyCreate(root vars.Ref, key key) gestalt.Component {
34+
return akash_(root, "key-create", "key", "create", "-m", "json", key.name.Name()).
35+
FN(js.Do(
36+
js.Str(key.name.Name(), "result", "[0]", "name"),
37+
js.Any("result", "[0]", "public_key_address").Export(key.addr.Name()),
38+
)).WithMeta(g.Export(key.addr.Name()))
39+
}

_run/multi/akash-provider/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ spec:
2828
env:
2929
- name: AKASH_DATA
3030
value: /data
31+
- name: AKASH_DEPLOYMENT_SERVICE_TYPE
32+
value: ClusterIP
33+
- name: AKASH_DEPLOYMENT_INGRESS_STATIC_HOSTS
34+
value: "false"
3135
ports:
3236
- containerPort: {{ .Values.provider.port }}
3337
name: http

_run/multi/dep-global.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
version: "1.0"
3+
4+
services:
5+
web:
6+
image: quay.io/ovrclk/demo-app
7+
expose:
8+
- port: 80
9+
as: 80
10+
accept:
11+
- hello.192.168.99.100.nip.io
12+
- hello.192.168.99.101.nip.io
13+
to:
14+
- global: true
15+
16+
profiles:
17+
compute:
18+
web:
19+
cpu: "0.25"
20+
memory: "128Mi"
21+
disk: "1Gi"
22+
placement:
23+
global:
24+
pricing:
25+
web: 1000u
26+
27+
deployment:
28+
web:
29+
global:
30+
profile: web
31+
count: 2

_run/multi/dep-test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
version: "1.0"
3+
4+
services:
5+
web:
6+
image: quay.io/ovrclk/demo-app
7+
expose:
8+
- port: 80
9+
as: 80
10+
accept:
11+
- hello.192.168.99.100.nip.io
12+
- hello.192.168.99.101.nip.io
13+
to:
14+
- global: true
15+
16+
profiles:
17+
compute:
18+
web:
19+
cpu: "0.25"
20+
memory: "128Mi"
21+
disk: "1Gi"
22+
placement:
23+
westcoast:
24+
attributes:
25+
region: us-west
26+
pricing:
27+
web: 100u
28+
eastcoast:
29+
attributes:
30+
region: us-east
31+
pricing:
32+
web: 100u
33+
34+
deployment:
35+
web:
36+
westcoast:
37+
profile: web
38+
count: 1
39+
eastcoast:
40+
profile: web
41+
count: 1

_run/multi/deployment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
accept:
1111
- hello.192.168.99.100.nip.io
1212
- hello.192.168.99.101.nip.io
13+
- hello.192.168.99.127.nip.io
1314
to:
1415
- global: true
1516

_run/multi/run.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ do_init(){
88
mkdir -p "$AKASH_DIR"
99
mkdir -p "$AKASHD_DIR"
1010

11-
_akash key create master | grep "Public Key" | awk '{print $3}' > "$DATA_ROOT/master.key"
12-
_akash key create other | grep "Public Key" | awk '{print $3}' > "$DATA_ROOT/other.key"
13-
11+
eval $(akash key create master -m shell)
12+
echo $akash_create_key_0_public_key > "$DATA_ROOT/master.key"
13+
eval $(akash key create other -m shell)
14+
echo $akash_create_key_0_public_key > "$DATA_ROOT/other.key"
1415
_akashd init "$(cat "$DATA_ROOT/master.key")" -t helm -c "${HELM_NODE_COUNT:-4}"
1516
}
1617

@@ -31,8 +32,14 @@ case "$1" in
3132
deploy)
3233
akash deployment create deployment.yml -k master
3334
;;
35+
minikube-start)
36+
minikube start --cpus 4 --memory 4096 --kubernetes-version v1.12.2
37+
minikube addons enable ingress
38+
minikube addons enable metrics-server
39+
kubectl create -f rbac.yml
40+
;;
3441
*)
35-
echo "USAGE: $0 <init|send|query|marketplace|deploy>" >&2
42+
echo "USAGE: $0 <init|send|query|marketplace|deploy|minikube-start>" >&2
3643
exit 1
3744
;;
3845
esac

_run/single/run.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ do_init() {
88
mkdir -p "$AKASH_DIR"
99
mkdir -p "$AKASHD_DIR"
1010

11-
akash key create master | grep "Public Key" | awk '{print $3}' > "$DATA_ROOT/master.key"
12-
akash key create other | grep "Public Key" | awk '{print $3}' > "$DATA_ROOT/other.key"
11+
eval $(akash key create master -m text); echo $PUBLIC_KEY_ADDRESS > "$DATA_ROOT/master.key"
12+
eval $(akash key create other -m text); echo $PUBLIC_KEY_ADDRESS > "$DATA_ROOT/other.key"
1313
akashd init "$(cat "$DATA_ROOT/master.key")"
14-
15-
akash_provider key create master | grep "Public Key" | awk '{print $3}' > "$DATA_ROOT/provider-master.key"
14+
eval $(akash_provider key create master -m text); echo $PUBLIC_KEY_ADDRESS > "$DATA_ROOT/provider-master.key"
1615
}
1716

1817
case "$1" in

cmd/akash/base.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ import (
77

88
func baseCommand() *cobra.Command {
99
cmd := &cobra.Command{
10-
Use: "akash",
11-
Short: "Akash client",
12-
SilenceUsage: true,
10+
Use: "akash",
11+
Short: "Akash CLI Utility",
12+
Long: baseLongDesc,
13+
SilenceUsage: true,
14+
SilenceErrors: false,
1315
}
1416
session.SetupBaseCommand(cmd)
1517
return cmd
1618
}
19+
20+
var baseLongDesc = `Akash CLI Utility.
21+
22+
Akash is a peer-to-peer marketplace for computing resources and
23+
a deployment platform for heavily distributed applications.
24+
Find out more at https://akash.network`

0 commit comments

Comments
 (0)