diff --git a/src/app/backend/deploy.go b/src/app/backend/deploy.go index abb62760b0613691c931061b1dfa92be21f49d97..1eae9b95687fbc013cd51832b721f4faf1f2e1e5 100644 --- a/src/app/backend/deploy.go +++ b/src/app/backend/deploy.go @@ -22,7 +22,6 @@ import ( const ( DescriptionAnnotationKey = "description" - NameLabelKey = "name" ) // Specification for an app deployment. @@ -48,6 +47,9 @@ type AppDeploymentSpec struct { // Target namespace of the application. Namespace string `json:"namespace"` + + // Labels that will be defined on Pods/RCs/Services + Labels []Label `json:"labels"` } // Port mapping for an application deployment. @@ -62,13 +64,22 @@ type PortMapping struct { Protocol api.Protocol `json:"protocol"` } +// Structure representing label assignable to Pod/RC/Service +type Label struct { + // Label key + Key string `json:"key"` + + // Label value + Value string `json:"value"` +} + // Deploys an app based on the given configuration. The app is deployed using the given client. // App deployment consists of a replication controller and an optional service. Both of them share // common labels. // TODO(bryk): Write tests for this function. func DeployApp(spec *AppDeploymentSpec, client *client.Client) error { annotations := map[string]string{DescriptionAnnotationKey: spec.Description} - labels := map[string]string{NameLabelKey: spec.Name} + labels := getLabelsMap(spec.Labels) objectMeta := api.ObjectMeta{ Annotations: annotations, Name: spec.Name, @@ -137,3 +148,14 @@ func DeployApp(spec *AppDeploymentSpec, client *client.Client) error { return nil } } + +// Converts array of labels to map[string]string +func getLabelsMap(labels []Label) map[string]string { + result := make(map[string]string) + + for _, label := range labels { + result[label.Key] = label.Value + } + + return result +} diff --git a/src/app/externs/backendapi.js b/src/app/externs/backendapi.js index 7bdd90fc525e0743d7a0da6a6febb2b21d61f4d9..b2bd8ef33dababbddf78e0fa04d4525f7cdd26cd 100644 --- a/src/app/externs/backendapi.js +++ b/src/app/externs/backendapi.js @@ -41,7 +41,8 @@ backendApi.PortMapping; * description: string, * portMappings: !Array, * replicas: number, - * namespace: string + * namespace: string, + * labels: !Array * }} */ backendApi.AppDeploymentSpec; @@ -106,3 +107,11 @@ backendApi.NamespaceSpec; * }} */ backendApi.NamespaceList; + +/** + * @typedef {{ + * key: string, + * value: string + * }} + */ +backendApi.Label; diff --git a/src/app/frontend/.eslintrc b/src/app/frontend/.eslintrc index 02d6b040627caeef9f91cdcd031a0831dd7d9878..28869c4f3fce2f976c8edcb27d7e08936e7df7f2 100644 --- a/src/app/frontend/.eslintrc +++ b/src/app/frontend/.eslintrc @@ -10,5 +10,8 @@ "angular/module-getter": 0, // Disable undefined variable checking. This is done by the compiler. "no-undef": 0, + // To allow comparison to undefined variable, because Google Closure Compiler does not + // understand angular.isDefined correctly. + "angular/definedundefined": 0, } } diff --git a/src/app/frontend/deploy/deploy.html b/src/app/frontend/deploy/deploy.html index 06df4579a1fe03160fe75615bcf8f9a1a9327bda..0af64038e446f6dbe664f5c798ca1c5283012539 100644 --- a/src/app/frontend/deploy/deploy.html +++ b/src/app/frontend/deploy/deploy.html @@ -17,7 +17,7 @@ limitations under the License.