Changing the projectRequest struct to use description as a first-class field.
| ... | ... |
@@ -14,9 +14,7 @@ angular.module('openshiftConsole')
|
| 14 | 14 |
DataService.create('projectrequests', null, {
|
| 15 | 15 |
name: $scope.name, |
| 16 | 16 |
displayName: $scope.displayName, |
| 17 |
- annotations: {
|
|
| 18 |
- description: $scope.description |
|
| 19 |
- } |
|
| 17 |
+ description: $scope.description |
|
| 20 | 18 |
}, $scope).then(function(data) { // Success
|
| 21 | 19 |
Navigate.toProjectOverview(data.metadata.name); |
| 22 | 20 |
}, function(result) { // Failure
|
| ... | ... |
@@ -8,7 +8,9 @@ |
| 8 | 8 |
* Controller of the openshiftConsole |
| 9 | 9 |
*/ |
| 10 | 10 |
angular.module('openshiftConsole')
|
| 11 |
- .controller('NewFromTemplateController', function ($scope, $http, $routeParams, DataService, $q, $location, TaskList, $parse, Navigate, imageObjectRefFilter, failureObjectNameFilter) {
|
|
| 11 |
+ .controller('NewFromTemplateController', function ($scope, $http, $routeParams, DataService, $q, $location, TaskList, $parse, Navigate, $filter, imageObjectRefFilter, failureObjectNameFilter) {
|
|
| 12 |
+ var displayNameFilter = $filter('displayName');
|
|
| 13 |
+ |
|
| 12 | 14 |
|
| 13 | 15 |
function errorPage(message) {
|
| 14 | 16 |
var redirect = URI('error').query({
|
| ... | ... |
@@ -84,11 +86,11 @@ angular.module('openshiftConsole')
|
| 84 | 84 |
} |
| 85 | 85 |
|
| 86 | 86 |
$scope.projectDisplayName = function() {
|
| 87 |
- return (this.project && this.project.displayName) || this.projectName; |
|
| 87 |
+ return displayNameFilter(this.project) || this.projectName; |
|
| 88 | 88 |
}; |
| 89 | 89 |
|
| 90 | 90 |
$scope.templateDisplayName = function() {
|
| 91 |
- return (this.template.annotations && this.template.annotations.displayName) || this.template.metadata.name; |
|
| 91 |
+ return displayNameFilter(this.template); |
|
| 92 | 92 |
}; |
| 93 | 93 |
|
| 94 | 94 |
$scope.createFromTemplate = function() {
|
| ... | ... |
@@ -22,7 +22,9 @@ angular.module('openshiftConsole')
|
| 22 | 22 |
"pod": ["openshift.io/deployer-pod.name"], |
| 23 | 23 |
"deploymentStatus": ["openshift.io/deployment.phase"], |
| 24 | 24 |
"encodedDeploymentConfig": ["openshift.io/encoded-deployment-config"], |
| 25 |
- "deploymentVersion": ["openshift.io/deployment-config.latest-version"] |
|
| 25 |
+ "deploymentVersion": ["openshift.io/deployment-config.latest-version"], |
|
| 26 |
+ "displayName": ["openshift.io/display-name"], |
|
| 27 |
+ "description": ["openshift.io/description"] |
|
| 26 | 28 |
}; |
| 27 | 29 |
return function(resource, key) {
|
| 28 | 30 |
if (resource && resource.spec && resource.spec.tags && key.indexOf(".") !== -1){
|
| ... | ... |
@@ -35,7 +37,7 @@ angular.module('openshiftConsole')
|
| 35 | 35 |
if(tagName === tag.name && tag.annotations){
|
| 36 | 36 |
return tag.annotations[tagKey]; |
| 37 | 37 |
} |
| 38 |
- } |
|
| 38 |
+ } |
|
| 39 | 39 |
} |
| 40 | 40 |
if (resource && resource.metadata && resource.metadata.annotations) {
|
| 41 | 41 |
// If the key's already in the annotation map, return it. |
| ... | ... |
@@ -182,7 +184,8 @@ angular.module('openshiftConsole')
|
| 182 | 182 |
}) |
| 183 | 183 |
.filter('buildForImage', function() {
|
| 184 | 184 |
return function(image, builds) {
|
| 185 |
- // TODO concerned that this gets called anytime any data is changed on the scope, whether its relevant changes or not |
|
| 185 |
+ // TODO concerned that this gets called anytime any data is changed on the scope, |
|
| 186 |
+ // whether its relevant changes or not |
|
| 186 | 187 |
var envVars = image.dockerImageMetadata.Config.Env; |
| 187 | 188 |
for (var i = 0; i < envVars.length; i++) {
|
| 188 | 189 |
var keyValue = envVars[i].split("=");
|
| ... | ... |
@@ -206,7 +209,8 @@ angular.module('openshiftConsole')
|
| 206 | 206 |
}) |
| 207 | 207 |
.filter('isWebRoute', function(){
|
| 208 | 208 |
return function(route){
|
| 209 |
- //TODO: implement when we can tell if routes are http(s) or not web related which will drive links in view |
|
| 209 |
+ //TODO: implement when we can tell if routes are http(s) or not web related which will drive |
|
| 210 |
+ // links in view |
|
| 210 | 211 |
return true; |
| 211 | 212 |
}; |
| 212 | 213 |
}) |
| ... | ... |
@@ -47,7 +47,7 @@ |
| 47 | 47 |
<div class="form-group"> |
| 48 | 48 |
<label for="description">Description</label> |
| 49 | 49 |
<textarea class="form-control input-lg" |
| 50 |
- name="displayName" |
|
| 50 |
+ name="description" |
|
| 51 | 51 |
id="description" |
| 52 | 52 |
placeholder="A short description." |
| 53 | 53 |
ng-model="description"></textarea> |
| ... | ... |
@@ -8,8 +8,8 @@ |
| 8 | 8 |
"name": "hello-openshift-project" |
| 9 | 9 |
}, |
| 10 | 10 |
"annotations": {
|
| 11 |
- "description": "This is an example project to demonstrate OpenShift v3", |
|
| 12 |
- "displayName": "Hello OpenShift" |
|
| 11 |
+ "openshift.io/description": "This is an example project to demonstrate OpenShift v3", |
|
| 12 |
+ "openshift.io/display-name": "Hello OpenShift" |
|
| 13 | 13 |
} |
| 14 | 14 |
}, |
| 15 | 15 |
"spec": {},
|
| ... | ... |
@@ -8,8 +8,8 @@ |
| 8 | 8 |
"name": "hello-openshift-project" |
| 9 | 9 |
}, |
| 10 | 10 |
"annotations": {
|
| 11 |
- "description": "This is an example project to demonstrate OpenShift v3", |
|
| 12 |
- "displayName": "Hello OpenShift" |
|
| 11 |
+ "openshift.io/description": "This is an example project to demonstrate OpenShift v3", |
|
| 12 |
+ "openshift.io/display-name": "Hello OpenShift" |
|
| 13 | 13 |
} |
| 14 | 14 |
}, |
| 15 | 15 |
"spec": {},
|
| ... | ... |
@@ -21820,32 +21820,32 @@ angular.forEach(c, function(a) {
|
| 21820 | 21820 |
null !== a && (b.debug("Generated resource definition:", a), d.push(a));
|
| 21821 | 21821 |
}), l(d, a.projectName, a).then(m, n); |
| 21822 | 21822 |
}; |
| 21823 |
-} ]), angular.module("openshiftConsole").controller("NewFromTemplateController", [ "$scope", "$http", "$routeParams", "DataService", "$q", "$location", "TaskList", "$parse", "Navigate", "imageObjectRefFilter", "failureObjectNameFilter", function(a, b, c, d, e, f, g, h, i, j, k) {
|
|
| 21824 |
-function l(a) {
|
|
| 21825 |
-var b = [], c = o(a); |
|
| 21823 |
+} ]), angular.module("openshiftConsole").controller("NewFromTemplateController", [ "$scope", "$http", "$routeParams", "DataService", "$q", "$location", "TaskList", "$parse", "Navigate", "$filter", "imageObjectRefFilter", "failureObjectNameFilter", function(a, b, c, d, e, f, g, h, i, j, k, l) {
|
|
| 21824 |
+function m(a) {
|
|
| 21825 |
+var b = [], c = q(a); |
|
| 21826 | 21826 |
return c && angular.forEach(c, function(a) {
|
| 21827 | 21827 |
b.push(a.image); |
| 21828 | 21828 |
}), b; |
| 21829 | 21829 |
} |
| 21830 |
-function m(b) {
|
|
| 21830 |
+function n(b) {
|
|
| 21831 | 21831 |
var c = [], d = [], e = {};
|
| 21832 | 21832 |
return angular.forEach(b.objects, function(b) {
|
| 21833 | 21833 |
if ("BuildConfig" === b.kind) {
|
| 21834 |
-var f = j(p(b), a.projectName); |
|
| 21834 |
+var f = k(r(b), a.projectName); |
|
| 21835 | 21835 |
f && c.push({
|
| 21836 | 21836 |
name:f |
| 21837 | 21837 |
}); |
| 21838 |
-var g = j(q(b), a.projectName); |
|
| 21838 |
+var g = k(s(b), a.projectName); |
|
| 21839 | 21839 |
g && (e[g] = !0); |
| 21840 | 21840 |
} |
| 21841 |
-"DeploymentConfig" === b.kind && (d = d.concat(l(b))); |
|
| 21841 |
+"DeploymentConfig" === b.kind && (d = d.concat(m(b))); |
|
| 21842 | 21842 |
}), d.forEach(function(a) {
|
| 21843 | 21843 |
e[a] || c.push({
|
| 21844 | 21844 |
name:a |
| 21845 | 21845 |
}); |
| 21846 | 21846 |
}), c; |
| 21847 | 21847 |
} |
| 21848 |
-function n(a) {
|
|
| 21848 |
+function o(a) {
|
|
| 21849 | 21849 |
var b = /^helplink\.(.*)\.title$/, c = /^helplink\.(.*)\.url$/, d = {};
|
| 21850 | 21850 |
for (var e in a.annotations) {
|
| 21851 | 21851 |
var f, g = e.match(b); |
| ... | ... |
@@ -21853,24 +21853,24 @@ g ? (f = d[g[1]] || {}, f.title = a.annotations[e], d[g[1]] = f) :(g = e.match(c
|
| 21853 | 21853 |
} |
| 21854 | 21854 |
return d; |
| 21855 | 21855 |
} |
| 21856 |
-var o = h("spec.template.spec.containers"), p = h("spec.strategy.sourceStrategy.from"), q = h("spec.output.to");
|
|
| 21856 |
+var p = j("displayName"), q = h("spec.template.spec.containers"), r = h("spec.strategy.sourceStrategy.from"), s = h("spec.output.to");
|
|
| 21857 | 21857 |
a.projectDisplayName = function() {
|
| 21858 |
-return this.project && this.project.displayName || this.projectName; |
|
| 21858 |
+return p(this.project) || this.projectName; |
|
| 21859 | 21859 |
}, a.templateDisplayName = function() {
|
| 21860 |
-return this.template.annotations && this.template.annotations.displayName || this.template.metadata.name; |
|
| 21860 |
+return p(this.template); |
|
| 21861 | 21861 |
}, a.createFromTemplate = function() {
|
| 21862 | 21862 |
d.create("processedtemplates", null, a.template, a).then(function(b) {
|
| 21863 | 21863 |
var c = {
|
| 21864 | 21864 |
started:"Creating " + a.templateDisplayName() + " in project " + a.projectDisplayName(), |
| 21865 | 21865 |
success:"Created " + a.templateDisplayName() + " in project " + a.projectDisplayName(), |
| 21866 | 21866 |
failure:"Failed to create " + a.templateDisplayName() + " in project " + a.projectDisplayName() |
| 21867 |
-}, f = n(a.template); |
|
| 21867 |
+}, f = o(a.template); |
|
| 21868 | 21868 |
g.add(c, f, function() {
|
| 21869 | 21869 |
var c = e.defer(); |
| 21870 | 21870 |
return d.createList(b.objects, a).then(function(b) {
|
| 21871 | 21871 |
var d = [], e = !1; |
| 21872 | 21872 |
b.failure.length > 0 ? b.failure.forEach(function(a) {
|
| 21873 |
-var b = k(a) || "object"; |
|
| 21873 |
+var b = l(a) || "object"; |
|
| 21874 | 21874 |
d.push({
|
| 21875 | 21875 |
type:"error", |
| 21876 | 21876 |
message:"Cannot create " + b + ". ", |
| ... | ... |
@@ -21896,13 +21896,13 @@ details:c |
| 21896 | 21896 |
}, a.toggleOptionsExpanded = function() {
|
| 21897 | 21897 |
a.optionsExpanded = !a.optionsExpanded; |
| 21898 | 21898 |
}; |
| 21899 |
-var r = c.name, s = c.namespace; |
|
| 21900 |
-return r ? (a.emptyMessage = "Loading...", a.alerts = [], a.projectName = c.project, a.projectPromise = $.Deferred(), d.get("projects", a.projectName, a).then(function(b) {
|
|
| 21899 |
+var t = c.name, u = c.namespace; |
|
| 21900 |
+return t ? (a.emptyMessage = "Loading...", a.alerts = [], a.projectName = c.project, a.projectPromise = $.Deferred(), d.get("projects", a.projectName, a).then(function(b) {
|
|
| 21901 | 21901 |
a.project = b, a.projectPromise.resolve(b); |
| 21902 |
-}), void d.get("templates", r, a, {
|
|
| 21903 |
-namespace:s |
|
| 21902 |
+}), void d.get("templates", t, a, {
|
|
| 21903 |
+namespace:u |
|
| 21904 | 21904 |
}).then(function(b) {
|
| 21905 |
-a.template = b, a.templateImages = m(b), a.hasParameters = a.template.parameters && a.template.parameters.length > 0, a.optionsExpanded = !1, a.templateUrl = b.metadata.selfLink, b.labels = b.labels || {};
|
|
| 21905 |
+a.template = b, a.templateImages = n(b), a.hasParameters = a.template.parameters && a.template.parameters.length > 0, a.optionsExpanded = !1, a.templateUrl = b.metadata.selfLink, b.labels = b.labels || {};
|
|
| 21906 | 21906 |
}, function() {
|
| 21907 | 21907 |
i.toErrorPage("Cannot create from template: the specified template could not be retrieved.");
|
| 21908 | 21908 |
})) :void i.toErrorPage("Cannot create from template: a template name was not specified.");
|
| ... | ... |
@@ -22075,9 +22075,7 @@ a.createProject = function() {
|
| 22075 | 22075 |
a.createProjectForm.$valid && b.create("projectrequests", null, {
|
| 22076 | 22076 |
name:a.name, |
| 22077 | 22077 |
displayName:a.displayName, |
| 22078 |
-annotations:{
|
|
| 22079 | 22078 |
description:a.description |
| 22080 |
-} |
|
| 22081 | 22079 |
}, a).then(function(a) {
|
| 22082 | 22080 |
d.toProjectOverview(a.metadata.name); |
| 22083 | 22081 |
}, function(b) {
|
| ... | ... |
@@ -22671,7 +22669,9 @@ deployment:[ "openshift.io/deployment.name" ], |
| 22671 | 22671 |
pod:[ "openshift.io/deployer-pod.name" ], |
| 22672 | 22672 |
deploymentStatus:[ "openshift.io/deployment.phase" ], |
| 22673 | 22673 |
encodedDeploymentConfig:[ "openshift.io/encoded-deployment-config" ], |
| 22674 |
-deploymentVersion:[ "openshift.io/deployment-config.latest-version" ] |
|
| 22674 |
+deploymentVersion:[ "openshift.io/deployment-config.latest-version" ], |
|
| 22675 |
+displayName:[ "openshift.io/display-name" ], |
|
| 22676 |
+description:[ "openshift.io/description" ] |
|
| 22675 | 22677 |
}; |
| 22676 | 22678 |
return function(b, c) {
|
| 22677 | 22679 |
if (b && b.spec && b.spec.tags && -1 !== c.indexOf(".")) for (var d = c.split("."), e = b.spec.tags, f = 0; f < e.length; ++f) {
|
| ... | ... |
@@ -69912,7 +69912,7 @@ Project names may only contain lower-case letters, numbers, and dashes. They may |
| 69912 | 69912 |
</div> |
| 69913 | 69913 |
<div class="form-group"> |
| 69914 | 69914 |
<label for="description">Description</label> |
| 69915 |
-<textarea class="form-control input-lg" name="displayName" id="description" placeholder="A short description." ng-model="description"></textarea> |
|
| 69915 |
+<textarea class="form-control input-lg" name="description" id="description" placeholder="A short description." ng-model="description"></textarea> |
|
| 69916 | 69916 |
</div> |
| 69917 | 69917 |
<div class="button-group"> |
| 69918 | 69918 |
<button type="submit" class="btn btn-primary btn-lg" ng-click="createProject()" ng-disabled="createProjectForm.$invalid || nameTaken" value="">Create</button> |
| ... | ... |
@@ -96,10 +96,10 @@ func (o *NewProjectOptions) Run(useNodeSelector bool) error {
|
| 96 | 96 |
project := &projectapi.Project{}
|
| 97 | 97 |
project.Name = o.ProjectName |
| 98 | 98 |
project.Annotations = make(map[string]string) |
| 99 |
- project.Annotations["description"] = o.Description |
|
| 100 |
- project.Annotations["displayName"] = o.DisplayName |
|
| 99 |
+ project.Annotations[projectapi.ProjectDescription] = o.Description |
|
| 100 |
+ project.Annotations[projectapi.ProjectDisplayName] = o.DisplayName |
|
| 101 | 101 |
if useNodeSelector {
|
| 102 |
- project.Annotations[projectapi.ProjectNodeSelectorParam] = o.NodeSelector |
|
| 102 |
+ project.Annotations[projectapi.ProjectNodeSelector] = o.NodeSelector |
|
| 103 | 103 |
} |
| 104 | 104 |
project, err := o.Client.Projects().Create(project) |
| 105 | 105 |
if err != nil {
|
| ... | ... |
@@ -103,8 +103,8 @@ func (o *NewProjectOptions) Run() error {
|
| 103 | 103 |
projectRequest := &projectapi.ProjectRequest{}
|
| 104 | 104 |
projectRequest.Name = o.ProjectName |
| 105 | 105 |
projectRequest.DisplayName = o.DisplayName |
| 106 |
+ projectRequest.Description = o.Description |
|
| 106 | 107 |
projectRequest.Annotations = make(map[string]string) |
| 107 |
- projectRequest.Annotations["description"] = o.Description |
|
| 108 | 108 |
|
| 109 | 109 |
project, err := o.Client.ProjectRequests().Create(projectRequest) |
| 110 | 110 |
if err != nil {
|
| ... | ... |
@@ -553,15 +553,15 @@ func (d *ProjectDescriber) Describe(namespace, name string) (string, error) {
|
| 553 | 553 |
|
| 554 | 554 |
nodeSelector := "" |
| 555 | 555 |
if len(project.ObjectMeta.Annotations) > 0 {
|
| 556 |
- if ns, ok := project.ObjectMeta.Annotations[projectapi.ProjectNodeSelectorParam]; ok {
|
|
| 556 |
+ if ns, ok := project.ObjectMeta.Annotations[projectapi.ProjectNodeSelector]; ok {
|
|
| 557 | 557 |
nodeSelector = ns |
| 558 | 558 |
} |
| 559 | 559 |
} |
| 560 | 560 |
|
| 561 | 561 |
return tabbedString(func(out *tabwriter.Writer) error {
|
| 562 | 562 |
formatMeta(out, project.ObjectMeta) |
| 563 |
- formatString(out, "Display Name", project.Annotations["displayName"]) |
|
| 564 |
- formatString(out, "Description", project.Annotations["description"]) |
|
| 563 |
+ formatString(out, "Display Name", project.Annotations[projectapi.ProjectDisplayName]) |
|
| 564 |
+ formatString(out, "Description", project.Annotations[projectapi.ProjectDescription]) |
|
| 565 | 565 |
formatString(out, "Status", project.Status.Phase) |
| 566 | 566 |
formatString(out, "Node Selector", nodeSelector) |
| 567 | 567 |
fmt.Fprintf(out, "\n") |
| ... | ... |
@@ -302,7 +302,7 @@ func printImageStreamList(streams *imageapi.ImageStreamList, w io.Writer, withNa |
| 302 | 302 |
} |
| 303 | 303 |
|
| 304 | 304 |
func printProject(project *projectapi.Project, w io.Writer, withNamespace bool) error {
|
| 305 |
- _, err := fmt.Fprintf(w, "%s\t%s\t%s\n", project.Name, project.Annotations["displayName"], project.Status.Phase) |
|
| 305 |
+ _, err := fmt.Fprintf(w, "%s\t%s\t%s\n", project.Name, project.Annotations[projectapi.ProjectDisplayName], project.Status.Phase) |
|
| 306 | 306 |
return err |
| 307 | 307 |
} |
| 308 | 308 |
|
| ... | ... |
@@ -17,6 +17,7 @@ import ( |
| 17 | 17 |
"github.com/openshift/origin/pkg/client" |
| 18 | 18 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 19 | 19 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 20 |
+ projectapi "github.com/openshift/origin/pkg/project/api" |
|
| 20 | 21 |
) |
| 21 | 22 |
|
| 22 | 23 |
// ProjectStatusDescriber generates extended information about a Project |
| ... | ... |
@@ -75,8 +76,9 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error |
| 75 | 75 |
|
| 76 | 76 |
return tabbedString(func(out *tabwriter.Writer) error {
|
| 77 | 77 |
indent := " " |
| 78 |
- if len(project.Annotations["displayName"]) > 0 && project.Annotations["displayName"] != namespace {
|
|
| 79 |
- fmt.Fprintf(out, "In project %s (%s)\n", project.Annotations["displayName"], namespace) |
|
| 78 |
+ if len(project.Annotations[projectapi.ProjectDisplayName]) > 0 && |
|
| 79 |
+ project.Annotations[projectapi.ProjectDisplayName] != namespace {
|
|
| 80 |
+ fmt.Fprintf(out, "In project %s (%s)\n", project.Annotations[projectapi.ProjectDisplayName], namespace) |
|
| 80 | 81 |
} else {
|
| 81 | 82 |
fmt.Fprintf(out, "In project %s\n", namespace) |
| 82 | 83 |
} |
| ... | ... |
@@ -8,7 +8,6 @@ import ( |
| 8 | 8 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/cache" |
| 9 | 9 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient" |
| 10 | 10 |
|
| 11 |
- projectapi "github.com/openshift/origin/pkg/project/api" |
|
| 12 | 11 |
projectcache "github.com/openshift/origin/pkg/project/cache" |
| 13 | 12 |
"github.com/openshift/origin/pkg/util/labelselector" |
| 14 | 13 |
) |
| ... | ... |
@@ -107,7 +106,7 @@ func TestPodAdmission(t *testing.T) {
|
| 107 | 107 |
for _, test := range tests {
|
| 108 | 108 |
projectcache.FakeProjectCache(mockClient, projectStore, test.defaultNodeSelector) |
| 109 | 109 |
if !test.ignoreProjectNodeSelector {
|
| 110 |
- project.ObjectMeta.Annotations = map[string]string{projectapi.ProjectNodeSelectorParam: test.projectNodeSelector}
|
|
| 110 |
+ project.ObjectMeta.Annotations = map[string]string{"openshift.io/node-selector": test.projectNodeSelector}
|
|
| 111 | 111 |
} |
| 112 | 112 |
pod.Spec = kapi.PodSpec{NodeSelector: test.podNodeSelector}
|
| 113 | 113 |
|
| ... | ... |
@@ -14,8 +14,6 @@ type ProjectList struct {
|
| 14 | 14 |
const ( |
| 15 | 15 |
// These are internal finalizer values to Origin |
| 16 | 16 |
FinalizerOrigin kapi.FinalizerName = "openshift.io/origin" |
| 17 |
- |
|
| 18 |
- ProjectNodeSelectorParam string = "openshift.io/node-selector" |
|
| 19 | 17 |
) |
| 20 | 18 |
|
| 21 | 19 |
// ProjectSpec describes the attributes on a Project |
| ... | ... |
@@ -42,4 +40,16 @@ type ProjectRequest struct {
|
| 42 | 42 |
kapi.TypeMeta |
| 43 | 43 |
kapi.ObjectMeta |
| 44 | 44 |
DisplayName string |
| 45 |
+ Description string |
|
| 45 | 46 |
} |
| 47 |
+ |
|
| 48 |
+// These constants represent annotations keys affixed to projects |
|
| 49 |
+const ( |
|
| 50 |
+ // ProjectDisplayName is an annotation that stores the name displayed when querying for projects |
|
| 51 |
+ ProjectDisplayName = "openshift.io/display-name" |
|
| 52 |
+ // ProjectDescription is an annotatoion that holds the description of the project |
|
| 53 |
+ ProjectDescription = "openshift.io/description" |
|
| 54 |
+ // ProjectNodeSelector is an annotation that holds the node selector; |
|
| 55 |
+ // the node selector annotation determines which nodes will have pods from this project scheduled to them |
|
| 56 |
+ ProjectNodeSelector = "openshift.io/node-selector" |
|
| 57 |
+) |
| ... | ... |
@@ -14,8 +14,6 @@ type ProjectList struct {
|
| 14 | 14 |
const ( |
| 15 | 15 |
// These are internal finalizer values to Origin |
| 16 | 16 |
FinalizerOrigin kapi.FinalizerName = "openshift.io/origin" |
| 17 |
- |
|
| 18 |
- ProjectNodeSelectorParam string = "openshift.io/node-selector" |
|
| 19 | 17 |
) |
| 20 | 18 |
|
| 21 | 19 |
// ProjectSpec describes the attributes on a Project |
| ... | ... |
@@ -45,4 +43,5 @@ type ProjectRequest struct {
|
| 45 | 45 |
kapi.TypeMeta `json:",inline"` |
| 46 | 46 |
kapi.ObjectMeta `json:"metadata,omitempty"` |
| 47 | 47 |
DisplayName string `json:"displayName,omitempty" description:"display name to apply to a project"` |
| 48 |
+ Description string `json:"description,omitempty" description:"description to apply to a proejct"` |
|
| 48 | 49 |
} |
| ... | ... |
@@ -14,8 +14,6 @@ type ProjectList struct {
|
| 14 | 14 |
const ( |
| 15 | 15 |
// These are internal finalizer values to Origin |
| 16 | 16 |
FinalizerOrigin kapi.FinalizerName = "openshift.io/origin" |
| 17 |
- |
|
| 18 |
- ProjectNodeSelectorParam string = "openshift.io/node-selector" |
|
| 19 | 17 |
) |
| 20 | 18 |
|
| 21 | 19 |
// ProjectSpec describes the attributes on a Project |
| ... | ... |
@@ -46,4 +44,5 @@ type ProjectRequest struct {
|
| 46 | 46 |
kapi.TypeMeta `json:",inline"` |
| 47 | 47 |
kapi.ObjectMeta `json:"metadata,omitempty"` |
| 48 | 48 |
DisplayName string `json:"displayName,omitempty"` |
| 49 |
+ Description string `json:"description,omitempty"` |
|
| 49 | 50 |
} |
| ... | ... |
@@ -17,8 +17,8 @@ func TestProjectConversion(t *testing.T) {
|
| 17 | 17 |
ObjectMeta: kapi.ObjectMeta{
|
| 18 | 18 |
Name: "foo", |
| 19 | 19 |
Annotations: map[string]string{
|
| 20 |
- "description": "This is a description", |
|
| 21 |
- "displayName": "hi", |
|
| 20 |
+ "openshift.io/description": "This is a description", |
|
| 21 |
+ "openshift.io/display-name": "hi", |
|
| 22 | 22 |
}, |
| 23 | 23 |
}, |
| 24 | 24 |
} |
| ... | ... |
@@ -27,8 +27,8 @@ func TestProjectConversion(t *testing.T) {
|
| 27 | 27 |
ObjectMeta: v1beta3.ObjectMeta{
|
| 28 | 28 |
Name: "foo", |
| 29 | 29 |
Annotations: map[string]string{
|
| 30 |
- "description": "This is a description", |
|
| 31 |
- "displayName": "hi", |
|
| 30 |
+ "openshift.io/description": "This is a description", |
|
| 31 |
+ "openshift.io/display-name": "hi", |
|
| 32 | 32 |
}, |
| 33 | 33 |
}, |
| 34 | 34 |
} |
| ... | ... |
@@ -14,8 +14,6 @@ type ProjectList struct {
|
| 14 | 14 |
const ( |
| 15 | 15 |
// These are internal finalizer values to Origin |
| 16 | 16 |
FinalizerOrigin kapi.FinalizerName = "openshift.io/origin" |
| 17 |
- |
|
| 18 |
- ProjectNodeSelectorParam string = "openshift.io/node-selector" |
|
| 19 | 17 |
) |
| 20 | 18 |
|
| 21 | 19 |
// ProjectSpec describes the attributes on a Project |
| ... | ... |
@@ -45,4 +43,16 @@ type ProjectRequest struct {
|
| 45 | 45 |
kapi.TypeMeta `json:",inline"` |
| 46 | 46 |
kapi.ObjectMeta `json:"metadata,omitempty"` |
| 47 | 47 |
DisplayName string `json:"displayName,omitempty"` |
| 48 |
+ Description string `json:"description,omitempty"` |
|
| 48 | 49 |
} |
| 50 |
+ |
|
| 51 |
+// These constants represent annotations keys affixed to projects |
|
| 52 |
+const ( |
|
| 53 |
+ // ProjectDisplayName is an annotation that stores the name displayed when querying for projects |
|
| 54 |
+ ProjectDisplayName = "openshift.io/display-name" |
|
| 55 |
+ // ProjectDescription is an annotatoion that holds the description of the project |
|
| 56 |
+ ProjectDescription = "openshift.io/description" |
|
| 57 |
+ // ProjectNodeSelector is an annotation that holds the node selector; |
|
| 58 |
+ // the node selector annotation determines which nodes will have pods from this project scheduled to them |
|
| 59 |
+ ProjectNodeSelector = "openshift.io/node-selector" |
|
| 60 |
+) |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors" |
| 8 | 8 |
|
| 9 | 9 |
"github.com/openshift/origin/pkg/project/api" |
| 10 |
+ projectapi "github.com/openshift/origin/pkg/project/api" |
|
| 10 | 11 |
"github.com/openshift/origin/pkg/util/labelselector" |
| 11 | 12 |
) |
| 12 | 13 |
|
| ... | ... |
@@ -26,8 +27,9 @@ func ValidateProject(project *api.Project) fielderrors.ValidationErrorList {
|
| 26 | 26 |
if len(project.Namespace) > 0 {
|
| 27 | 27 |
result = append(result, fielderrors.NewFieldInvalid("namespace", project.Namespace, "must be the empty-string"))
|
| 28 | 28 |
} |
| 29 |
- if !validateNoNewLineOrTab(project.Annotations["displayName"]) {
|
|
| 30 |
- result = append(result, fielderrors.NewFieldInvalid("displayName", project.Annotations["displayName"], "may not contain a new line or tab"))
|
|
| 29 |
+ if !validateNoNewLineOrTab(project.Annotations[projectapi.ProjectDisplayName]) {
|
|
| 30 |
+ result = append(result, fielderrors.NewFieldInvalid(projectapi.ProjectDisplayName, |
|
| 31 |
+ project.Annotations[projectapi.ProjectDisplayName], "may not contain a new line or tab")) |
|
| 31 | 32 |
} |
| 32 | 33 |
result = append(result, validateNodeSelector(project)...) |
| 33 | 34 |
return result |
| ... | ... |
@@ -59,9 +61,10 @@ func validateNodeSelector(p *api.Project) fielderrors.ValidationErrorList {
|
| 59 | 59 |
allErrs := fielderrors.ValidationErrorList{}
|
| 60 | 60 |
|
| 61 | 61 |
if len(p.Annotations) > 0 {
|
| 62 |
- if selector, ok := p.Annotations[api.ProjectNodeSelectorParam]; ok {
|
|
| 62 |
+ if selector, ok := p.Annotations[projectapi.ProjectNodeSelector]; ok {
|
|
| 63 | 63 |
if _, err := labelselector.Parse(selector); err != nil {
|
| 64 |
- allErrs = append(allErrs, fielderrors.NewFieldInvalid("nodeSelector", p.Annotations[api.ProjectNodeSelectorParam], "must be a valid label selector"))
|
|
| 64 |
+ allErrs = append(allErrs, fielderrors.NewFieldInvalid("nodeSelector",
|
|
| 65 |
+ p.Annotations[projectapi.ProjectNodeSelector], "must be a valid label selector")) |
|
| 65 | 66 |
} |
| 66 | 67 |
} |
| 67 | 68 |
} |
| ... | ... |
@@ -18,8 +18,8 @@ func TestValidateProject(t *testing.T) {
|
| 18 | 18 |
project: api.Project{
|
| 19 | 19 |
ObjectMeta: kapi.ObjectMeta{
|
| 20 | 20 |
Annotations: map[string]string{
|
| 21 |
- "description": "This is a description", |
|
| 22 |
- "displayName": "hi", |
|
| 21 |
+ "openshift.io/description": "This is a description", |
|
| 22 |
+ "openshift.io/display-name": "hi", |
|
| 23 | 23 |
}, |
| 24 | 24 |
}, |
| 25 | 25 |
}, |
| ... | ... |
@@ -32,8 +32,8 @@ func TestValidateProject(t *testing.T) {
|
| 32 | 32 |
ObjectMeta: kapi.ObjectMeta{
|
| 33 | 33 |
Name: "141-.124.$", |
| 34 | 34 |
Annotations: map[string]string{
|
| 35 |
- "description": "This is a description", |
|
| 36 |
- "displayName": "hi", |
|
| 35 |
+ "openshift.io/description": "This is a description", |
|
| 36 |
+ "openshift.io/display-name": "hi", |
|
| 37 | 37 |
}, |
| 38 | 38 |
}, |
| 39 | 39 |
}, |
| ... | ... |
@@ -92,8 +92,8 @@ func TestValidateProject(t *testing.T) {
|
| 92 | 92 |
Name: "foo", |
| 93 | 93 |
Namespace: "foo", |
| 94 | 94 |
Annotations: map[string]string{
|
| 95 |
- "description": "This is a description", |
|
| 96 |
- "displayName": "hi", |
|
| 95 |
+ "openshift.io/description": "This is a description", |
|
| 96 |
+ "openshift.io/display-name": "hi", |
|
| 97 | 97 |
}, |
| 98 | 98 |
}, |
| 99 | 99 |
}, |
| ... | ... |
@@ -107,8 +107,8 @@ func TestValidateProject(t *testing.T) {
|
| 107 | 107 |
Name: "foo", |
| 108 | 108 |
Namespace: "", |
| 109 | 109 |
Annotations: map[string]string{
|
| 110 |
- "description": "This is a description", |
|
| 111 |
- "displayName": "h\t\ni", |
|
| 110 |
+ "openshift.io/description": "This is a description", |
|
| 111 |
+ "openshift.io/display-name": "h\t\ni", |
|
| 112 | 112 |
}, |
| 113 | 113 |
}, |
| 114 | 114 |
}, |
| ... | ... |
@@ -122,7 +122,7 @@ func TestValidateProject(t *testing.T) {
|
| 122 | 122 |
Name: "foo", |
| 123 | 123 |
Namespace: "", |
| 124 | 124 |
Annotations: map[string]string{
|
| 125 |
- api.ProjectNodeSelectorParam: "infra=true, env = test", |
|
| 125 |
+ "openshift.io/node-selector": "infra=true, env = test", |
|
| 126 | 126 |
}, |
| 127 | 127 |
}, |
| 128 | 128 |
}, |
| ... | ... |
@@ -135,7 +135,7 @@ func TestValidateProject(t *testing.T) {
|
| 135 | 135 |
Name: "foo", |
| 136 | 136 |
Namespace: "", |
| 137 | 137 |
Annotations: map[string]string{
|
| 138 |
- api.ProjectNodeSelectorParam: "infra, env = $test", |
|
| 138 |
+ "openshift.io/node-selector": "infra, env = $test", |
|
| 139 | 139 |
}, |
| 140 | 140 |
}, |
| 141 | 141 |
}, |
| ... | ... |
@@ -155,8 +155,8 @@ func TestValidateProject(t *testing.T) {
|
| 155 | 155 |
ObjectMeta: kapi.ObjectMeta{
|
| 156 | 156 |
Name: "foo", |
| 157 | 157 |
Annotations: map[string]string{
|
| 158 |
- "description": "This is a description", |
|
| 159 |
- "displayName": "hi", |
|
| 158 |
+ "openshift.io/description": "This is a description", |
|
| 159 |
+ "openshift.io/display-name": "hi", |
|
| 160 | 160 |
}, |
| 161 | 161 |
}, |
| 162 | 162 |
} |
| ... | ... |
@@ -54,7 +54,7 @@ func (p *ProjectCache) GetNodeSelector(namespace *kapi.Namespace) string {
|
| 54 | 54 |
selector := "" |
| 55 | 55 |
found := false |
| 56 | 56 |
if len(namespace.ObjectMeta.Annotations) > 0 {
|
| 57 |
- if ns, ok := namespace.ObjectMeta.Annotations[projectapi.ProjectNodeSelectorParam]; ok {
|
|
| 57 |
+ if ns, ok := namespace.ObjectMeta.Annotations[projectapi.ProjectNodeSelector]; ok {
|
|
| 58 | 58 |
selector = ns |
| 59 | 59 |
found = true |
| 60 | 60 |
} |
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" |
| 13 | 13 |
|
| 14 | 14 |
"github.com/openshift/origin/pkg/project/api" |
| 15 |
+ projectapi "github.com/openshift/origin/pkg/project/api" |
|
| 15 | 16 |
projectauth "github.com/openshift/origin/pkg/project/auth" |
| 16 | 17 |
projectregistry "github.com/openshift/origin/pkg/project/registry/project" |
| 17 | 18 |
) |
| ... | ... |
@@ -74,7 +75,7 @@ func convertProject(project *api.Project) *kapi.Namespace {
|
| 74 | 74 |
if namespace.Annotations == nil {
|
| 75 | 75 |
namespace.Annotations = map[string]string{}
|
| 76 | 76 |
} |
| 77 |
- namespace.Annotations["displayName"] = project.Annotations["displayName"] |
|
| 77 |
+ namespace.Annotations[projectapi.ProjectDisplayName] = project.Annotations[projectapi.ProjectDisplayName] |
|
| 78 | 78 |
return namespace |
| 79 | 79 |
} |
| 80 | 80 |
|
| ... | ... |
@@ -74,7 +74,7 @@ func TestCreateInvalidProject(t *testing.T) {
|
| 74 | 74 |
storage := NewREST(mockClient.Namespaces(), &mockLister{})
|
| 75 | 75 |
_, err := storage.Create(nil, &api.Project{
|
| 76 | 76 |
ObjectMeta: kapi.ObjectMeta{
|
| 77 |
- Annotations: map[string]string{"displayName": "h\t\ni"},
|
|
| 77 |
+ Annotations: map[string]string{"openshift.io/display-name": "h\t\ni"},
|
|
| 78 | 78 |
}, |
| 79 | 79 |
}) |
| 80 | 80 |
if !errors.IsInvalid(err) {
|
| ... | ... |
@@ -69,8 +69,8 @@ func (r *REST) Create(ctx kapi.Context, obj runtime.Object) (runtime.Object, err |
| 69 | 69 |
projectDisplayName = projectRequest.DisplayName |
| 70 | 70 |
} |
| 71 | 71 |
|
| 72 |
- if len(projectRequest.Annotations["description"]) > 0 {
|
|
| 73 |
- projectDescription = projectRequest.Annotations["description"] |
|
| 72 |
+ if len(projectRequest.Description) > 0 {
|
|
| 73 |
+ projectDescription = projectRequest.Description |
|
| 74 | 74 |
} |
| 75 | 75 |
if userInfo, exists := kapi.UserFrom(ctx); exists {
|
| 76 | 76 |
projectAdmin = userInfo.GetName() |
| ... | ... |
@@ -31,8 +31,8 @@ func DefaultTemplate() *templateapi.Template {
|
| 31 | 31 |
project := &projectapi.Project{}
|
| 32 | 32 |
project.Name = ns |
| 33 | 33 |
project.Annotations = map[string]string{
|
| 34 |
- "description": "${" + ProjectDescriptionParam + "}",
|
|
| 35 |
- "displayName": "${" + ProjectDisplayNameParam + "}",
|
|
| 34 |
+ projectapi.ProjectDescription: "${" + ProjectDescriptionParam + "}",
|
|
| 35 |
+ projectapi.ProjectDisplayName: "${" + ProjectDisplayNameParam + "}",
|
|
| 36 | 36 |
} |
| 37 | 37 |
ret.Objects = append(ret.Objects, project) |
| 38 | 38 |
|
| ... | ... |
@@ -131,8 +131,8 @@ func TestProjectIsNamespace(t *testing.T) {
|
| 131 | 131 |
ObjectMeta: kapi.ObjectMeta{
|
| 132 | 132 |
Name: "new-project", |
| 133 | 133 |
Annotations: map[string]string{
|
| 134 |
- "displayName": "Hello World", |
|
| 135 |
- projectapi.ProjectNodeSelectorParam: "env=test", |
|
| 134 |
+ "openshift.io/display-name": "Hello World", |
|
| 135 |
+ "openshift.io/node-selector": "env=test", |
|
| 136 | 136 |
}, |
| 137 | 137 |
}, |
| 138 | 138 |
} |
| ... | ... |
@@ -149,11 +149,11 @@ func TestProjectIsNamespace(t *testing.T) {
|
| 149 | 149 |
if project.Name != namespace.Name {
|
| 150 | 150 |
t.Fatalf("Project name did not match namespace name, project %v, namespace %v", project.Name, namespace.Name)
|
| 151 | 151 |
} |
| 152 |
- if project.Annotations["displayName"] != namespace.Annotations["displayName"] {
|
|
| 153 |
- t.Fatalf("Project display name did not match namespace annotation, project %v, namespace %v", project.Annotations["displayName"], namespace.Annotations["displayName"])
|
|
| 152 |
+ if project.Annotations["openshift.io/display-name"] != namespace.Annotations["openshift.io/display-name"] {
|
|
| 153 |
+ t.Fatalf("Project display name did not match namespace annotation, project %v, namespace %v", project.Annotations["openshift.io/display-name"], namespace.Annotations["openshift.io/display-name"])
|
|
| 154 | 154 |
} |
| 155 |
- if project.Annotations[projectapi.ProjectNodeSelectorParam] != namespace.Annotations[projectapi.ProjectNodeSelectorParam] {
|
|
| 156 |
- t.Fatalf("Project node selector did not match namespace node selector, project %v, namespace %v", project.Annotations[projectapi.ProjectNodeSelectorParam], namespace.Annotations[projectapi.ProjectNodeSelectorParam])
|
|
| 155 |
+ if project.Annotations["openshift.io/node-selector"] != namespace.Annotations["openshift.io/node-selector"] {
|
|
| 156 |
+ t.Fatalf("Project node selector did not match namespace node selector, project %v, namespace %v", project.Annotations["openshift.io/node-selector"], namespace.Annotations["openshift.io/node-selector"])
|
|
| 157 | 157 |
} |
| 158 | 158 |
} |
| 159 | 159 |
|