Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
origin-web-common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Java-于龙
origin-web-common
Commits
454f7a6a
Commit
454f7a6a
authored
May 05, 2017
by
benjaminapetersen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update calculateAvailableKinds to support both string & object
parent
23923bd9
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
82 additions
and
86 deletions
+82
-86
origin-web-common-services.js
dist/origin-web-common-services.js
+10
-4
origin-web-common.js
dist/origin-web-common.js
+10
-42
origin-web-common.min.js
dist/origin-web-common.min.js
+17
-32
apiService.js
src/services/apiService.js
+10
-4
karma.conf.js
test/karma.conf.js
+5
-2
config.js
test/spec/fixtures/config.js
+0
-0
constants.js
test/spec/fixtures/constants.js
+13
-0
apiServiceSpec.js
test/spec/services/apiServiceSpec.js
+17
-2
No files found.
dist/origin-web-common-services.js
View file @
454f7a6a
...
...
@@ -469,7 +469,12 @@ angular.module('openshiftCommonServices')
// Returns an array of available kinds, including their group
var
calculateAvailableKinds
=
function
(
includeClusterScoped
)
{
var
kinds
=
[];
var
rejectedKinds
=
Constants
.
AVAILABLE_KINDS_BLACKLIST
;
var
rejectedKinds
=
_
.
map
(
Constants
.
AVAILABLE_KINDS_BLACKLIST
,
function
(
kind
)
{
return
_
.
isString
(
kind
)
?
{
kind
:
kind
,
group
:
''
}
:
kind
;
});
// ignore the legacy openshift kinds, these have been migrated to api groups
_
.
each
(
_
.
pick
(
API_CFG
,
function
(
value
,
key
)
{
...
...
@@ -478,12 +483,13 @@ angular.module('openshiftCommonServices')
_
.
each
(
api
.
resources
.
v1
,
function
(
resource
)
{
if
(
resource
.
namespaced
||
includeClusterScoped
)
{
// Exclude subresources and any rejected kinds
if
(
resource
.
name
.
indexOf
(
"/"
)
>=
0
||
_
.
contains
(
rejectedKinds
,
resource
.
kind
))
{
if
(
_
.
contains
(
resource
.
name
,
'/'
)
||
_
.
find
(
rejectedKinds
,
{
kind
:
resource
.
kind
,
group
:
''
}
))
{
return
;
}
kinds
.
push
({
kind
:
resource
.
kind
kind
:
resource
.
kind
,
group
:
''
});
}
});
...
...
@@ -495,7 +501,7 @@ angular.module('openshiftCommonServices')
var
preferredVersion
=
defaultVersion
[
group
.
name
]
||
group
.
preferredVersion
;
_
.
each
(
group
.
versions
[
preferredVersion
].
resources
,
function
(
resource
)
{
// Exclude subresources and any rejected kinds
if
(
resource
.
name
.
indexOf
(
"/"
)
>=
0
||
_
.
contains
(
rejectedKinds
,
resource
.
kind
))
{
if
(
_
.
contains
(
resource
.
name
,
'/'
)
||
_
.
find
(
rejectedKinds
,
{
kind
:
resource
.
kind
,
group
:
group
.
name
}
))
{
return
;
}
...
...
dist/origin-web-common.js
View file @
454f7a6a
...
...
@@ -896,44 +896,6 @@ angular.module('openshiftCommonUI')
}
};
}]);
;
// This is the default configuration for the dev mode of the web console.
// A generated version of this config is created at run-time when running
// the web console from the openshift binary.
//
// To change configuration for local development, copy this file to
// assets/app/config.local.js and edit the copy.
if
(
!
window
.
OPENSHIFT_CONFIG
)
{
window
.
OPENSHIFT_CONFIG
=
{
apis
:
{
hostPort
:
"localhost:8443"
,
prefix
:
"/apis"
},
api
:
{
openshift
:
{
hostPort
:
"localhost:8443"
,
prefix
:
"/oapi"
},
k8s
:
{
hostPort
:
"localhost:8443"
,
prefix
:
"/api"
}
},
auth
:
{
oauth_authorize_uri
:
"https://localhost:8443/oauth/authorize"
,
oauth_token_uri
:
"https://localhost:8443/oauth/token"
,
oauth_redirect_base
:
"https://localhost:9000/dev-console"
,
oauth_client_id
:
"openshift-web-console"
,
logout_uri
:
""
},
loggingURL
:
""
,
metricsURL
:
""
};
window
.
OPENSHIFT_VERSION
=
{
openshift
:
"dev-mode"
,
kubernetes
:
"dev-mode"
};
}
;
'use strict'
;
angular
.
module
(
'openshiftCommonUI'
)
...
...
@@ -1815,7 +1777,12 @@ angular.module('openshiftCommonServices')
// Returns an array of available kinds, including their group
var
calculateAvailableKinds
=
function
(
includeClusterScoped
)
{
var
kinds
=
[];
var
rejectedKinds
=
Constants
.
AVAILABLE_KINDS_BLACKLIST
;
var
rejectedKinds
=
_
.
map
(
Constants
.
AVAILABLE_KINDS_BLACKLIST
,
function
(
kind
)
{
return
_
.
isString
(
kind
)
?
{
kind
:
kind
,
group
:
''
}
:
kind
;
});
// ignore the legacy openshift kinds, these have been migrated to api groups
_
.
each
(
_
.
pick
(
API_CFG
,
function
(
value
,
key
)
{
...
...
@@ -1824,12 +1791,13 @@ angular.module('openshiftCommonServices')
_
.
each
(
api
.
resources
.
v1
,
function
(
resource
)
{
if
(
resource
.
namespaced
||
includeClusterScoped
)
{
// Exclude subresources and any rejected kinds
if
(
resource
.
name
.
indexOf
(
"/"
)
>=
0
||
_
.
contains
(
rejectedKinds
,
resource
.
kind
))
{
if
(
_
.
contains
(
resource
.
name
,
'/'
)
||
_
.
find
(
rejectedKinds
,
{
kind
:
resource
.
kind
,
group
:
''
}
))
{
return
;
}
kinds
.
push
({
kind
:
resource
.
kind
kind
:
resource
.
kind
,
group
:
''
});
}
});
...
...
@@ -1841,7 +1809,7 @@ angular.module('openshiftCommonServices')
var
preferredVersion
=
defaultVersion
[
group
.
name
]
||
group
.
preferredVersion
;
_
.
each
(
group
.
versions
[
preferredVersion
].
resources
,
function
(
resource
)
{
// Exclude subresources and any rejected kinds
if
(
resource
.
name
.
indexOf
(
"/"
)
>=
0
||
_
.
contains
(
rejectedKinds
,
resource
.
kind
))
{
if
(
_
.
contains
(
resource
.
name
,
'/'
)
||
_
.
find
(
rejectedKinds
,
{
kind
:
resource
.
kind
,
group
:
group
.
name
}
))
{
return
;
}
...
...
dist/origin-web-common.min.js
View file @
454f7a6a
...
...
@@ -322,34 +322,7 @@ content ? (scope.truncatedContent = truncateFilter(content, scope.limit, scope.u
});
}
};
}
]),
window
.
OPENSHIFT_CONFIG
||
(
window
.
OPENSHIFT_CONFIG
=
{
apis
:{
hostPort
:
"localhost:8443"
,
prefix
:
"/apis"
},
api
:{
openshift
:{
hostPort
:
"localhost:8443"
,
prefix
:
"/oapi"
},
k8s
:{
hostPort
:
"localhost:8443"
,
prefix
:
"/api"
}
},
auth
:{
oauth_authorize_uri
:
"https://localhost:8443/oauth/authorize"
,
oauth_token_uri
:
"https://localhost:8443/oauth/token"
,
oauth_redirect_base
:
"https://localhost:9000/dev-console"
,
oauth_client_id
:
"openshift-web-console"
,
logout_uri
:
""
},
loggingURL
:
""
,
metricsURL
:
""
},
window
.
OPENSHIFT_VERSION
=
{
openshift
:
"dev-mode"
,
kubernetes
:
"dev-mode"
}),
angular
.
module
(
"openshiftCommonUI"
).
filter
(
"alertStatus"
,
function
()
{
}
]),
angular
.
module
(
"openshiftCommonUI"
).
filter
(
"alertStatus"
,
function
()
{
return
function
(
type
)
{
var
status
;
switch
(
type
)
{
...
...
@@ -740,22 +713,34 @@ return apiObject && apiObject.kind && (kind = apiObject.kind), apiObject && apiO
var
kind
=
"<none>"
,
version
=
"<none>"
;
return
apiObject
&&
apiObject
.
kind
&&
(
kind
=
apiObject
.
kind
),
apiObject
&&
apiObject
.
apiVersion
&&
(
version
=
apiObject
.
apiVersion
),
"The API version "
+
version
+
" for kind "
+
kind
+
" is not supported by this server"
;
},
calculateAvailableKinds
=
function
(
includeClusterScoped
)
{
var
kinds
=
[],
rejectedKinds
=
Constants
.
AVAILABLE_KINDS_BLACKLIST
;
var
kinds
=
[],
rejectedKinds
=
_
.
map
(
Constants
.
AVAILABLE_KINDS_BLACKLIST
,
function
(
kind
)
{
return
_
.
isString
(
kind
)
?
{
kind
:
kind
,
group
:
""
}
:
kind
;
});
return
_
.
each
(
_
.
pick
(
API_CFG
,
function
(
value
,
key
)
{
return
"openshift"
!==
key
;
}),
function
(
api
)
{
_
.
each
(
api
.
resources
.
v1
,
function
(
resource
)
{
if
(
resource
.
namespaced
||
includeClusterScoped
)
{
if
(
resource
.
name
.
indexOf
(
"/"
)
>=
0
||
_
.
contains
(
rejectedKinds
,
resource
.
kind
))
return
;
if
(
_
.
contains
(
resource
.
name
,
"/"
)
||
_
.
find
(
rejectedKinds
,
{
kind
:
resource
.
kind
,
group
:
""
}))
return
;
kinds
.
push
({
kind
:
resource
.
kind
kind
:
resource
.
kind
,
group
:
""
});
}
});
}),
_
.
each
(
APIS_CFG
.
groups
,
function
(
group
)
{
var
preferredVersion
=
defaultVersion
[
group
.
name
]
||
group
.
preferredVersion
;
_
.
each
(
group
.
versions
[
preferredVersion
].
resources
,
function
(
resource
)
{
resource
.
name
.
indexOf
(
"/"
)
>=
0
||
_
.
contains
(
rejectedKinds
,
resource
.
kind
)
||
"extensions"
===
group
.
name
&&
"HorizontalPodAutoscaler"
===
resource
.
kind
||
"batch"
===
group
.
name
&&
"Job"
===
resource
.
kind
||
(
resource
.
namespaced
||
includeClusterScoped
)
&&
kinds
.
push
({
_
.
contains
(
resource
.
name
,
"/"
)
||
_
.
find
(
rejectedKinds
,
{
kind
:
resource
.
kind
,
group
:
group
.
name
})
||
"extensions"
===
group
.
name
&&
"HorizontalPodAutoscaler"
===
resource
.
kind
||
"batch"
===
group
.
name
&&
"Job"
===
resource
.
kind
||
(
resource
.
namespaced
||
includeClusterScoped
)
&&
kinds
.
push
({
kind
:
resource
.
kind
,
group
:
group
.
name
});
...
...
src/services/apiService.js
View file @
454f7a6a
...
...
@@ -266,7 +266,12 @@ angular.module('openshiftCommonServices')
// Returns an array of available kinds, including their group
var
calculateAvailableKinds
=
function
(
includeClusterScoped
)
{
var
kinds
=
[];
var
rejectedKinds
=
Constants
.
AVAILABLE_KINDS_BLACKLIST
;
var
rejectedKinds
=
_
.
map
(
Constants
.
AVAILABLE_KINDS_BLACKLIST
,
function
(
kind
)
{
return
_
.
isString
(
kind
)
?
{
kind
:
kind
,
group
:
''
}
:
kind
;
});
// ignore the legacy openshift kinds, these have been migrated to api groups
_
.
each
(
_
.
pick
(
API_CFG
,
function
(
value
,
key
)
{
...
...
@@ -275,12 +280,13 @@ angular.module('openshiftCommonServices')
_
.
each
(
api
.
resources
.
v1
,
function
(
resource
)
{
if
(
resource
.
namespaced
||
includeClusterScoped
)
{
// Exclude subresources and any rejected kinds
if
(
resource
.
name
.
indexOf
(
"/"
)
>=
0
||
_
.
contains
(
rejectedKinds
,
resource
.
kind
))
{
if
(
_
.
contains
(
resource
.
name
,
'/'
)
||
_
.
find
(
rejectedKinds
,
{
kind
:
resource
.
kind
,
group
:
''
}
))
{
return
;
}
kinds
.
push
({
kind
:
resource
.
kind
kind
:
resource
.
kind
,
group
:
''
});
}
});
...
...
@@ -292,7 +298,7 @@ angular.module('openshiftCommonServices')
var
preferredVersion
=
defaultVersion
[
group
.
name
]
||
group
.
preferredVersion
;
_
.
each
(
group
.
versions
[
preferredVersion
].
resources
,
function
(
resource
)
{
// Exclude subresources and any rejected kinds
if
(
resource
.
name
.
indexOf
(
"/"
)
>=
0
||
_
.
contains
(
rejectedKinds
,
resource
.
kind
))
{
if
(
_
.
contains
(
resource
.
name
,
'/'
)
||
_
.
find
(
rejectedKinds
,
{
kind
:
resource
.
kind
,
group
:
group
.
name
}
))
{
return
;
}
...
...
test/karma.conf.js
View file @
454f7a6a
...
...
@@ -31,12 +31,15 @@ module.exports = function(config) {
"bower_components/hawtio-core/dist/hawtio-core.js"
,
"bower_components/kubernetes-container-terminal/dist/container-terminal.js"
,
"bower_components/hawtio-extension-service/dist/hawtio-extension-service.js"
,
'src/config.js'
,
// load up the fixtures first
'test/spec/fixtures/config.js'
,
'test/spec/fixtures/constants.js'
,
'test/spec/fixtures/api-discovery.js'
,
// TODO: is this causing modules to load multiple times? see `src/**/*.js` below
'src/**/*module.js'
,
'dist/scripts/templates.js'
,
'src/**/*.js'
,
'test/spec/spec-helper.js'
,
'test/spec/fixtures/api-discovery.js'
,
'test/spec/**/*.js'
],
...
...
src
/config.js
→
test/spec/fixtures
/config.js
View file @
454f7a6a
File moved
test/spec/fixtures/constants.js
0 → 100644
View file @
454f7a6a
window
.
OPENSHIFT_CONSTANTS
=
window
.
OPENSHIFT_CONSTANTS
||
{};
window
.
OPENSHIFT_CONSTANTS
.
AVAILABLE_KINDS_BLACKLIST
=
[
// using this kind to test the blacklisting function in apiService.
// "Binding"/servicecatalog.k8s.io will not actually be blacklisted.
{
kind
:
"Binding"
,
group
:
"servicecatalog.k8s.io"
},
"Ingress"
,
// These are things like DCPs that aren't actually persisted resources
"DeploymentConfigRollback"
,
// FOR TESTING:
// { kind: 'LocalSubjectAccessReview', group: ' authorization.openshift.io' }
// { kind: 'LocalSubjectAccessReview', group: ' authorization.k8s.io' }
];
test/spec/services/apiServiceSpec.js
View file @
454f7a6a
...
...
@@ -282,7 +282,7 @@ describe("APIService", function() {
});
// unlike the /oapi endpoint, the /api endpoint should still be listed
it
(
'should list items from the k8s /api namespace
(that do not have a group)
'
,
function
()
{
it
(
'should list items from the k8s /api namespace
where group is an empty string
'
,
function
()
{
var
allKinds
=
APIService
.
availableKinds
(
true
);
var
shouldBeFound
=
[];
// this is a sampling of items from /api that should still be listed,
...
...
@@ -298,7 +298,7 @@ describe("APIService", function() {
];
_
.
each
(
k8sAPIStillExistsSample
,
function
(
kindToFind
)
{
var
found
=
_
.
find
(
allKinds
,
function
(
kind
)
{
return
(
kind
.
kind
===
kindToFind
.
kind
)
&&
!
_
.
includes
(
_
.
keys
(
kind
),
'group'
)
;
return
(
kind
.
kind
===
kindToFind
.
kind
)
&&
kind
.
group
===
''
;
});
if
(
found
)
{
shouldBeFound
.
push
(
found
);
...
...
@@ -307,6 +307,21 @@ describe("APIService", function() {
expect
(
shouldBeFound
.
length
).
toEqual
(
k8sAPIStillExistsSample
.
length
);
});
it
(
'should not return kinds from the AVAILABLE_KINDS_BLACKLIST'
,
function
()
{
var
allKinds
=
APIService
.
availableKinds
(
true
);
// calculateAvailableKinds will transform strings form AVAILABLE_KINDS_BLACKLIST
// into objects in this same way.
var
blacklist
=
_
.
map
(
window
.
OPENSHIFT_CONSTANTS
.
AVAILABLE_KINDS_BLACKLIST
,
function
(
kind
)
{
return
_
.
isString
(
kind
)
?
{
kind
:
kind
,
group
:
''
}
:
kind
;
});
_
.
each
(
blacklist
,
function
(
blacklistedKind
)
{
expect
(
_
.
find
(
allKinds
,
blacklistedKind
)).
toEqual
(
undefined
);
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment