Files
threshold/internal/host/static/host_set_member.go
T
s-christoffandJim 6b78108ecf Update primary error functions to take a context, deprecate old functions (#1358)
* add new error funcs which take a ctx and deprecate existing funcs

* use context where available when writing error events

* remove circular internal/errors pkg dep

* suppress some chatty errors using errors.WithoutEvent()

* convert auth oidc funcs to take context where needed to write events

Co-authored-by: Jim <jlambert@hashicorp.com>
2021-07-29 20:52:56 -04:00

46 lines
1.2 KiB
Go

package static
import (
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/host/static/store"
)
// A HostSetMember represents the membership of a host in a host set.
type HostSetMember struct {
*store.HostSetMember
tableName string `gorm:"-"`
}
// NewHostSetMember creates a new in memory HostSetMember representing the
// membership of hostId in hostSetId.
func NewHostSetMember(hostSetId, hostId string, opt ...Option) (*HostSetMember, error) {
const op = "static.NewHostSetMember"
if hostSetId == "" {
return nil, errors.NewDeprecated(errors.InvalidParameter, op, "no host set id")
}
if hostId == "" {
return nil, errors.NewDeprecated(errors.InvalidParameter, op, "no host id")
}
member := &HostSetMember{
HostSetMember: &store.HostSetMember{
SetId: hostSetId,
HostId: hostId,
},
}
return member, nil
}
// TableName returns the table name for the host set.
func (m *HostSetMember) TableName() string {
if m.tableName != "" {
return m.tableName
}
return "static_host_set_member"
}
// SetTableName sets the table name. If the caller attempts to
// set the name to "" the name will be reset to the default name.
func (m *HostSetMember) SetTableName(n string) {
m.tableName = n
}