-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrecord.go
More file actions
42 lines (38 loc) · 1.35 KB
/
record.go
File metadata and controls
42 lines (38 loc) · 1.35 KB
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
package deploymentrecord
// Status constants for deployment records.
const (
StatusDeployed = "deployed"
StatusDecommissioned = "decommissioned"
)
// DeploymentRecord represents a deployment event record.
type DeploymentRecord struct {
Name string `json:"name"`
Digest string `json:"digest"`
Version string `json:"version"`
LogicalEnvironment string `json:"logical_environment"`
PhysicalEnvironment string `json:"physical_environment"`
Cluster string `json:"cluster"`
Status string `json:"status"`
DeploymentName string `json:"deployment_name"`
}
// NewDeploymentRecord creates a new DeploymentRecord with the given status.
// Status must be either StatusDeployed or StatusDecommissioned.
//
//nolint:revive
func NewDeploymentRecord(name, digest, version, logicalEnv, physicalEnv,
cluster, status, deploymentName string) *DeploymentRecord {
// Validate status
if status != StatusDeployed && status != StatusDecommissioned {
status = StatusDeployed // default to deployed if invalid
}
return &DeploymentRecord{
Name: name,
Digest: digest,
Version: version,
LogicalEnvironment: logicalEnv,
PhysicalEnvironment: physicalEnv,
Cluster: cluster,
Status: status,
DeploymentName: deploymentName,
}
}