forked from juju/juju
/
formatted.go
76 lines (66 loc) · 3.36 KB
/
formatted.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package cmd
import "time"
// FormattedCharmResource holds the formatted representation of a resource's info.
type FormattedCharmResource struct {
// These fields are exported for the sake of serialization.
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Path string `json:"path" yaml:"path"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Revision int `json:"revision,omitempty" yaml:"revision,omitempty"`
Fingerprint string `json:"fingerprint" yaml:"fingerprint"`
Size int64 `json:"size" yaml:"size"`
Origin string `json:"origin" yaml:"origin"`
}
// FormattedServiceInfo holds the formatted representation of the information
// about an application's resources.
type FormattedServiceInfo struct {
Resources []FormattedSvcResource `json:"resources,omitempty" yaml:"resources,omitempty"`
Updates []FormattedCharmResource `json:"updates,omitempty" yaml:"updates,omitempty"`
}
// FormattedSvcResource holds the formatted representation of a resource's info.
type FormattedSvcResource struct {
// These fields are exported for the sake of serialization.
ID string `json:"resourceid,omitempty" yaml:"resourceid,omitempty"`
ApplicationID string `json:"applicationId,omitempty" yaml:"applicationId,omitempty"`
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Path string `json:"path" yaml:"path"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Revision int `json:"revision,omitempty" yaml:"revision,omitempty"`
Fingerprint string `json:"fingerprint" yaml:"fingerprint"`
Size int64 `json:"size" yaml:"size"`
Origin string `json:"origin" yaml:"origin"`
Used bool `json:"used" yaml:"used"`
Timestamp time.Time `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`
Username string `json:"username,omitempty" yaml:"username,omitempty"`
// These fields are not exported so they won't be serialized, since they are
// specific to the tabular output.
combinedRevision string
usedYesNo string
combinedOrigin string
}
// FormattedUnitResource holds the formatted representation of a resource's info.
type FormattedUnitResource FormattedSvcResource
// FormattedDetailResource is the data for a single line of tabular output for
// juju resources <application> --details.
type FormattedDetailResource struct {
UnitID string `json:"unitID" yaml:"unitID"`
Unit FormattedSvcResource `json:"unit" yaml:"unit"`
Expected FormattedSvcResource `json:"expected" yaml:"expected"`
Progress int64 `json:"progress,omitempty" yaml:"progress,omitempty"`
unitNumber int
progress string
revProgress string
}
// FormattedServiceDetails is the data for the tabular output for juju resources
// <application> --details.
type FormattedServiceDetails struct {
Resources []FormattedDetailResource `json:"resources,omitempty" yaml:"resources,omitempty"`
Updates []FormattedCharmResource `json:"updates,omitempty" yaml:"updates,omitempty"`
}
// FormattedDetailResource is the data for the tabular output for juju resources
// <unit> --details.
type FormattedUnitDetails []FormattedDetailResource