2020-08-13 14:00:15 -04:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-02-02 17:15:17 -08:00
|
|
|
|
2020-08-13 14:00:15 -04:00
|
|
|
package static
|
|
|
|
|
|
|
|
|
|
import (
|
2023-06-06 17:09:08 -04:00
|
|
|
"context"
|
|
|
|
|
|
2023-03-10 15:06:39 -05:00
|
|
|
"github.com/hashicorp/boundary/globals"
|
2020-08-13 14:00:15 -04:00
|
|
|
"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"
|
2023-11-15 19:55:46 -05:00
|
|
|
"github.com/hashicorp/boundary/internal/types/resource"
|
2020-08-13 14:00:15 -04:00
|
|
|
)
|
|
|
|
|
|
2021-07-27 09:59:52 -07:00
|
|
|
func init() {
|
2023-11-15 19:55:46 -05:00
|
|
|
globals.RegisterPrefixToResourceInfo(globals.StaticHostCatalogPrefix, resource.HostCatalog, host.Domain, Subtype)
|
|
|
|
|
globals.RegisterPrefixToResourceInfo(globals.StaticHostSetPrefix, resource.HostSet, host.Domain, Subtype)
|
|
|
|
|
globals.RegisterPrefixToResourceInfo(globals.StaticHostPrefix, resource.Host, host.Domain, Subtype)
|
2021-07-27 09:59:52 -07:00
|
|
|
}
|
|
|
|
|
|
2023-11-02 16:03:47 -04:00
|
|
|
// PublicId prefixes for the resources in the static package.
|
|
|
|
|
const (
|
2023-11-15 19:55:46 -05:00
|
|
|
Subtype = globals.Subtype("static")
|
2023-11-02 16:03:47 -04:00
|
|
|
)
|
|
|
|
|
|
2023-06-06 17:09:08 -04:00
|
|
|
func newHostCatalogId(ctx context.Context) (string, error) {
|
|
|
|
|
id, err := db.NewPublicId(ctx, globals.StaticHostCatalogPrefix)
|
2020-08-13 14:00:15 -04:00
|
|
|
if err != nil {
|
2023-06-06 17:09:08 -04:00
|
|
|
return "", errors.Wrap(ctx, 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
|
|
|
}
|
|
|
|
|
|
2023-06-06 17:09:08 -04:00
|
|
|
func newHostId(ctx context.Context) (string, error) {
|
|
|
|
|
id, err := db.NewPublicId(ctx, globals.StaticHostPrefix)
|
2020-08-13 14:00:15 -04:00
|
|
|
if err != nil {
|
2023-06-06 17:09:08 -04:00
|
|
|
return "", errors.Wrap(ctx, 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
|
|
|
}
|
|
|
|
|
|
2023-06-06 17:09:08 -04:00
|
|
|
func newHostSetId(ctx context.Context) (string, error) {
|
|
|
|
|
id, err := db.NewPublicId(ctx, globals.StaticHostSetPrefix)
|
2020-08-13 14:00:15 -04:00
|
|
|
if err != nil {
|
2023-06-06 17:09:08 -04:00
|
|
|
return "", errors.Wrap(ctx, 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
|
|
|
}
|