本文整理汇总了Golang中github.com/pborman/uuid.UUID.String方法的典型用法代码示例。如果您正苦于以下问题:Golang UUID.String方法的具体用法?Golang UUID.String怎么用?Golang UUID.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pborman/uuid.UUID
的用法示例。
在下文中一共展示了UUID.String方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MinionClassifierKeys
// MinionClassifierKeys returns all classifier keys that a minion has
func (c *etcdMinionClient) MinionClassifierKeys(m uuid.UUID) ([]string, error) {
// Classifier directory in etcd
classifierDir := filepath.Join(minion.EtcdMinionSpace, m.String(), "classifier")
opts := &etcdclient.GetOptions{
Recursive: true,
}
resp, err := c.kapi.Get(context.Background(), classifierDir, opts)
if err != nil {
return nil, err
}
var classifierKeys []string
for _, node := range resp.Node.Nodes {
klassifier := new(classifier.Classifier)
err := json.Unmarshal([]byte(node.Value), &klassifier)
if err != nil {
return nil, err
}
classifierKeys = append(classifierKeys, klassifier.Key)
}
return classifierKeys, nil
}
示例2: StartTask
func (db *DB) StartTask(id uuid.UUID, effective time.Time) error {
validtime := ValidateEffectiveUnix(effective)
return db.Exec(
`UPDATE tasks SET status = ?, started_at = ? WHERE uuid = ?`,
RunningStatus, validtime, id.String(),
)
}
示例3: GetTarget
func (db *DB) GetTarget(id uuid.UUID) (*Target, error) {
r, err := db.Query(`
SELECT t.uuid, t.name, t.summary, t.plugin, t.endpoint, t.agent
FROM targets t
LEFT JOIN jobs j
ON j.target_uuid = t.uuid
WHERE t.uuid = ?`, id.String())
if err != nil {
return nil, err
}
defer r.Close()
if !r.Next() {
return nil, nil
}
ann := &Target{}
var this NullUUID
if err = r.Scan(&this, &ann.Name, &ann.Summary, &ann.Plugin, &ann.Endpoint, &ann.Agent); err != nil {
return nil, err
}
ann.UUID = this.UUID
return ann, nil
}
示例4: GetStore
func (db *DB) GetStore(id uuid.UUID) (*Store, error) {
r, err := db.Query(`
SELECT s.uuid, s.name, s.summary, s.plugin, s.endpoint
FROM stores s
LEFT JOIN jobs j
ON j.store_uuid = s.uuid
WHERE s.uuid = ?`, id.String())
if err != nil {
return nil, err
}
defer r.Close()
if !r.Next() {
return nil, nil
}
ann := &Store{}
var this NullUUID
if err = r.Scan(&this, &ann.Name, &ann.Summary, &ann.Plugin, &ann.Endpoint); err != nil {
return nil, err
}
ann.UUID = this.UUID
return ann, nil
}
示例5: GetByUuid
func (db *InMemDatabase) GetByUuid(id uuid.UUID) (contrail.IObject, error) {
uid := makeUID(id)
obj, ok := db.objByIdMap[uid]
if !ok {
return nil, fmt.Errorf("%s: Not found", id.String())
}
return obj, nil
}
示例6: newPod
func newPod(h *Host, id uuid.UUID) *Pod {
if id == nil {
id = uuid.NewRandom()
}
return &Pod{
Host: h,
UUID: id,
ui: ui.NewUI("yellow", "pod", id.String()),
}
}
示例7: MinionName
// MinionName returns the name of a minion identified by its uuid
func (c *etcdMinionClient) MinionName(m uuid.UUID) (string, error) {
nameKey := filepath.Join(minion.EtcdMinionSpace, m.String(), "name")
resp, err := c.kapi.Get(context.Background(), nameKey, nil)
if err != nil {
return "", err
}
return resp.Node.Value, nil
}
示例8: UpdateSchedule
func (db *DB) UpdateSchedule(id uuid.UUID, ts string) error {
_, err := timespec.Parse(ts)
if err != nil {
return err
}
return db.Exec(
`UPDATE schedules SET timespec = ? WHERE uuid = ?`,
ts, id.String(),
)
}
示例9: GetTask
func (db *DB) GetTask(id uuid.UUID) (*Task, error) {
filter := TaskFilter{UUID: id.String()}
r, err := db.GetAllTasks(&filter)
if err != nil {
return nil, err
}
if len(r) == 0 {
return nil, nil
}
return r[0], nil
}
示例10: NewImage
func NewImage(h *Host, id uuid.UUID) *Image {
if id == nil {
id = uuid.NewRandom()
}
return &Image{
Host: h,
UUID: id,
Manifest: *schema.BlankImageManifest(),
ui: ui.NewUI("blue", "image", id.String()),
}
}
示例11: CreateTaskArchive
func (db *DB) CreateTaskArchive(id uuid.UUID, key string, effective time.Time) (uuid.UUID, error) {
// fail on empty store_key, as '' seems to satisfy the NOT NULL constraint in postgres
if key == "" {
return nil, fmt.Errorf("cannot create an archive without a store_key")
}
// determine how long we need to keep this specific archive for
r, err := db.Query(
`SELECT r.expiry
FROM retention r
INNER JOIN jobs j ON r.uuid = j.retention_uuid
INNER JOIN tasks t ON j.uuid = t.job_uuid
WHERE t.uuid = ?`,
id.String(),
)
if err != nil {
return nil, err
}
defer r.Close()
if !r.Next() {
return nil, fmt.Errorf("failed to determine expiration for task %s", id)
}
var expiry int
if err := r.Scan(&expiry); err != nil {
return nil, err
}
r.Close()
// insert an archive with all proper references, expiration, etc.
archive_id := uuid.NewRandom()
validtime := ValidateEffectiveUnix(effective)
err = db.Exec(
`INSERT INTO archives
(uuid, target_uuid, store_uuid, store_key, taken_at, expires_at, notes, status, purge_reason)
SELECT ?, t.uuid, s.uuid, ?, ?, ?, '', ?, ''
FROM tasks
INNER JOIN jobs j ON j.uuid = tasks.job_uuid
INNER JOIN targets t ON t.uuid = j.target_uuid
INNER JOIN stores s ON s.uuid = j.store_uuid
WHERE tasks.uuid = ?`,
archive_id.String(), key, validtime, effective.Add(time.Duration(expiry)*time.Second).Unix(), "valid", id.String(),
)
if err != nil {
return nil, err
}
// and finally, associate task -> archive
return archive_id, db.Exec(
`UPDATE tasks SET archive_uuid = ? WHERE uuid = ?`,
archive_id.String(), id.String(),
)
}
示例12: MinionLastseen
// MinionLastSeen retrieves the time a minion was last seen
func (c *etcdMinionClient) MinionLastseen(m uuid.UUID) (int64, error) {
lastseenKey := filepath.Join(minion.EtcdMinionSpace, m.String(), "lastseen")
resp, err := c.kapi.Get(context.Background(), lastseenKey, nil)
if err != nil {
return 0, err
}
lastseen, err := strconv.ParseInt(resp.Node.Value, 10, 64)
return lastseen, err
}
示例13: MinionClassifier
// MinionClassifier retrieves a classifier with the given key
func (c *etcdMinionClient) MinionClassifier(m uuid.UUID, key string) (*classifier.Classifier, error) {
// Classifier key in etcd
classifierKey := filepath.Join(minion.EtcdMinionSpace, m.String(), "classifier", key)
resp, err := c.kapi.Get(context.Background(), classifierKey, nil)
if err != nil {
return nil, err
}
klassifier := new(classifier.Classifier)
err = json.Unmarshal([]byte(resp.Node.Value), &klassifier)
return klassifier, err
}
示例14: MinionTaskResult
// MinionTaskResult retrieves the result of a task for a given minion
func (c *etcdMinionClient) MinionTaskResult(m uuid.UUID, t uuid.UUID) (*task.Task, error) {
// Task key in etcd
taskKey := filepath.Join(minion.EtcdMinionSpace, m.String(), "log", t.String())
// Get the task from etcd
resp, err := c.kapi.Get(context.Background(), taskKey, nil)
if err != nil {
return nil, err
}
result := new(task.Task)
err = json.Unmarshal([]byte(resp.Node.Value), &result)
return result, err
}
示例15: hasPermission
func hasPermission(session *LoginSession, uuidBytes uuid.UUID) bool {
var tags []string
if session == nil {
tags = defaulttags
} else {
tags = session.tags
}
uuidString := uuidBytes.String()
for _, tag := range tags {
if tagHasPermission(tag, uuidBytes, uuidString) {
return true
}
}
return false
}