-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathapplicationoffer.go
37 lines (30 loc) · 1.21 KB
/
applicationoffer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2017 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package names
const ApplicationOfferTagKind = "applicationoffer"
// IsValidApplicationOffer returns whether name is a valid application offer name.
func IsValidApplicationOffer(uuid string) bool {
return validUUID.MatchString(uuid)
}
type ApplicationOfferTag struct {
Name string
}
func (t ApplicationOfferTag) String() string { return t.Kind() + "-" + t.Id() }
func (t ApplicationOfferTag) Kind() string { return ApplicationOfferTagKind }
func (t ApplicationOfferTag) Id() string { return t.Name }
// NewApplicationOfferTag returns the tag for the application with the given name.
func NewApplicationOfferTag(applicationOfferName string) ApplicationOfferTag {
return ApplicationOfferTag{Name: applicationOfferName}
}
// ParseApplicationOfferTag parses a application tag string.
func ParseApplicationOfferTag(applicationOfferTag string) (ApplicationOfferTag, error) {
tag, err := ParseTag(applicationOfferTag)
if err != nil {
return ApplicationOfferTag{}, err
}
st, ok := tag.(ApplicationOfferTag)
if !ok {
return ApplicationOfferTag{}, invalidTagError(applicationOfferTag, ApplicationOfferTagKind)
}
return st, nil
}