Skip to content

Commit 95b2b16

Browse files
committed
Updates to match with flintlock v0.1.0-alpha.6
1 parent e126404 commit 95b2b16

File tree

4 files changed

+45
-54
lines changed

4 files changed

+45
-54
lines changed

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
## Hammertime
22

3-
A very basic, very untested, very unrefactored, and (likely) very unmaintained
4-
CLI tool for interacting with [flintlock](https://github.com/weaveworks/flintlock) servers.
3+
A very basic CLI tool for interacting with [flintlock](https://github.com/weaveworks/flintlock) servers.
54

65
(Those of you who know your archaic gun mechanisms will understand the name and no doubt
76
find it hilarious.) (You are welcome.)
@@ -10,6 +9,15 @@ Why did I make this? Well we used to use another generic GRPC client, but we dis
109
that, for reasons I do not yet know, it [didn't like some of the enum values we returned](https://github.com/weaveworks/flintlock/issues/313#issuecomment-991015159).
1110
So here we are.
1211

12+
I have kept it around because it makes working with flintlock very straightforward.
13+
14+
### Versioning
15+
16+
Latest of hammertime is always aligned with latest of flintlock.
17+
Check the release notes for potential breakages.
18+
19+
TODO compatibility table
20+
1321
### Installation
1422

1523
1. Build from source:
@@ -28,25 +36,24 @@ Alias to `ht` if you like.
2836

2937
### Usage
3038

31-
4 commands, very few configuration options. Everything has defaults so you don't need
32-
to pass any flags at all if you don't want to. Each command simply spits out the response
39+
4 commands, very few configuration options. Each command simply spits out the response
3340
as JSON so you can pipe to `jq` or whatever as you like.
3441

3542
```bash
36-
# create 'mvm0' in 'ns0'
43+
# create 'mvm0' in 'ns0' (take note of the UID after creation)
3744
hammertime create
3845

39-
# get 'mvm0' in 'ns0'
40-
hammertime get
46+
# get
47+
hammertime get -i <UUID>
4148

4249
# get just the state of 'mvm0' in 'ns0' *see below
43-
hammertime get -s
50+
hammertime get -i <UUID> -s
4451

45-
# get all mvms in 'ns0'
52+
# get all mvms
4653
hammertime list
4754

48-
# delete 'mvm0' from 'ns0'
49-
hammertime delete
55+
# delete
56+
hammertime delete -i <UID>
5057
```
5158

5259
The name and namespace are configurable, as are the GRPC address and port.

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ go 1.17
44

55
require (
66
github.com/urfave/cli/v2 v2.3.0
7-
github.com/weaveworks/flintlock/api v0.0.0-20211208132553-00580350aa87
7+
github.com/weaveworks/flintlock/api v0.0.0-20220126104712-74e49997e1bf
8+
github.com/weaveworks/flintlock/client v0.0.0-20220110105514-c0ec7b5054ee
89
google.golang.org/grpc v1.42.0
910
google.golang.org/protobuf v1.27.1
11+
gopkg.in/yaml.v2 v2.4.0
1012
)
1113

1214
require (
@@ -15,10 +17,8 @@ require (
1517
github.com/grpc-ecosystem/grpc-gateway/v2 v2.6.0 // indirect
1618
github.com/russross/blackfriday/v2 v2.0.1 // indirect
1719
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
18-
github.com/weaveworks/flintlock/client v0.0.0-20220110105514-c0ec7b5054ee // indirect
1920
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
2021
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
2122
golang.org/x/text v0.3.5 // indirect
2223
google.golang.org/genproto v0.0.0-20211021150943-2b146023228c // indirect
23-
gopkg.in/yaml.v2 v2.4.0 // indirect
2424
)

go.sum

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
131131
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
132132
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
133133
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
134+
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
134135
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
135136
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
137+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
136138
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
137139
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
138140
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -151,8 +153,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
151153
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
152154
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
153155
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
154-
github.com/weaveworks/flintlock/api v0.0.0-20211208132553-00580350aa87 h1:F3PvXLznTPsWg6/DlJq1L14Tdfz43jvHZ3UtqMtRIZk=
155-
github.com/weaveworks/flintlock/api v0.0.0-20211208132553-00580350aa87/go.mod h1:RFgQ7RSa7zGNxxR+dS6NRDCQ/IAN23WCfXg4+L6fclI=
156+
github.com/weaveworks/flintlock/api v0.0.0-20220126104712-74e49997e1bf h1:U4uOomP3oci4tP9f8W2uxGlC2tSQKbLQZKNWXg+YcXQ=
157+
github.com/weaveworks/flintlock/api v0.0.0-20220126104712-74e49997e1bf/go.mod h1:RFgQ7RSa7zGNxxR+dS6NRDCQ/IAN23WCfXg4+L6fclI=
156158
github.com/weaveworks/flintlock/client v0.0.0-20220110105514-c0ec7b5054ee h1:qBmT4sop1gKsDe6oMfOopaoXsTnpnkh0C0wV52RVt6c=
157159
github.com/weaveworks/flintlock/client v0.0.0-20220110105514-c0ec7b5054ee/go.mod h1:1jiepUOR2kxAdoxXXyNQ0LnOeT2gOUSnWGuXh9akjDw=
158160
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -425,6 +427,7 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
425427
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
426428
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
427429
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
430+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
428431
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
429432
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
430433
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

main.go

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func main() {
3131
dialTarget string
3232
port string
3333
mvmName string
34+
mvmUID string
3435
mvmNamespace string
3536
sshKeyPath string
3637
jsonSpec string
@@ -110,18 +111,10 @@ func main() {
110111
Usage: "get an existing microvm",
111112
Flags: []cli.Flag{
112113
&cli.StringFlag{
113-
Name: "name",
114-
Value: defaultMvmName,
115-
Aliases: []string{"n"},
116-
Usage: "microvm name",
117-
Destination: &mvmName,
118-
},
119-
&cli.StringFlag{
120-
Name: "namespace",
121-
Value: defaultMvmNamespace,
122-
Aliases: []string{"ns"},
123-
Usage: "microvm namespace",
124-
Destination: &mvmNamespace,
114+
Name: "id",
115+
Aliases: []string{"i"},
116+
Usage: "microvm uuid",
117+
Destination: &mvmUID,
125118
},
126119
&cli.BoolFlag{
127120
Name: "state",
@@ -144,8 +137,7 @@ func main() {
144137
if err != nil {
145138
return err
146139
}
147-
mvmName = spec.Id
148-
mvmNamespace = spec.Namespace
140+
mvmUID = *spec.Uid
149141
}
150142

151143
conn, err := grpc.Dial(fmt.Sprintf("%s:%s", dialTarget, port), grpc.WithInsecure(), grpc.WithBlock())
@@ -154,7 +146,7 @@ func main() {
154146
}
155147
defer conn.Close()
156148

157-
res, err := getMicrovm(v1alpha1.NewMicroVMClient(conn), mvmName, mvmNamespace)
149+
res, err := getMicrovm(v1alpha1.NewMicroVMClient(conn), mvmUID)
158150
if err != nil {
159151
return err
160152
}
@@ -200,18 +192,10 @@ func main() {
200192
Usage: "delete an existing microvm",
201193
Flags: []cli.Flag{
202194
&cli.StringFlag{
203-
Name: "name",
204-
Value: defaultMvmName,
205-
Aliases: []string{"n"},
206-
Usage: "microvm name",
207-
Destination: &mvmName,
208-
},
209-
&cli.StringFlag{
210-
Name: "namespace",
211-
Value: defaultMvmNamespace,
212-
Aliases: []string{"ns"},
213-
Usage: "microvm namespace",
214-
Destination: &mvmNamespace,
195+
Name: "id",
196+
Aliases: []string{"i"},
197+
Usage: "microvm uid",
198+
Destination: &mvmUID,
215199
},
216200
&cli.StringFlag{
217201
Name: "file",
@@ -227,8 +211,7 @@ func main() {
227211
if err != nil {
228212
return err
229213
}
230-
mvmName = spec.Id
231-
mvmNamespace = spec.Namespace
214+
mvmUID = *spec.Uid
232215
}
233216

234217
conn, err := grpc.Dial(fmt.Sprintf("%s:%s", dialTarget, port), grpc.WithInsecure(), grpc.WithBlock())
@@ -237,7 +220,7 @@ func main() {
237220
}
238221
defer conn.Close()
239222

240-
res, err := deleteMicroVM(v1alpha1.NewMicroVMClient(conn), mvmName, mvmNamespace)
223+
res, err := deleteMicroVM(v1alpha1.NewMicroVMClient(conn), mvmUID)
241224
if err != nil {
242225
return err
243226
}
@@ -293,10 +276,9 @@ func createMicrovm(client v1alpha1.MicroVMClient, name, ns, sshPath, jsonSpec st
293276
return resp, nil
294277
}
295278

296-
func getMicrovm(client v1alpha1.MicroVMClient, name, ns string) (*v1alpha1.GetMicroVMResponse, error) {
279+
func getMicrovm(client v1alpha1.MicroVMClient, uid string) (*v1alpha1.GetMicroVMResponse, error) {
297280
getReq := v1alpha1.GetMicroVMRequest{
298-
Id: name,
299-
Namespace: ns,
281+
Uid: uid,
300282
}
301283
resp, err := client.GetMicroVM(context.Background(), &getReq)
302284
if err != nil {
@@ -306,10 +288,9 @@ func getMicrovm(client v1alpha1.MicroVMClient, name, ns string) (*v1alpha1.GetMi
306288
return resp, nil
307289
}
308290

309-
func deleteMicroVM(client v1alpha1.MicroVMClient, name, ns string) (*emptypb.Empty, error) {
291+
func deleteMicroVM(client v1alpha1.MicroVMClient, uid string) (*emptypb.Empty, error) {
310292
delReq := v1alpha1.DeleteMicroVMRequest{
311-
Id: name,
312-
Namespace: ns,
293+
Uid: uid,
313294
}
314295
resp, err := client.DeleteMicroVM(context.Background(), &delReq)
315296
if err != nil {
@@ -366,8 +347,8 @@ func defaultMicroVM(name, namespace, sshPath string) (*types.MicroVMSpec, error)
366347
},
367348
Interfaces: []*types.NetworkInterface{
368349
{
369-
GuestDeviceName: "eth1",
370-
Type: 0,
350+
DeviceId: "eth1",
351+
Type: 0,
371352
},
372353
},
373354
Metadata: map[string]string{

0 commit comments

Comments
 (0)