Add config to enable "public" namespaces
These are namespaces that will be displayed in the repo list view, regardless of whether the user is a member.
This commit is contained in:
parent
dff4207a89
commit
650dbe5f5b
3 changed files with 19 additions and 4 deletions
|
@ -273,6 +273,12 @@ class DefaultConfig(ImmutableConfig):
|
||||||
# rather than only write access or admin access.
|
# rather than only write access or admin access.
|
||||||
FEATURE_READER_BUILD_LOGS = False
|
FEATURE_READER_BUILD_LOGS = False
|
||||||
|
|
||||||
|
# If a namespace is defined in the public namespace list, then it will appear on *all*
|
||||||
|
# user's repository list pages, regardless of whether that user is a member of the namespace.
|
||||||
|
# Typically, this is used by an enterprise customer in configuring a set of "well-known"
|
||||||
|
# namespaces.
|
||||||
|
PUBLIC_NAMESPACES = []
|
||||||
|
|
||||||
# The namespace to use for library repositories.
|
# The namespace to use for library repositories.
|
||||||
# Note: This must remain 'library' until Docker removes their hard-coded namespace for libraries.
|
# Note: This must remain 'library' until Docker removes their hard-coded namespace for libraries.
|
||||||
# See: https://github.com/docker/docker/blob/master/registry/session.go#L320
|
# See: https://github.com/docker/docker/blob/master/registry/session.go#L320
|
||||||
|
|
|
@ -79,6 +79,7 @@ def user_view(user, previous_username=None):
|
||||||
'name': o.username,
|
'name': o.username,
|
||||||
'avatar': avatar.get_data_for_org(o),
|
'avatar': avatar.get_data_for_org(o),
|
||||||
'can_create_repo': CreateRepositoryPermission(o.username).can(),
|
'can_create_repo': CreateRepositoryPermission(o.username).can(),
|
||||||
|
'public': o.username in app.config.get('PUBLIC_NAMESPACES', []),
|
||||||
}
|
}
|
||||||
|
|
||||||
if user_admin:
|
if user_admin:
|
||||||
|
@ -89,7 +90,13 @@ def user_view(user, previous_username=None):
|
||||||
|
|
||||||
return org_response
|
return org_response
|
||||||
|
|
||||||
organizations = model.organization.get_user_organizations(user.username)
|
# Retrieve the organizations for the user.
|
||||||
|
organizations = list(model.organization.get_user_organizations(user.username))
|
||||||
|
|
||||||
|
# Add any public namespaces.
|
||||||
|
public_namespaces = app.config.get('PUBLIC_NAMESPACES', [])
|
||||||
|
if public_namespaces:
|
||||||
|
organizations.extend([model.user.get_namespace_user(ns) for ns in public_namespaces])
|
||||||
|
|
||||||
def login_view(login):
|
def login_view(login):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
function RepoListCtrl($scope, $sanitize, $q, Restangular, UserService, ApiService, Features) {
|
function RepoListCtrl($scope, $sanitize, $q, Restangular, UserService, ApiService, Features, Config) {
|
||||||
$scope.namespace = null;
|
$scope.namespace = null;
|
||||||
$scope.page = 1;
|
$scope.page = 1;
|
||||||
$scope.publicPageCount = null;
|
$scope.publicPageCount = null;
|
||||||
|
@ -35,7 +35,8 @@
|
||||||
user.organizations.map(function(org) {
|
user.organizations.map(function(org) {
|
||||||
$scope.namespaces.push({
|
$scope.namespaces.push({
|
||||||
'name': org.name,
|
'name': org.name,
|
||||||
'avatar': org.avatar
|
'avatar': org.avatar,
|
||||||
|
'public': org.public
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -99,7 +100,8 @@
|
||||||
var options = {
|
var options = {
|
||||||
'namespace': namespace.name,
|
'namespace': namespace.name,
|
||||||
'last_modified': true,
|
'last_modified': true,
|
||||||
'popularity': true
|
'popularity': true,
|
||||||
|
'public': namespace.public
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace.repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
namespace.repositories = ApiService.listReposAsResource().withOptions(options).get(function(resp) {
|
||||||
|
|
Reference in a new issue