Files
threshold/internal/host/plugin/ids.go
T
Todd Knight 1249f9668f Add Plugin Host Set Repo Create, List, Read Operations (#1497)
Add repo for plugin based host sets as well as tests.
2021-09-09 10:45:41 -07:00

44 lines
1.1 KiB
Go

package plugin
import (
"fmt"
"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.
HostCatalogPrefix = "hcplg"
HostSetPrefix = "hsplg"
Subtype = subtypes.Subtype("plugin")
)
func newHostCatalogId(upre string) (string, error) {
prefix := fmt.Sprintf("%s_%s", HostCatalogPrefix, upre)
id, err := db.NewPublicId(prefix)
if err != nil {
return "", errors.WrapDeprecated(err, "plugin.newHostCatalogId")
}
return id, nil
}
func newHostSetId(upre string) (string, error) {
prefix := fmt.Sprintf("%s_%s", HostSetPrefix, upre)
id, err := db.NewPublicId(prefix)
if err != nil {
return "", errors.WrapDeprecated(err, "plugin.newHostSetId")
}
return id, nil
}