2021-09-08 10:06:38 -07:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
|
|
import (
|
2021-09-09 11:15:14 -07:00
|
|
|
"context"
|
2021-09-09 10:45:41 -07:00
|
|
|
|
2021-09-08 10:06:38 -07:00
|
|
|
"github.com/hashicorp/boundary/internal/db"
|
|
|
|
|
"github.com/hashicorp/boundary/internal/errors"
|
|
|
|
|
"github.com/hashicorp/boundary/internal/host"
|
|
|
|
|
"github.com/hashicorp/boundary/internal/types/subtypes"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
if err := host.Register(Subtype, HostCatalogPrefix, HostSetPrefix); err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PublicId prefixes for the resources in the plugin package.
|
|
|
|
|
const (
|
|
|
|
|
// TODO: Pull these out of being constants and have them derivable at run time.
|
2021-09-24 13:16:13 -07:00
|
|
|
HostCatalogPrefix = "hc"
|
|
|
|
|
HostSetPrefix = "hs"
|
2021-09-08 10:06:38 -07:00
|
|
|
|
|
|
|
|
Subtype = subtypes.Subtype("plugin")
|
|
|
|
|
)
|
|
|
|
|
|
2021-09-24 13:16:13 -07:00
|
|
|
func newHostCatalogId(ctx context.Context) (string, error) {
|
|
|
|
|
id, err := db.NewPublicId(HostCatalogPrefix)
|
2021-09-08 10:06:38 -07:00
|
|
|
if err != nil {
|
2021-09-09 11:15:14 -07:00
|
|
|
return "", errors.Wrap(ctx, err, "plugin.newHostCatalogId")
|
2021-09-08 10:06:38 -07:00
|
|
|
}
|
|
|
|
|
return id, nil
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-24 13:16:13 -07:00
|
|
|
func newHostSetId(ctx context.Context) (string, error) {
|
|
|
|
|
id, err := db.NewPublicId(HostSetPrefix)
|
2021-09-08 10:06:38 -07:00
|
|
|
if err != nil {
|
2021-09-09 11:15:14 -07:00
|
|
|
return "", errors.Wrap(ctx, err, "plugin.newHostSetId")
|
2021-09-08 10:06:38 -07:00
|
|
|
}
|
|
|
|
|
return id, nil
|
|
|
|
|
}
|