2020-08-13 14:00:15 -04:00
|
|
|
package static
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/hashicorp/boundary/internal/db"
|
2020-12-09 10:11:38 -08:00
|
|
|
"github.com/hashicorp/boundary/internal/errors"
|
2021-07-27 09:59:52 -07:00
|
|
|
"github.com/hashicorp/boundary/internal/host"
|
|
|
|
|
"github.com/hashicorp/boundary/internal/types/subtypes"
|
2020-08-13 14:00:15 -04:00
|
|
|
)
|
|
|
|
|
|
2021-07-27 09:59:52 -07:00
|
|
|
func init() {
|
|
|
|
|
if err := host.Register(Subtype, HostCatalogPrefix, HostSetPrefix, HostPrefix); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-13 14:00:15 -04:00
|
|
|
// PublicId prefixes for the resources in the static package.
|
|
|
|
|
const (
|
2020-08-25 00:21:08 -04:00
|
|
|
HostCatalogPrefix = "hcst"
|
|
|
|
|
HostSetPrefix = "hsst"
|
|
|
|
|
HostPrefix = "hst"
|
2021-07-27 09:59:52 -07:00
|
|
|
|
|
|
|
|
Subtype = subtypes.Subtype("static")
|
2020-08-13 14:00:15 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func newHostCatalogId() (string, error) {
|
|
|
|
|
id, err := db.NewPublicId(HostCatalogPrefix)
|
|
|
|
|
if err != nil {
|
2020-12-09 10:11:38 -08:00
|
|
|
return "", errors.Wrap(err, "static.newHostCatalogId")
|
2020-08-13 14:00:15 -04:00
|
|
|
}
|
2020-12-23 11:00:00 -08:00
|
|
|
return id, nil
|
2020-08-13 14:00:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newHostId() (string, error) {
|
|
|
|
|
id, err := db.NewPublicId(HostPrefix)
|
|
|
|
|
if err != nil {
|
2020-12-09 10:11:38 -08:00
|
|
|
return "", errors.Wrap(err, "static.newHostId")
|
2020-08-13 14:00:15 -04:00
|
|
|
}
|
2020-12-23 11:00:00 -08:00
|
|
|
return id, nil
|
2020-08-13 14:00:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newHostSetId() (string, error) {
|
|
|
|
|
id, err := db.NewPublicId(HostSetPrefix)
|
|
|
|
|
if err != nil {
|
2020-12-09 10:11:38 -08:00
|
|
|
return "", errors.Wrap(err, "static.newHostSetId")
|
2020-08-13 14:00:15 -04:00
|
|
|
}
|
2020-12-23 11:00:00 -08:00
|
|
|
return id, nil
|
2020-08-13 14:00:15 -04:00
|
|
|
}
|