Files
threshold/internal/host/static/public_ids.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.4 KiB
Go
Raw Normal View History

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 (
"context"
"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"
"github.com/hashicorp/boundary/internal/host"
"github.com/hashicorp/boundary/internal/types/resource"
2020-08-13 14:00:15 -04:00
)
func init() {
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)
}
2023-11-02 16:03:47 -04:00
// PublicId prefixes for the resources in the static package.
const (
Subtype = globals.Subtype("static")
2023-11-02 16:03:47 -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 {
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
}
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 {
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
}
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 {
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
}