Files
threshold/internal/host/plugin/ids.go
T
Todd Knight 4f09f1d74f Add create, list, lookup functions for plugin based host catalogs (#1515)
Create the repository for plugin host catalogs.  A large TODO is left in the code to interface with the plugin system once ready.
2021-09-09 11:15:14 -07:00

45 lines
1.1 KiB
Go

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