Ai
1 Star 0 Fork 0

ryancartoon/sensu-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
namespace.go 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
Simon Plourde 提交于 2019-06-11 23:20 +08:00 . APId Refactoring (#3018)
package v2
import (
"fmt"
"net/url"
"path"
)
const (
// NamespaceTypeAll represents an empty namespace, used to represent a request
// across all namespaces
NamespaceTypeAll = ""
// NamespacesResource is the name of this resource type
NamespacesResource = "namespaces"
)
// StorePrefix returns the path prefix to this resource in the store
func (n *Namespace) StorePrefix() string {
return NamespacesResource
}
// URIPath returns the path component of a Namespace URI.
func (n *Namespace) URIPath() string {
return path.Join(URLPrefix, "namespaces", url.PathEscape(n.Name))
}
// Validate returns an error if the namespace does not pass validation tests
func (n *Namespace) Validate() error {
if err := ValidateName(n.Name); err != nil {
return fmt.Errorf("namespace name %s", err)
}
return nil
}
// FixtureNamespace returns a mocked namespace
func FixtureNamespace(name string) *Namespace {
return &Namespace{
Name: name,
}
}
// GetObjectMeta only exists here to fulfil the requirements of Resource
func (n *Namespace) GetObjectMeta() ObjectMeta {
return ObjectMeta{Name: n.Name}
}
// NamespaceFields returns a set of fields that represent that resource
func NamespaceFields(r Resource) map[string]string {
resource := r.(*Namespace)
return map[string]string{
"namespace.name": resource.Name,
}
}
// SetNamespace sets the namespace of the resource.
func (n *Namespace) SetNamespace(namespace string) {
return
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ryancartoon/sensu-go.git
git@gitee.com:ryancartoon/sensu-go.git
ryancartoon
sensu-go
sensu-go
v5.10.1

搜索帮助