|
5 | 5 | "io/ioutil" |
6 | 6 | "os" |
7 | 7 | "path/filepath" |
| 8 | + |
| 9 | + "github.com/openshift/osde2e/pkg/config" |
8 | 10 | ) |
9 | 11 |
|
10 | 12 | const ( |
@@ -40,6 +42,58 @@ func init() { |
40 | 42 | Instance = &Metadata{} |
41 | 43 | } |
42 | 44 |
|
| 45 | +// Next are a bunch of setter functions that allow us |
| 46 | +// to track/trap changes to metadata and then flush |
| 47 | +// the changes to a file. |
| 48 | + |
| 49 | +// SetClusterID sets the cluster id |
| 50 | +func (m *Metadata) SetClusterID(id string) { |
| 51 | + m.ClusterID = id |
| 52 | + m.WriteToJSON(config.Instance.ReportDir) |
| 53 | +} |
| 54 | + |
| 55 | +// SetClusterName sets the cluster name |
| 56 | +func (m *Metadata) SetClusterName(name string) { |
| 57 | + m.ClusterName = name |
| 58 | + m.WriteToJSON(config.Instance.ReportDir) |
| 59 | +} |
| 60 | + |
| 61 | +// SetClusterVersion sets the cluster version |
| 62 | +func (m *Metadata) SetClusterVersion(version string) { |
| 63 | + m.ClusterVersion = version |
| 64 | + m.WriteToJSON(config.Instance.ReportDir) |
| 65 | +} |
| 66 | + |
| 67 | +// SetEnvironment sets the cluster environment |
| 68 | +func (m *Metadata) SetEnvironment(env string) { |
| 69 | + m.Environment = env |
| 70 | + m.WriteToJSON(config.Instance.ReportDir) |
| 71 | +} |
| 72 | + |
| 73 | +// SetUpgradeVersion sets the cluster upgrade version |
| 74 | +func (m *Metadata) SetUpgradeVersion(ver string) { |
| 75 | + m.UpgradeVersion = ver |
| 76 | + m.WriteToJSON(config.Instance.ReportDir) |
| 77 | +} |
| 78 | + |
| 79 | +// SetUpgradeVersionSource sets the cluster upgrade version source |
| 80 | +func (m *Metadata) SetUpgradeVersionSource(src string) { |
| 81 | + m.UpgradeVersionSource = src |
| 82 | + m.WriteToJSON(config.Instance.ReportDir) |
| 83 | +} |
| 84 | + |
| 85 | +// SetTimeToOCMReportingInstalled sets the time it took for OCM to report a cluster provisioned |
| 86 | +func (m *Metadata) SetTimeToOCMReportingInstalled(timeToOCMReportingInstalled float64) { |
| 87 | + m.TimeToOCMReportingInstalled = timeToOCMReportingInstalled |
| 88 | + m.WriteToJSON(config.Instance.ReportDir) |
| 89 | +} |
| 90 | + |
| 91 | +// SetTimeToClusterReady sets the time it took for OCM to report a cluster ready |
| 92 | +func (m *Metadata) SetTimeToClusterReady(timeToClusterReady float64) { |
| 93 | + m.TimeToClusterReady = timeToClusterReady |
| 94 | + m.WriteToJSON(config.Instance.ReportDir) |
| 95 | +} |
| 96 | + |
43 | 97 | // WriteToJSON will marshall the metadata struct and write it into the given file. |
44 | 98 | func (m *Metadata) WriteToJSON(reportDir string) (err error) { |
45 | 99 | var data []byte |
|
0 commit comments