| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package coordinator |
| 6 |
| 7 import ( |
| 8 "strings" |
| 9 |
| 10 "github.com/luci/luci-go/common/config" |
| 11 ) |
| 12 |
| 13 const projectNamespacePrefix = "luci." |
| 14 |
| 15 // ProjectNamespace returns the AppEngine namespace for a given luci-config |
| 16 // project name. |
| 17 func ProjectNamespace(project config.ProjectName) string { |
| 18 return projectNamespacePrefix + string(project) |
| 19 } |
| 20 |
| 21 // ProjectFromNamespace returns the current project installed in the supplied |
| 22 // Context's namespace. |
| 23 // |
| 24 // If the namespace does not have a project namespace prefix, this function |
| 25 // will return an empty string. |
| 26 func ProjectFromNamespace(ns string) config.ProjectName { |
| 27 if !strings.HasPrefix(ns, projectNamespacePrefix) { |
| 28 return "" |
| 29 } |
| 30 return config.ProjectName(ns[len(projectNamespacePrefix):]) |
| 31 } |
| OLD | NEW |