blob: a70553268bf42650cfc6b742849e5551b4c7c453 [file] [log] [blame]
// Copyright 2015 The LUCI Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package coordinator
import (
"strings"
)
const (
// ProjectNamespacePrefix is the datastore namespace prefix for project
// namespaces.
ProjectNamespacePrefix = "luci."
)
// ProjectNamespace returns the AppEngine namespace for a given luci-config
// project name.
func ProjectNamespace(project string) string {
return ProjectNamespacePrefix + project
}
// ProjectFromNamespace returns the current project installed in the supplied
// Context's namespace.
//
// If the namespace does not have a project namespace prefix, this function
// will return an empty string.
func ProjectFromNamespace(ns string) string {
if !strings.HasPrefix(ns, ProjectNamespacePrefix) {
return ""
}
return ns[len(ProjectNamespacePrefix):]
}