Documentation
¶
Overview ¶
Package catalog owns catalog persistence and relation validation.
Index ¶
- Variables
- func CheckSecrets(v any) error
- func EditableFields(typ string) []string
- func ValidHTTPURL(value string) bool
- type AssetDetail
- type ConflictError
- type FieldError
- type Object
- type OfflineOptions
- type OfflinePreview
- type Patch
- type Query
- func (q Query) AssetDetail(ctx context.Context, p auth.Principal, id string) (AssetDetail, error)
- func (q Query) Browse(ctx context.Context, p auth.Principal, typ string) ([]Object, error)
- func (q Query) Changes(ctx context.Context, p auth.Principal, objectID, state string) ([]Object, error)
- func (q Query) CheckVersions(ctx context.Context, p auth.Principal) (versioncheck.Summary, error)
- func (q Query) Contexts(ctx context.Context, p auth.Principal, archived bool) ([]Object, error)
- func (q Query) FilterChanges(ctx context.Context, p auth.Principal, ...) ([]Object, error)
- func (q Query) Inventory(ctx context.Context, p auth.Principal, typ, id string) (search.Inventory, error)
- func (q Query) Outdated(ctx context.Context, p auth.Principal) ([]Object, error)
- func (q Query) Search(ctx context.Context, p auth.Principal, term string) ([]search.Result, error)
- func (q Query) ServiceDetail(ctx context.Context, p auth.Principal, idOrName string) (ServiceDetail, error)
- func (q Query) Site(ctx context.Context, p auth.Principal, id string) (search.Site, error)
- func (q Query) Topology(ctx context.Context, p auth.Principal, id string, depth int) (search.Topology, error)
- func (q Query) TopologyView(ctx context.Context, p auth.Principal, id string, depth int, view string) (search.Topology, error)
- func (q Query) Unverified(ctx context.Context, p auth.Principal) ([]Object, error)
- type RestoreResult
- type Service
- func (s Service) AssertNoSecret(v any) error
- func (s Service) CheckVersionsAllowed(p auth.Principal) error
- func (s Service) CreateAsset(ctx context.Context, p auth.Principal, o Object, baseRev int64, ...) (Object, error)
- func (s Service) CreateContext(ctx context.Context, p auth.Principal, o Object, reason, via string) (Object, error)
- func (s Service) DeleteAllowed(p auth.Principal) error
- func (s Service) DeleteAsset(ctx context.Context, p auth.Principal, id string, rev int64, reason string) error
- func (s Service) Get(ctx context.Context, p auth.Principal, id string) (Object, error)
- func (s Service) LatestOfflineOperation(ctx context.Context, p auth.Principal, hostID string) (string, error)
- func (s Service) MarkVerified(ctx context.Context, p auth.Principal, id string, rev int64, ...) (Object, error)
- func (s Service) OfflineHost(ctx context.Context, p auth.Principal, id string, rev int64, ...) (string, error)
- func (s Service) OfflinePreview(ctx context.Context, p auth.Principal, hostID string) (OfflinePreview, error)
- func (s Service) Propose(ctx context.Context, p auth.Principal, id string, rev int64, patch Patch, ...) (string, error)
- func (s Service) ProposeCreate(ctx context.Context, p auth.Principal, o Object, baseRev int64, ...) (string, error)
- func (s Service) ProposeDelete(ctx context.Context, p auth.Principal, id string, rev int64, ...) (string, error)
- func (s Service) PutContext(ctx context.Context, p auth.Principal, id string, rev int64, body string, ...) error
- func (s Service) RecordNote(ctx context.Context, p auth.Principal, target string, rev int64, ...) (string, error)
- func (s Service) RestoreHost(ctx context.Context, p auth.Principal, hostID, opID, reason string) (RestoreResult, error)
- func (s Service) Review(ctx context.Context, p auth.Principal, changeID string, approve bool) (Object, error)
- func (s Service) Update(ctx context.Context, p auth.Principal, id string, rev int64, patch Patch, ...) (Object, error)
- func (s Service) VerifyBatch(ctx context.Context, p auth.Principal, ids []string, withRelated bool, ...) ([]VerifyResult, error)
- type ServiceDetail
- type Store
- func (s Store) ArchiveExpired(ctx context.Context, now time.Time) (int64, error)
- func (s Store) Contexts(ctx context.Context, archived bool, now time.Time) ([]Object, error)
- func (s Store) Create(ctx context.Context, o Object, actor string) (Object, error)
- func (s Store) Get(ctx context.Context, id string) (Object, error)
- func (s Store) Unverified(ctx context.Context, now time.Time) ([]string, error)
- type ValidationError
- type VerifyResult
Constants ¶
This section is empty.
Variables ¶
var ErrConflict = errors.New("revision conflict")
var ErrInvalid = errors.New("invalid change")
var ErrSecret = secrets.ErrSecret
Functions ¶
func CheckSecrets ¶
func EditableFields ¶ added in v0.3.0
EditableFields returns a copy of the business fields accepted for this type.
func ValidHTTPURL ¶ added in v0.3.0
ValidHTTPURL 也用于导入直写数据表之前的校验。
Types ¶
type AssetDetail ¶ added in v0.4.0
type AssetDetail struct {
Object Object `json:"object"`
Notes []Object `json:"notes"`
Credentials []Object `json:"credentials"`
Changes []Object `json:"changes"`
ReferencedBy []Object `json:"referenced_by"`
}
AssetDetail 汇总详情页需要的关联数据;凭据仅含管理器引用。
type ConflictError ¶ added in v0.3.0
type ConflictError struct {
Fields []FieldError `json:"fields"`
}
func (*ConflictError) Error ¶ added in v0.3.0
func (e *ConflictError) Error() string
func (*ConflictError) Is ¶ added in v0.3.0
func (e *ConflictError) Is(target error) bool
type FieldError ¶ added in v0.3.0
type FieldError struct {
Field string `json:"field"`
Reason string `json:"reason"`
Expected string `json:"expected,omitempty"`
References []string `json:"references,omitempty"`
}
FieldError 描述被拒绝的字段,不保存提交的值。
type Object ¶
type Object struct {
ID string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Aliases []string `json:"aliases"`
Tags []string `json:"tags"`
Status string `json:"status"`
Source string `json:"source"`
Confidence string `json:"confidence"`
VerifiedAt *time.Time `json:"verified_at,omitempty"`
VerifiedBy string `json:"verified_by,omitempty"`
Rev int64 `json:"rev"`
CreatedAt time.Time `json:"created_at"`
CreatedBy string `json:"created_by"`
UpdatedAt time.Time `json:"updated_at"`
UpdatedBy string `json:"updated_by"`
Fields map[string]any `json:"fields"`
}
type OfflineOptions ¶ added in v0.3.0
type OfflinePreview ¶ added in v0.3.0
type Patch ¶
type Patch struct {
Name *string `json:"name,omitempty"`
Aliases *[]string `json:"aliases,omitempty"`
Tags *[]string `json:"tags,omitempty"`
Status *string `json:"status,omitempty"`
Source *string `json:"source,omitempty"`
Confidence *string `json:"confidence,omitempty"`
Fields map[string]any `json:"fields,omitempty"`
}
type Query ¶
type Query struct{ Service Service }
Query 将所有传输入口的读取请求收敛到同一个授权边界。
func (Query) AssetDetail ¶ added in v0.4.0
func (Query) CheckVersions ¶
func (Query) FilterChanges ¶ added in v0.4.0
func (Query) ServiceDetail ¶
func (Query) TopologyView ¶ added in v0.4.0
type RestoreResult ¶ added in v0.3.0
type Service ¶
type Service struct{ Store Store }
func (Service) AssertNoSecret ¶
func (Service) CreateAsset ¶
func (s Service) CreateAsset(ctx context.Context, p auth.Principal, o Object, baseRev int64, reason, via string) (Object, error)
CreateAsset accepts a new object at base revision zero and audits its creation.
func (Service) CreateContext ¶
func (Service) DeleteAsset ¶ added in v0.3.0
func (s Service) DeleteAsset(ctx context.Context, p auth.Principal, id string, rev int64, reason string) error
DeleteAsset is reserved for a signed-in web user. Referenced objects are reported before deletion.
func (Service) LatestOfflineOperation ¶ added in v0.3.0
func (Service) MarkVerified ¶
func (Service) OfflineHost ¶ added in v0.3.0
func (s Service) OfflineHost(ctx context.Context, p auth.Principal, id string, rev int64, opts OfflineOptions, reason string) (string, error)
OfflineHost changes selected objects atomically and keeps their prior state for a guarded restore.
func (Service) OfflinePreview ¶ added in v0.3.0
func (Service) Propose ¶
func (s Service) Propose(ctx context.Context, p auth.Principal, id string, rev int64, patch Patch, reason, via string) (string, error)
Propose records an immutable review request; approval rechecks its base revision.
func (Service) ProposeCreate ¶ added in v0.3.0
func (s Service) ProposeCreate(ctx context.Context, p auth.Principal, o Object, baseRev int64, reason, via string) (string, error)
ProposeCreate 先校验候选对象;审批时在落库事务中再次校验。
func (Service) ProposeDelete ¶
func (Service) PutContext ¶
func (s Service) PutContext(ctx context.Context, p auth.Principal, id string, rev int64, body string, expires time.Time, reason, via string) error
PutContext only permits keys to create or renew their own records.
func (Service) RecordNote ¶
func (Service) RestoreHost ¶ added in v0.3.0
type ServiceDetail ¶
type ServiceDetail struct {
Object Object `json:"service"`
Host Object `json:"host"`
IPs []Object `json:"ips"`
Ports []Object `json:"ports"`
Endpoints []Object `json:"endpoints"`
Versions []Object `json:"versions"`
Dependencies []Object `json:"dependencies"`
Credentials []Object `json:"credentials"`
Notes []Object `json:"notes"`
Changes []Object `json:"changes"`
}
type Store ¶
func (Store) ArchiveExpired ¶
ArchiveExpired keeps context rows but hides them from active queries.
func (Store) Create ¶
Create validates and inserts an object atomically. Actor is supplied by the caller's auth layer.
type ValidationError ¶ added in v0.3.0
type ValidationError struct {
Fields []FieldError `json:"fields"`
// contains filtered or unexported fields
}
func (*ValidationError) Error ¶ added in v0.3.0
func (e *ValidationError) Error() string
func (*ValidationError) Is ¶ added in v0.3.0
func (e *ValidationError) Is(target error) bool