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.3 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/subtypes"
2020-08-13 14:00:15 -04:00
)
func init() {
2023-11-02 16:03:47 -04:00
if err := subtypes.Register(host.Domain, Subtype, globals.StaticHostCatalogPrefix, globals.StaticHostSetPrefix, globals.StaticHostPrefix); err != nil {
panic(err)
}
}
2023-11-02 16:03:47 -04:00
// PublicId prefixes for the resources in the static package.
const (
Subtype = subtypes.Subtype("static")
)
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
}