forked from coreos/fleet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cat.go
38 lines (33 loc) · 747 Bytes
/
cat.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
package main
import (
"fmt"
"os"
)
var (
cmdCatUnit = &Command{
Name: "cat",
Summary: "Output the contents of a submitted unit",
Usage: "UNIT",
Description: `Outputs the unit file that is currently loaded in the cluster. Useful to verify
the correct version of a unit is running.`,
Run: runCatUnit,
}
)
func runCatUnit(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\n", name, err)
return 1
}
if j == nil {
fmt.Fprintf(os.Stderr, "Job %s not found.\n", name)
return 1
}
fmt.Print(j.Unit.String())
return
}