From 8f995f3b1e1f16e41f5944821659412263015b91 Mon Sep 17 00:00:00 2001 From: vaikas-google Date: Tue, 17 Nov 2015 16:25:44 -0800 Subject: [PATCH 1/2] introduce state of a resource to Resource in types. In prep for issues: 79, 80 --- manager/manager/types.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/manager/manager/types.go b/manager/manager/types.go index 90ca61988..07041f03f 100644 --- a/manager/manager/types.go +++ b/manager/manager/types.go @@ -84,7 +84,7 @@ func NewDeployment(name string, id int) *Deployment { // DeploymentStatus is an enumeration type for the status of a deployment. type DeploymentStatus string -// These constants implement the deploymentStatus enumeration type. +// These constants implement the DeploymentStatus enumeration type. const ( CreatedStatus DeploymentStatus = "Created" DeletedStatus DeploymentStatus = "Deleted" @@ -140,6 +140,23 @@ type Configuration struct { Resources []*Resource `json:"resources"` } +// ResourceStatus is an enumeration type for the status of a resource. +type ResourceStatus string + +// These constants implement the resourceStatus enumeration type. +const ( + Created ResourceStatus = "Created" + Failed ResourceStatus = "Failed" + Aborted ResourceStatus = "Aborted" +) + +// ResourceState describes the state of a resource. +type ResourceState struct { + Status ResourceStatus `json:"status"` + SelfLink string `json:"selflink,omitempty"` + Errors []string `json:"errors,omitempty"` +} + // Resource describes a resource in a configuration. A resource has // a name, a type and a set of properties. The name and type are used // to identify the resource in Kubernetes. The properties are passed @@ -148,6 +165,7 @@ type Resource struct { Name string `json:"name"` Type string `json:"type"` Properties map[string]interface{} `json:"properties,omitempty"` + State ResourceState `json:"state"` } // TypeInstance defines the metadata for an instantiation of a template type From 72898b7003e90d6cdc19fb0c143f95cc806b3775 Mon Sep 17 00:00:00 2001 From: vaikas-google Date: Tue, 17 Nov 2015 18:52:50 -0800 Subject: [PATCH 2/2] address codereview comment. make Status omitempty --- manager/manager/types.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manager/manager/types.go b/manager/manager/types.go index 07041f03f..5541fcde4 100644 --- a/manager/manager/types.go +++ b/manager/manager/types.go @@ -151,8 +151,9 @@ const ( ) // ResourceState describes the state of a resource. +// Status is set during resource creation and is a terminal state. type ResourceState struct { - Status ResourceStatus `json:"status"` + Status ResourceStatus `json:"status,omitempty"` SelfLink string `json:"selflink,omitempty"` Errors []string `json:"errors,omitempty"` }