* Remove Prefix Id and Plugin Name fields. Creating catalogs now require either the plugin id or the name of the plugin resource (but not both). Host Catalogs and Host Sets API resources now have a read only plugin field populated with plugin info. Host Catalogs have a plugin id field as a top level field.
42 lines
1001 B
Go
42 lines
1001 B
Go
package plugin
|
|
|
|
import (
|
|
"context"
|
|
|
|
"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 = "hc"
|
|
HostSetPrefix = "hs"
|
|
|
|
Subtype = subtypes.Subtype("plugin")
|
|
)
|
|
|
|
func newHostCatalogId(ctx context.Context) (string, error) {
|
|
id, err := db.NewPublicId(HostCatalogPrefix)
|
|
if err != nil {
|
|
return "", errors.Wrap(ctx, err, "plugin.newHostCatalogId")
|
|
}
|
|
return id, nil
|
|
}
|
|
|
|
func newHostSetId(ctx context.Context) (string, error) {
|
|
id, err := db.NewPublicId(HostSetPrefix)
|
|
if err != nil {
|
|
return "", errors.Wrap(ctx, err, "plugin.newHostSetId")
|
|
}
|
|
return id, nil
|
|
}
|