Documentation ¶
Index ¶
- Variables
- func DefaultProjectIDs() []string
- func MemberSliceToStringSlice(m []Member) []string
- func NewMaxProjectsExceededError(limit int) error
- func NewTxCommitError(e error) error
- type Condition
- type ConditionAttribute
- type ConditionOperator
- type Effect
- type ForeignKeyError
- type MaxProjectsExceededError
- type Member
- type Policy
- type PolicyChangeNotification
- type PolicyChangeNotifier
- type Project
- type ProjectRulesStatus
- type Role
- type Rule
- type RuleType
- type Statement
- type Storage
- type TxCommitError
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when a requested policy wasn't found. ErrNotFound = errors.New("not found") // ErrCannotDelete is thrown by our custom pg error from migration 02 // if a user tries to delete a policy that is marked as non-deletable. ErrCannotDelete = errors.New("policy not deletable") // ErrConflict indicates that the object being created already exists. ErrConflict = errors.New("conflict") // ErrDatabase results from unexpected database errors. ErrDatabase = errors.New("database internal") // ErrChangeProjectForRule indicates that an update operation attempted to change // the project for a rule, which is not allowed. ErrChangeProjectForRule = errors.New("cannot change rule project") // ErrMarkedForDeletion indicates an update was attempted on a rule that // is staged for deletion (cannot be "un-deleted") ErrMarkedForDeletion = errors.New("rule marked for deletion") // ErrChangeTypeForRule indicates that an update operation attempted to change // the type for a rule, which is not allowed. ErrChangeTypeForRule = errors.New("cannot change rule type") // ErrProjectInGraveyard indicates that an attempt was made to create a project with // an ID that is currently in iam_project_graveyard ErrProjectInGraveyard = errors.New("cannot create project with ID that is currently being deleted") )
Error responses common to all storage adapters, be it memstore, postgres, etc.
Functions ¶
func DefaultProjectIDs ¶
func DefaultProjectIDs() []string
func MemberSliceToStringSlice ¶
MemberSliceToStringSlice returns a slice of the names of members or an empty string slice if the member array is of length zero or nil.
func NewTxCommitError ¶
Types ¶
type Condition ¶
type Condition struct { Value []string `json:"value"` Attribute ConditionAttribute `json:"attribute"` Operator ConditionOperator `json:"operator"` }
Condition defines a condition for an ingest rule for a project.
func NewCondition ¶
func NewCondition(value []string, attribute ConditionAttribute, operator ConditionOperator) (Condition, error)
NewCondition is a factory for creating a Condition storage object that also does validation around what a valid condition is in terms of our storage layer.
type ConditionAttribute ¶
type ConditionAttribute int
ConditionAttribute is an enum of attributes a project rule condition can be.
const ( ChefRole ConditionAttribute = iota ChefServer ChefTag Environment Organization PolicyGroup PolicyName )
func NewConditionAttribute ¶
func NewConditionAttribute(in string) (ConditionAttribute, error)
NewConditionAttribute converts a string to a ConditionAttribute or returns an error.
func (ConditionAttribute) String ¶
func (c ConditionAttribute) String() string
func (*ConditionAttribute) UnmarshalJSON ¶
func (c *ConditionAttribute) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json unmarshalling for a ConditionAttribute reference so we can pull them out of the database directly as the correct type.
type ConditionOperator ¶
type ConditionOperator int
ConditionOperator is an enum of operators a project rule condition can have. This is an enum because we are planning on adding more eventually.
const ( MemberOf ConditionOperator = iota Equals )
func NewConditionOperator ¶
func NewConditionOperator(in string) (ConditionOperator, error)
NewConditionOperator converts a string to a ConditionOperator or returns an error.
func (ConditionOperator) String ¶
func (c ConditionOperator) String() string
func (*ConditionOperator) UnmarshalJSON ¶
func (c *ConditionOperator) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json unmarshalling for a ConditionOperator reference so we can pull them out of the database directly as the correct type.
type Effect ¶
type Effect int
Effect is an enum of allow or deny for use in Statements.
func (*Effect) UnmarshalJSON ¶
UnmarshalJSON implements json unmarshalling for an Effect reference so we can pull them out of the database directly as the correct type.
type ForeignKeyError ¶
type ForeignKeyError struct {
Msg string
}
MissingFieldError occurs when a required field was not passed.
func (*ForeignKeyError) Error ¶
func (e *ForeignKeyError) Error() string
type MaxProjectsExceededError ¶
type MaxProjectsExceededError struct {
// contains filtered or unexported fields
}
func (*MaxProjectsExceededError) Error ¶
func (e *MaxProjectsExceededError) Error() string
MaxProjectsExceededError indicates that a new project cannot be created since the max allowed are already created.
type Member ¶
type Member struct {
Name string `json:"name"`
}
Member represents a member that can be added / removed from a policy.
type Policy ¶
type Policy struct { ID string `json:"id"` Name string `json:"name"` Members []Member `json:"members"` Statements []Statement `json:"statements"` Type Type `json:"type"` Projects []string `json:"projects"` }
Policy represents a policy definition to be persisted to storage.
func DefaultPolicies ¶
DefaultPolicies shipped with IAM, and also the set of policies to which we factory-reset our storage.
type PolicyChangeNotification ¶
type PolicyChangeNotification struct{}
type PolicyChangeNotifier ¶
type PolicyChangeNotifier interface { C() <-chan PolicyChangeNotification Close() error }
type Project ¶
type Project struct { ID string `json:"id"` Name string `json:"name"` Type Type `json:"type"` Status string `json:"status"` }
Project represents a project definition to be persisted to storage.
func DefaultProjects ¶
func DefaultProjects() []Project
DefaultProjects defines the default Chef-managed projects provided on storage reset At present, this list contains internally required projects only, hidden from the user.
func NewProject ¶
NewProject is a factory for creating a Project storage object that also does validation around what a valid project is in terms of our storage layer.
type ProjectRulesStatus ¶
type ProjectRulesStatus int
ProjectRulesStatus is an enum that represents the states a project's rules can be in.
const ( // RulesStatusError occurs in some error situation RulesStatusError ProjectRulesStatus = iota // The project has rules but all are applied Applied // The project has rules and at least one is staged EditsPending // The project has no staged or applied rules NoRules )
func (ProjectRulesStatus) String ¶
func (c ProjectRulesStatus) String() string
type Role ¶
type Role struct { ID string `json:"id"` Name string `json:"name"` Actions []string `json:"actions"` Type Type `json:"type"` Projects []string `json:"projects"` }
Role represents a role definition to be persisted to storage.
func NewRole ¶
func NewRole(id string, name string, typeVal Type, actions []string, projects []string) (*Role, error)
NewRole is a factory for creating a Role storage object that also does validation around what a valid role is in terms of our storage layer.
func NewUpdateRole ¶
NewUpdateRole is a factory for modifying an existing role.
type Rule ¶
type Rule struct { ID string `json:"id"` ProjectID string `json:"project_id"` Name string `json:"name"` Type RuleType `json:"type"` Conditions []Condition `json:"conditions"` Deleted bool `json:"deleted"` Status string `json:"status"` }
Rule defines an ingest rule for a project.
type RuleType ¶
type RuleType int
RuleType is an enum of the types a project rule can be.
func NewRuleType ¶
NewRuleType converts a string to a RuleType or returns an error.
func (*RuleType) UnmarshalJSON ¶
UnmarshalJSON implements json unmarshalling for an RuleType reference so we can pull them out of the database directly as the correct type.
type Statement ¶
type Statement struct { Actions []string `json:"actions"` Resources []string `json:"resources"` Role string `json:"role"` Projects []string `json:"projects"` Effect Effect `json:"effect"` }
Statement must have at least a role OR a non-empty actions list
type Storage ¶
type Storage interface { // Reset allows "factory-resetting" IAM policies Reset(context.Context) error // Close closes the connection to the backend Close() error // contains filtered or unexported methods }
Storage is the interface that both our postgres and memstore storage solutions implement for consistency. The memstore implementation is only used for ease of testing.
type TxCommitError ¶
type TxCommitError struct {
// contains filtered or unexported fields
}
TxCommitError occurs when the database attempts to commit a transaction and fails.
func (*TxCommitError) Error ¶
func (e *TxCommitError) Error() string
type Type ¶
type Type int
Type is an enum to denote custom or chef-managed policy.
const ( // Custom represents a policy created by the enduser. Custom Type = iota // ChefManaged represents a policy created by Chef Software. ChefManaged // System represents a policy that is only loaded directly into OPA // to allow Automate to function correctly without revealing Automate's // internal policies to the customer // This type is only used in the OPA cache (not in API or database) System )
func (*Type) UnmarshalJSON ¶
UnmarshalJSON implements json unmarshalling for a Type reference so we can pull them out of the database directly as the correct type.