forked from coreos/fleet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.go
43 lines (36 loc) · 864 Bytes
/
verify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"os"
)
var cmdVerifyUnit = &Command{
Name: "verify",
Summary: "Verify unit file signatures using local SSH identities",
Usage: "UNIT",
Description: `Outputs whether or not unit file fits its signature. Useful to secure
the data of a unit.`,
Run: runVerifyUnit,
}
func runVerifyUnit(args []string) (exit int) {
if len(args) != 1 {
fmt.Fprintln(os.Stderr, "One unit file must be provided.")
return 1
}
name := unitNameMangle(args[0])
j, err := cAPI.Job(name)
if err != nil {
fmt.Fprintf(os.Stderr, "Error retrieving Job %s: %v", name, err)
return 1
}
if j == nil {
fmt.Fprintf(os.Stderr, "Job %s not found.\n", name)
return 1
}
err = verifyJob(j)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return 1
}
fmt.Printf("Succeeded verifying unit signature for Job %s.\n", j.Name)
return
}