feat(contracts)!: requests no longer name their org; the State Store derives it from the caller
This commit is contained in:
1 parent
2501e1301c
commit
7aec66b2d3
31 files changed
+149
-253
No files matched your search
@@ -654,7 +654,7 @@ func (b *boot) buildDaemon() {
|
||||
if principals, ok := b.stateStore.(access.PrincipalSource); ok {
|
||||
b.d.Principals = principals
|
||||
}
|
||||
if denials, ok := b.stateStore.(access.DenialStore); ok {
|
||||
if denials, ok := b.stateStore.(access.DenialRecorder); ok {
|
||||
b.d.Denials = denials
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ func (e *forgeExtensions) open(ctx context.Context, typ, instance, host, token s
|
||||
if !ok || !setting.Enabled {
|
||||
return nil, false
|
||||
}
|
||||
installed, err := e.source.Packages.ListInstalled(ctx, extension.OrgID)
|
||||
installed, err := e.source.Packages.ListInstalled(ctx)
|
||||
if err != nil {
|
||||
e.log.Warn("forge extensions: installed packages unavailable", "err", err)
|
||||
return nil, false
|
||||
|
||||
@@ -36,7 +36,7 @@ func openExtensionChannels(ctx context.Context, source extension.Source, secrets
|
||||
log.Warn("channel extensions unavailable: extension settings", "err", err)
|
||||
return nil
|
||||
}
|
||||
installed, err := source.Packages.ListInstalled(ctx, extension.OrgID)
|
||||
installed, err := source.Packages.ListInstalled(ctx)
|
||||
if err != nil {
|
||||
log.Warn("channel extensions unavailable: installed packages", "err", err)
|
||||
return nil
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
)
|
||||
|
||||
type messagingControlPlane struct{ client pb.ControlPlaneServiceClient }
|
||||
@@ -47,7 +46,7 @@ func (c messagingControlPlane) Catalog(ctx context.Context) ([]messaging.Setting
|
||||
}
|
||||
|
||||
func (c messagingControlPlane) Query(ctx context.Context, kind string) (messaging.SettingResource, error) {
|
||||
response, err := c.client.Query(ctx, controlplanerpc.QueryRequest(ctx, kind))
|
||||
response, err := c.client.Query(ctx, &pb.QueryRequest{Kind: kind})
|
||||
if err != nil {
|
||||
return messaging.SettingResource{}, settingsRPCError(err)
|
||||
}
|
||||
@@ -63,7 +62,7 @@ func (c messagingControlPlane) Command(ctx context.Context, command messaging.Se
|
||||
if err != nil {
|
||||
return messaging.SettingResource{}, errors.Join(messaging.ErrSettingsValidation, err)
|
||||
}
|
||||
response, err := c.client.Command(ctx, controlplanerpc.CommandRequest(ctx, &pb.CommandRequest{Kind: command.Kind, Command: "replace", ValueJson: value, ExpectedVersion: command.ExpectedVersion, RequestId: command.RequestID, Actor: command.Actor, Source: command.Source}))
|
||||
response, err := c.client.Command(ctx, &pb.CommandRequest{Kind: command.Kind, Command: "replace", ValueJson: value, ExpectedVersion: command.ExpectedVersion, RequestId: command.RequestID, Actor: command.Actor, Source: command.Source})
|
||||
if err != nil {
|
||||
return messaging.SettingResource{}, settingsRPCError(err)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ type deps struct {
|
||||
// Wired together or not at all.
|
||||
Access *infraaccess.Live
|
||||
Principals access.PrincipalSource
|
||||
Denials access.DenialStore
|
||||
Denials access.DenialRecorder
|
||||
}
|
||||
|
||||
// compose builds the dashboard server from contract-backed dependencies.
|
||||
@@ -61,7 +61,7 @@ func compose(d deps) *webui.Server {
|
||||
if snapshots, ok := d.Store.(storecontract.ConfigSnapshotStore); ok {
|
||||
srv.ConfigSource = webui.RemoteConfigView(snapshots)
|
||||
}
|
||||
if packages, ok := d.Store.(storepkg.Manager); ok {
|
||||
if packages, ok := d.Store.(storepkg.Installations); ok {
|
||||
srv.Packages = packages
|
||||
}
|
||||
if steps, ok := d.Store.(storecontract.StepReader); ok {
|
||||
|
||||
@@ -57,7 +57,7 @@ func (c *Client) Catalog(ctx context.Context) ([]*pb.ResourceDescriptor, error)
|
||||
}
|
||||
|
||||
func (c *WorkflowDefinitionsClient) WorkflowDefinitions(ctx context.Context) (workflow.WorkflowDefinitionCollection, int64, error) {
|
||||
response, err := c.rpc.Query(ctx, controlplanerpc.QueryRequest(ctx, WorkflowDefinitionsKind))
|
||||
response, err := c.rpc.Query(ctx, &pb.QueryRequest{Kind: WorkflowDefinitionsKind})
|
||||
if err != nil {
|
||||
return workflow.WorkflowDefinitionCollection{}, 0, controlplanerpc.ClientError(err)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func (c *WorkflowDefinitionsClient) ReplaceWorkflowDefinitions(ctx context.Conte
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
response, err := c.rpc.Command(ctx, controlplanerpc.CommandRequest(ctx, &pb.CommandRequest{Kind: WorkflowDefinitionsKind, Command: "replace", ValueJson: value, ExpectedVersion: expectedVersion, Actor: actor, Source: source, RequestId: requestID}))
|
||||
response, err := c.rpc.Command(ctx, &pb.CommandRequest{Kind: WorkflowDefinitionsKind, Command: "replace", ValueJson: value, ExpectedVersion: expectedVersion, Actor: actor, Source: source, RequestId: requestID})
|
||||
if err != nil {
|
||||
return 0, controlplanerpc.ClientError(err)
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func (c *WorkflowDefinitionsClient) ReplaceWorkflowDefinitions(ctx context.Conte
|
||||
}
|
||||
|
||||
func (c *Client) WorkflowExecutionSettings(ctx context.Context) (workflow.ExecutionSettings, int64, error) {
|
||||
response, err := c.rpc.Query(ctx, controlplanerpc.QueryRequest(ctx, WorkflowExecutionSettingsKind))
|
||||
response, err := c.rpc.Query(ctx, &pb.QueryRequest{Kind: WorkflowExecutionSettingsKind})
|
||||
if err != nil {
|
||||
return workflow.ExecutionSettings{}, 0, controlplanerpc.ClientError(err)
|
||||
}
|
||||
@@ -96,7 +96,7 @@ func (c *Client) ReplaceWorkflowExecutionSettings(ctx context.Context, settings
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
response, err := c.rpc.Command(ctx, controlplanerpc.CommandRequest(ctx, &pb.CommandRequest{Kind: WorkflowExecutionSettingsKind, Command: "replace", ValueJson: value, ExpectedVersion: expectedVersion, Actor: actor, Source: source, RequestId: requestID}))
|
||||
response, err := c.rpc.Command(ctx, &pb.CommandRequest{Kind: WorkflowExecutionSettingsKind, Command: "replace", ValueJson: value, ExpectedVersion: expectedVersion, Actor: actor, Source: source, RequestId: requestID})
|
||||
if err != nil {
|
||||
return 0, controlplanerpc.ClientError(err)
|
||||
}
|
||||
@@ -104,7 +104,7 @@ func (c *Client) ReplaceWorkflowExecutionSettings(ctx context.Context, settings
|
||||
}
|
||||
|
||||
func (c *Client) WatchWorkflowExecutionSettings(ctx context.Context, afterVersion int64) (<-chan AppliedSettings, error) {
|
||||
stream, err := c.rpc.Watch(ctx, controlplanerpc.WatchRequest(ctx, WorkflowExecutionSettingsKind, afterVersion))
|
||||
stream, err := c.rpc.Watch(ctx, &pb.WatchRequest{Kind: WorkflowExecutionSettingsKind, AfterVersion: afterVersion})
|
||||
if err != nil {
|
||||
return nil, controlplanerpc.ClientError(err)
|
||||
}
|
||||
@@ -125,7 +125,7 @@ type AppliedResource struct {
|
||||
// WatchResource streams version updates for a resource kind without decoding
|
||||
// documents.
|
||||
func (c *Client) WatchResource(ctx context.Context, kind string, afterVersion int64) (<-chan AppliedResource, error) {
|
||||
stream, err := c.rpc.Watch(ctx, controlplanerpc.WatchRequest(ctx, kind, afterVersion))
|
||||
stream, err := c.rpc.Watch(ctx, &pb.WatchRequest{Kind: kind, AfterVersion: afterVersion})
|
||||
if err != nil {
|
||||
return nil, controlplanerpc.ClientError(err)
|
||||
}
|
||||
@@ -141,7 +141,7 @@ type AppliedSettings struct {
|
||||
}
|
||||
|
||||
func (c *Client) Personas(ctx context.Context) (agent.PersonaCollection, int64, error) {
|
||||
response, err := c.rpc.Query(ctx, controlplanerpc.QueryRequest(ctx, PersonasKind))
|
||||
response, err := c.rpc.Query(ctx, &pb.QueryRequest{Kind: PersonasKind})
|
||||
if err != nil {
|
||||
return agent.PersonaCollection{}, 0, controlplanerpc.ClientError(err)
|
||||
}
|
||||
@@ -156,7 +156,7 @@ type AppliedPersonas struct {
|
||||
}
|
||||
|
||||
func (c *Client) WatchPersonas(ctx context.Context, afterVersion int64) (<-chan AppliedPersonas, error) {
|
||||
stream, err := c.rpc.Watch(ctx, controlplanerpc.WatchRequest(ctx, PersonasKind, afterVersion))
|
||||
stream, err := c.rpc.Watch(ctx, &pb.WatchRequest{Kind: PersonasKind, AfterVersion: afterVersion})
|
||||
if err != nil {
|
||||
return nil, controlplanerpc.ClientError(err)
|
||||
}
|
||||
@@ -208,7 +208,7 @@ func sendUpdate[T any](ctx context.Context, out chan<- T, update T) bool {
|
||||
}
|
||||
|
||||
func (c *Client) Schedules(ctx context.Context) ([]scheduling.JobSpec, int64, error) {
|
||||
response, err := c.rpc.Query(ctx, controlplanerpc.QueryRequest(ctx, SchedulesKind))
|
||||
response, err := c.rpc.Query(ctx, &pb.QueryRequest{Kind: SchedulesKind})
|
||||
if err != nil {
|
||||
return nil, 0, controlplanerpc.ClientError(err)
|
||||
}
|
||||
@@ -224,7 +224,7 @@ func (c *Client) ReplaceSchedules(ctx context.Context, jobs []scheduling.JobSpec
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
response, err := c.rpc.Command(ctx, controlplanerpc.CommandRequest(ctx, &pb.CommandRequest{Kind: SchedulesKind, Command: "replace", ValueJson: value, ExpectedVersion: expectedVersion, Actor: actor, Source: source, RequestId: requestID}))
|
||||
response, err := c.rpc.Command(ctx, &pb.CommandRequest{Kind: SchedulesKind, Command: "replace", ValueJson: value, ExpectedVersion: expectedVersion, Actor: actor, Source: source, RequestId: requestID})
|
||||
if err != nil {
|
||||
return 0, controlplanerpc.ClientError(err)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func (l *LivePlaybooks) current(ctx context.Context) *playbook.Store {
|
||||
defer l.mu.Unlock()
|
||||
ctx, cancel := context.WithTimeout(ctx, playbookQueryTimeout)
|
||||
defer cancel()
|
||||
response, err := l.rpc.Query(ctx, controlplanerpc.QueryRequest(ctx, PlaybooksKind))
|
||||
response, err := l.rpc.Query(ctx, &pb.QueryRequest{Kind: PlaybooksKind})
|
||||
if err != nil {
|
||||
l.log.Warn("eda playbooks unavailable; keeping the last good set", "err", controlplanerpc.ClientError(err))
|
||||
return l.store
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
@@ -27,7 +28,7 @@ func workflowEnablementDefinition() Definition {
|
||||
|
||||
// WorkflowEnablement returns which workflows each org has disabled.
|
||||
func (c *Client) WorkflowEnablement(ctx context.Context) (task.WorkflowEnablement, error) {
|
||||
response, err := c.rpc.Query(ctx, controlplanerpc.QueryRequest(ctx, WorkflowEnablementKind))
|
||||
response, err := c.rpc.Query(ctx, &controlpb.QueryRequest{Kind: WorkflowEnablementKind})
|
||||
if err != nil {
|
||||
return task.WorkflowEnablement{}, controlplanerpc.ClientError(err)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
)
|
||||
|
||||
// The audit identity every offline rollback records. A rollback is one more
|
||||
@@ -146,7 +145,7 @@ func replayRevision(ctx context.Context, resources controlplane.ResourceStore, o
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
replaced, err := server.Command(ctx, controlplanerpc.CommandRequest(ctx, &pb.CommandRequest{
|
||||
replaced, err := server.Command(ctx, &pb.CommandRequest{
|
||||
Kind: options.Kind,
|
||||
Command: "replace",
|
||||
ValueJson: revision.Value,
|
||||
@@ -154,7 +153,7 @@ func replayRevision(ctx context.Context, resources controlplane.ResourceStore, o
|
||||
Actor: OfflineRollbackActor,
|
||||
Source: OfflineRollbackSource,
|
||||
RequestId: fmt.Sprintf("recovery-rollback-%s-%d", options.Kind, time.Now().UTC().UnixNano()),
|
||||
}))
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("replay %s at revision %d: %w", options.Kind, revision.Version, err)
|
||||
}
|
||||
|
||||
@@ -283,12 +283,11 @@ func (x *Resource) GetOrgId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Every request that names a resource acts in one org's copy of it. An empty
|
||||
// org_id is the default org.
|
||||
// Every request that names a resource acts in one org's copy of it: the org
|
||||
// the State Store derives from the caller's principal, else the default org.
|
||||
type QueryRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"`
|
||||
OrgId string `protobuf:"bytes,2,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -330,13 +329,6 @@ func (x *QueryRequest) GetKind() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *QueryRequest) GetOrgId() string {
|
||||
if x != nil {
|
||||
return x.OrgId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type QueryResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"`
|
||||
@@ -472,8 +464,7 @@ type HistoryRequest struct {
|
||||
Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"`
|
||||
// Limit caps the revisions returned, newest first. Zero means the server's
|
||||
// own default.
|
||||
Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||
OrgId string `protobuf:"bytes,3,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
|
||||
Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -522,13 +513,6 @@ func (x *HistoryRequest) GetLimit() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *HistoryRequest) GetOrgId() string {
|
||||
if x != nil {
|
||||
return x.OrgId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type HistoryResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Revisions []*Revision `protobuf:"bytes,1,rep,name=revisions,proto3" json:"revisions,omitempty"`
|
||||
@@ -810,7 +794,6 @@ type CommandRequest struct {
|
||||
// from browser/request JSON.
|
||||
Actor string `protobuf:"bytes,6,opt,name=actor,proto3" json:"actor,omitempty"`
|
||||
Source string `protobuf:"bytes,7,opt,name=source,proto3" json:"source,omitempty"`
|
||||
OrgId string `protobuf:"bytes,8,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -894,13 +877,6 @@ func (x *CommandRequest) GetSource() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CommandRequest) GetOrgId() string {
|
||||
if x != nil {
|
||||
return x.OrgId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CommandResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"`
|
||||
@@ -949,7 +925,6 @@ type WatchRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"`
|
||||
AfterVersion int64 `protobuf:"varint,2,opt,name=after_version,json=afterVersion,proto3" json:"after_version,omitempty"`
|
||||
OrgId string `protobuf:"bytes,3,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -998,13 +973,6 @@ func (x *WatchRequest) GetAfterVersion() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WatchRequest) GetOrgId() string {
|
||||
if x != nil {
|
||||
return x.OrgId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type WatchResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"`
|
||||
@@ -1083,10 +1051,9 @@ const file_controlplane_v1_controlplane_proto_rawDesc = "" +
|
||||
"value_json\x18\x03 \x01(\fR\tvalueJson\x129\n" +
|
||||
"\n" +
|
||||
"updated_at\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\x12\x15\n" +
|
||||
"\x06org_id\x18\x05 \x01(\tR\x05orgId\"9\n" +
|
||||
"\x06org_id\x18\x05 \x01(\tR\x05orgId\"0\n" +
|
||||
"\fQueryRequest\x12\x12\n" +
|
||||
"\x04kind\x18\x01 \x01(\tR\x04kind\x12\x15\n" +
|
||||
"\x06org_id\x18\x02 \x01(\tR\x05orgId\"F\n" +
|
||||
"\x04kind\x18\x01 \x01(\tR\x04kindJ\x04\b\x02\x10\x03R\x06org_id\"F\n" +
|
||||
"\rQueryResponse\x125\n" +
|
||||
"\bresource\x18\x01 \x01(\v2\x19.controlplane.v1.ResourceR\bresource\"\xbc\x01\n" +
|
||||
"\bRevision\x12\x18\n" +
|
||||
@@ -1097,11 +1064,10 @@ const file_controlplane_v1_controlplane_proto_rawDesc = "" +
|
||||
"\x06source\x18\x04 \x01(\tR\x06source\x12\x1d\n" +
|
||||
"\n" +
|
||||
"request_id\x18\x05 \x01(\tR\trequestId\x12*\n" +
|
||||
"\x02at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\x02at\"Q\n" +
|
||||
"\x02at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\x02at\"H\n" +
|
||||
"\x0eHistoryRequest\x12\x12\n" +
|
||||
"\x04kind\x18\x01 \x01(\tR\x04kind\x12\x14\n" +
|
||||
"\x05limit\x18\x02 \x01(\x05R\x05limit\x12\x15\n" +
|
||||
"\x06org_id\x18\x03 \x01(\tR\x05orgId\"J\n" +
|
||||
"\x05limit\x18\x02 \x01(\x05R\x05limitJ\x04\b\x03\x10\x04R\x06org_id\"J\n" +
|
||||
"\x0fHistoryResponse\x127\n" +
|
||||
"\trevisions\x18\x01 \x03(\v2\x19.controlplane.v1.RevisionR\trevisions\"\xc6\x02\n" +
|
||||
"\n" +
|
||||
@@ -1124,7 +1090,7 @@ const file_controlplane_v1_controlplane_proto_rawDesc = "" +
|
||||
"\x05kinds\x18\x04 \x03(\tR\x05kinds\x12\x14\n" +
|
||||
"\x05limit\x18\x03 \x01(\x05R\x05limitJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03R\x05tableR\vrecord_keys\"F\n" +
|
||||
"\rAuditResponse\x125\n" +
|
||||
"\aentries\x18\x01 \x03(\v2\x1b.controlplane.v1.AuditEntryR\aentries\"\xec\x01\n" +
|
||||
"\aentries\x18\x01 \x03(\v2\x1b.controlplane.v1.AuditEntryR\aentries\"\xe3\x01\n" +
|
||||
"\x0eCommandRequest\x12\x12\n" +
|
||||
"\x04kind\x18\x01 \x01(\tR\x04kind\x12\x18\n" +
|
||||
"\acommand\x18\x02 \x01(\tR\acommand\x12\x1d\n" +
|
||||
@@ -1134,14 +1100,12 @@ const file_controlplane_v1_controlplane_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"request_id\x18\x05 \x01(\tR\trequestId\x12\x14\n" +
|
||||
"\x05actor\x18\x06 \x01(\tR\x05actor\x12\x16\n" +
|
||||
"\x06source\x18\a \x01(\tR\x06source\x12\x15\n" +
|
||||
"\x06org_id\x18\b \x01(\tR\x05orgId\"H\n" +
|
||||
"\x06source\x18\a \x01(\tR\x06sourceJ\x04\b\b\x10\tR\x06org_id\"H\n" +
|
||||
"\x0fCommandResponse\x125\n" +
|
||||
"\bresource\x18\x01 \x01(\v2\x19.controlplane.v1.ResourceR\bresource\"^\n" +
|
||||
"\bresource\x18\x01 \x01(\v2\x19.controlplane.v1.ResourceR\bresource\"U\n" +
|
||||
"\fWatchRequest\x12\x12\n" +
|
||||
"\x04kind\x18\x01 \x01(\tR\x04kind\x12#\n" +
|
||||
"\rafter_version\x18\x02 \x01(\x03R\fafterVersion\x12\x15\n" +
|
||||
"\x06org_id\x18\x03 \x01(\tR\x05orgId\"\\\n" +
|
||||
"\rafter_version\x18\x02 \x01(\x03R\fafterVersionJ\x04\b\x03\x10\x04R\x06org_id\"\\\n" +
|
||||
"\rWatchResponse\x125\n" +
|
||||
"\bresource\x18\x01 \x01(\v2\x19.controlplane.v1.ResourceR\bresource\x12\x14\n" +
|
||||
"\x05error\x18\x02 \x01(\tR\x05error2\xd9\x03\n" +
|
||||
|
||||
@@ -11166,9 +11166,10 @@ func (x *PackageAuthority) GetEnv() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Package and denial requests act in the org the State Store derives from the
|
||||
// caller's principal, else the default org.
|
||||
type InstallPackageRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
OrgId string `protobuf:"bytes,1,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Reference string `protobuf:"bytes,3,opt,name=reference,proto3" json:"reference,omitempty"`
|
||||
Digest string `protobuf:"bytes,4,opt,name=digest,proto3" json:"digest,omitempty"`
|
||||
@@ -11206,13 +11207,6 @@ func (*InstallPackageRequest) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_state_proto_rawDescGZIP(), []int{202}
|
||||
}
|
||||
|
||||
func (x *InstallPackageRequest) GetOrgId() string {
|
||||
if x != nil {
|
||||
return x.OrgId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InstallPackageRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
@@ -11280,7 +11274,6 @@ func (x *InstallPackageResponse) GetPackage() *InstalledPackage {
|
||||
|
||||
type GetInstalledPackageRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
OrgId string `protobuf:"bytes,1,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -11316,13 +11309,6 @@ func (*GetInstalledPackageRequest) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_state_proto_rawDescGZIP(), []int{204}
|
||||
}
|
||||
|
||||
func (x *GetInstalledPackageRequest) GetOrgId() string {
|
||||
if x != nil {
|
||||
return x.OrgId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetInstalledPackageRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
@@ -11376,7 +11362,6 @@ func (x *GetInstalledPackageResponse) GetPackage() *InstalledPackage {
|
||||
|
||||
type ListInstalledPackagesRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
OrgId string `protobuf:"bytes,1,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -11411,13 +11396,6 @@ func (*ListInstalledPackagesRequest) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_state_proto_rawDescGZIP(), []int{206}
|
||||
}
|
||||
|
||||
func (x *ListInstalledPackagesRequest) GetOrgId() string {
|
||||
if x != nil {
|
||||
return x.OrgId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ListInstalledPackagesResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Packages []*InstalledPackage `protobuf:"bytes,1,rep,name=packages,proto3" json:"packages,omitempty"`
|
||||
@@ -11464,7 +11442,6 @@ func (x *ListInstalledPackagesResponse) GetPackages() []*InstalledPackage {
|
||||
|
||||
type AcceptPackageAuthorityRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
OrgId string `protobuf:"bytes,1,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Accepted *PackageAuthority `protobuf:"bytes,3,opt,name=accepted,proto3" json:"accepted,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
@@ -11501,13 +11478,6 @@ func (*AcceptPackageAuthorityRequest) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_state_proto_rawDescGZIP(), []int{208}
|
||||
}
|
||||
|
||||
func (x *AcceptPackageAuthorityRequest) GetOrgId() string {
|
||||
if x != nil {
|
||||
return x.OrgId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AcceptPackageAuthorityRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
@@ -11568,7 +11538,6 @@ func (x *AcceptPackageAuthorityResponse) GetPackage() *InstalledPackage {
|
||||
|
||||
type RemoveInstalledPackageRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
OrgId string `protobuf:"bytes,1,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -11604,13 +11573,6 @@ func (*RemoveInstalledPackageRequest) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_state_proto_rawDescGZIP(), []int{210}
|
||||
}
|
||||
|
||||
func (x *RemoveInstalledPackageRequest) GetOrgId() string {
|
||||
if x != nil {
|
||||
return x.OrgId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RemoveInstalledPackageRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
@@ -12479,7 +12441,6 @@ func (*RecordDenialResponse) Descriptor() ([]byte, []int) {
|
||||
|
||||
type ListDenialsRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
OrgId string `protobuf:"bytes,1,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
|
||||
Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -12515,13 +12476,6 @@ func (*ListDenialsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_state_proto_rawDescGZIP(), []int{228}
|
||||
}
|
||||
|
||||
func (x *ListDenialsRequest) GetOrgId() string {
|
||||
if x != nil {
|
||||
return x.OrgId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ListDenialsRequest) GetLimit() int32 {
|
||||
if x != nil {
|
||||
return x.Limit
|
||||
@@ -13325,32 +13279,27 @@ const file_state_v1_state_proto_rawDesc = "" +
|
||||
"\x11forge_permissions\x18\x03 \x03(\tR\x10forgePermissions\x12\x1a\n" +
|
||||
"\btriggers\x18\x04 \x03(\tR\btriggers\x12\x14\n" +
|
||||
"\x05tools\x18\x05 \x03(\tR\x05tools\x12\x10\n" +
|
||||
"\x03env\x18\x06 \x03(\tR\x03env\"x\n" +
|
||||
"\x15InstallPackageRequest\x12\x15\n" +
|
||||
"\x06org_id\x18\x01 \x01(\tR\x05orgId\x12\x12\n" +
|
||||
"\x03env\x18\x06 \x03(\tR\x03env\"o\n" +
|
||||
"\x15InstallPackageRequest\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04name\x12\x1c\n" +
|
||||
"\treference\x18\x03 \x01(\tR\treference\x12\x16\n" +
|
||||
"\x06digest\x18\x04 \x01(\tR\x06digest\"N\n" +
|
||||
"\x06digest\x18\x04 \x01(\tR\x06digestJ\x04\b\x01\x10\x02R\x06org_id\"N\n" +
|
||||
"\x16InstallPackageResponse\x124\n" +
|
||||
"\apackage\x18\x01 \x01(\v2\x1a.state.v1.InstalledPackageR\apackage\"G\n" +
|
||||
"\x1aGetInstalledPackageRequest\x12\x15\n" +
|
||||
"\x06org_id\x18\x01 \x01(\tR\x05orgId\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04name\"S\n" +
|
||||
"\apackage\x18\x01 \x01(\v2\x1a.state.v1.InstalledPackageR\apackage\">\n" +
|
||||
"\x1aGetInstalledPackageRequest\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04nameJ\x04\b\x01\x10\x02R\x06org_id\"S\n" +
|
||||
"\x1bGetInstalledPackageResponse\x124\n" +
|
||||
"\apackage\x18\x01 \x01(\v2\x1a.state.v1.InstalledPackageR\apackage\"5\n" +
|
||||
"\x1cListInstalledPackagesRequest\x12\x15\n" +
|
||||
"\x06org_id\x18\x01 \x01(\tR\x05orgId\"W\n" +
|
||||
"\apackage\x18\x01 \x01(\v2\x1a.state.v1.InstalledPackageR\apackage\",\n" +
|
||||
"\x1cListInstalledPackagesRequestJ\x04\b\x01\x10\x02R\x06org_id\"W\n" +
|
||||
"\x1dListInstalledPackagesResponse\x126\n" +
|
||||
"\bpackages\x18\x01 \x03(\v2\x1a.state.v1.InstalledPackageR\bpackages\"\x82\x01\n" +
|
||||
"\x1dAcceptPackageAuthorityRequest\x12\x15\n" +
|
||||
"\x06org_id\x18\x01 \x01(\tR\x05orgId\x12\x12\n" +
|
||||
"\bpackages\x18\x01 \x03(\v2\x1a.state.v1.InstalledPackageR\bpackages\"y\n" +
|
||||
"\x1dAcceptPackageAuthorityRequest\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04name\x126\n" +
|
||||
"\baccepted\x18\x03 \x01(\v2\x1a.state.v1.PackageAuthorityR\baccepted\"V\n" +
|
||||
"\baccepted\x18\x03 \x01(\v2\x1a.state.v1.PackageAuthorityR\bacceptedJ\x04\b\x01\x10\x02R\x06org_id\"V\n" +
|
||||
"\x1eAcceptPackageAuthorityResponse\x124\n" +
|
||||
"\apackage\x18\x01 \x01(\v2\x1a.state.v1.InstalledPackageR\apackage\"J\n" +
|
||||
"\x1dRemoveInstalledPackageRequest\x12\x15\n" +
|
||||
"\x06org_id\x18\x01 \x01(\tR\x05orgId\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04name\" \n" +
|
||||
"\apackage\x18\x01 \x01(\v2\x1a.state.v1.InstalledPackageR\apackage\"A\n" +
|
||||
"\x1dRemoveInstalledPackageRequest\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04nameJ\x04\b\x01\x10\x02R\x06org_id\" \n" +
|
||||
"\x1eRemoveInstalledPackageResponse\"6\n" +
|
||||
"\x13GetPrincipalRequest\x12\x1f\n" +
|
||||
"\videntity_id\x18\x01 \x01(\tR\n" +
|
||||
@@ -13401,10 +13350,9 @@ const file_state_v1_state_proto_rawDesc = "" +
|
||||
"\x02at\x18\t \x01(\v2\x1a.google.protobuf.TimestampR\x02at\"E\n" +
|
||||
"\x13RecordDenialRequest\x12.\n" +
|
||||
"\x06denial\x18\x01 \x01(\v2\x16.state.v1.AccessDenialR\x06denial\"\x16\n" +
|
||||
"\x14RecordDenialResponse\"A\n" +
|
||||
"\x12ListDenialsRequest\x12\x15\n" +
|
||||
"\x06org_id\x18\x01 \x01(\tR\x05orgId\x12\x14\n" +
|
||||
"\x05limit\x18\x02 \x01(\x05R\x05limit\"G\n" +
|
||||
"\x14RecordDenialResponse\"8\n" +
|
||||
"\x12ListDenialsRequest\x12\x14\n" +
|
||||
"\x05limit\x18\x02 \x01(\x05R\x05limitJ\x04\b\x01\x10\x02R\x06org_id\"G\n" +
|
||||
"\x13ListDenialsResponse\x120\n" +
|
||||
"\adenials\x18\x01 \x03(\v2\x16.state.v1.AccessDenialR\adenials2\xe2B\n" +
|
||||
"\x11StateStoreService\x12S\n" +
|
||||
|
||||
@@ -117,7 +117,7 @@ type Daemon struct {
|
||||
// identity. Wired with Access or not at all.
|
||||
Principals access.PrincipalSource
|
||||
// Denials records dispatch refusals. Optional: nil skips the record.
|
||||
Denials access.DenialStore
|
||||
Denials access.DenialRecorder
|
||||
Forge forge.Forge
|
||||
Trees *worktree.Manager
|
||||
Bus *events.Bus
|
||||
|
||||
@@ -41,13 +41,17 @@ type Resetter interface {
|
||||
ResetInstancePolicies(ctx context.Context) error
|
||||
}
|
||||
|
||||
// DenialRecorder records one refusal with the level that decided it and the
|
||||
// deciding policies.
|
||||
type DenialRecorder interface {
|
||||
RecordDenial(ctx context.Context, d Denial) error
|
||||
}
|
||||
|
||||
// DenialStore records and lists denial records. The store coalesces
|
||||
// identical denials within a minute into one row with a count, so a retry
|
||||
// storm does not flood the surface.
|
||||
type DenialStore interface {
|
||||
// RecordDenial records one refusal with the level that decided it and
|
||||
// the deciding policies.
|
||||
RecordDenial(ctx context.Context, d Denial) error
|
||||
DenialRecorder
|
||||
// ListDenials returns an org's most recent denials, newest first.
|
||||
ListDenials(ctx context.Context, orgID org.OrgID, limit int) ([]Denial, error)
|
||||
}
|
||||
@@ -62,6 +62,16 @@ type Manager interface {
|
||||
AcceptPackageAuthority(ctx context.Context, orgID, name string, accepted Authority) (Installed, error)
|
||||
}
|
||||
|
||||
// Installations is Manager as a remote caller sees it: the State Store acts
|
||||
// in the caller's org, so no method names one.
|
||||
type Installations interface {
|
||||
InstallPackage(ctx context.Context, name, reference, digest string) (Installed, error)
|
||||
GetInstalled(ctx context.Context, name string) (Installed, error)
|
||||
ListInstalled(ctx context.Context) ([]Installed, error)
|
||||
RemoveInstalled(ctx context.Context, name string) error
|
||||
AcceptPackageAuthority(ctx context.Context, name string, accepted Authority) (Installed, error)
|
||||
}
|
||||
|
||||
// Service validates the registry content before persisting an installation.
|
||||
type Service struct {
|
||||
Registry Registry
|
||||
|
||||
@@ -50,7 +50,7 @@ type ResourceReader interface {
|
||||
}
|
||||
|
||||
func (c *Client) Query(ctx context.Context, kind string, decode func([]byte) error) (int64, bool, error) {
|
||||
response, err := c.rpc.Query(ctx, QueryRequest(ctx, kind))
|
||||
response, err := c.rpc.Query(ctx, &pb.QueryRequest{Kind: kind})
|
||||
if err != nil {
|
||||
mapped := ClientError(err)
|
||||
if errors.Is(mapped, ErrNotFound) {
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package controlplanerpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
)
|
||||
|
||||
// Requests carry the org from the context (org.WithOrg), defaulting to the
|
||||
// default org.
|
||||
|
||||
// QueryRequest builds a resource query for the caller's org.
|
||||
func QueryRequest(ctx context.Context, kind string) *pb.QueryRequest {
|
||||
return &pb.QueryRequest{Kind: kind, OrgId: string(org.OrgFromContext(ctx))}
|
||||
}
|
||||
|
||||
// HistoryRequest builds an audit-history request for the caller's org.
|
||||
func HistoryRequest(ctx context.Context, kind string) *pb.HistoryRequest {
|
||||
return &pb.HistoryRequest{Kind: kind, OrgId: string(org.OrgFromContext(ctx))}
|
||||
}
|
||||
|
||||
// WatchRequest builds a resource watch for the caller's org.
|
||||
func WatchRequest(ctx context.Context, kind string, afterVersion int64) *pb.WatchRequest {
|
||||
return &pb.WatchRequest{Kind: kind, AfterVersion: afterVersion, OrgId: string(org.OrgFromContext(ctx))}
|
||||
}
|
||||
|
||||
// CommandRequest stamps the caller's org onto a command request the caller
|
||||
// assembled, whose remaining fields differ per command.
|
||||
func CommandRequest(ctx context.Context, request *pb.CommandRequest) *pb.CommandRequest {
|
||||
request.OrgId = string(org.OrgFromContext(ctx))
|
||||
return request
|
||||
}
|
||||
@@ -14,13 +14,10 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
)
|
||||
|
||||
// OrgID is the single-operator install's org, the one packages are installed in.
|
||||
const OrgID = "default"
|
||||
|
||||
// Packages reads installed packages, as *staterpc.Client does.
|
||||
type Packages interface {
|
||||
ListInstalled(ctx context.Context, orgID string) ([]storepkg.Installed, error)
|
||||
GetInstalled(ctx context.Context, orgID, name string) (storepkg.Installed, error)
|
||||
ListInstalled(ctx context.Context) ([]storepkg.Installed, error)
|
||||
GetInstalled(ctx context.Context, name string) (storepkg.Installed, error)
|
||||
}
|
||||
|
||||
// Source is what an extension supervisor reads: the extension-settings
|
||||
@@ -55,7 +52,7 @@ func (s Source) Enabled(ctx context.Context) (map[string]controlplanerpc.Extensi
|
||||
// package digest, and returns its path and sha256. A binary already there for
|
||||
// this digest is reused.
|
||||
func Materialize(ctx context.Context, packages Packages, cacheDir string, pkg storepkg.Installed, file string) (string, string, error) {
|
||||
full, err := packages.GetInstalled(ctx, OrgID, pkg.Name)
|
||||
full, err := packages.GetInstalled(ctx, pkg.Name)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("get installed package: %w", err)
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func (r *Runner) Sync(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (r *Runner) apply(ctx context.Context, settings map[string]controlplanerpc.ExtensionSetting) error {
|
||||
installed, err := r.source.Packages.ListInstalled(ctx, extension.OrgID)
|
||||
installed, err := r.source.Packages.ListInstalled(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("list installed packages: %w", err)
|
||||
}
|
||||
|
||||
@@ -126,13 +126,13 @@ func (f *fakeSource) Query(_ context.Context, _ string, decode func([]byte) erro
|
||||
return 1, true, decode(raw)
|
||||
}
|
||||
|
||||
func (f *fakeSource) ListInstalled(context.Context, string) ([]storepkg.Installed, error) {
|
||||
func (f *fakeSource) ListInstalled(context.Context) ([]storepkg.Installed, error) {
|
||||
listed := f.pkg
|
||||
listed.Layer = nil
|
||||
return []storepkg.Installed{listed}, nil
|
||||
}
|
||||
|
||||
func (f *fakeSource) GetInstalled(context.Context, string, string) (storepkg.Installed, error) {
|
||||
func (f *fakeSource) GetInstalled(context.Context, string) (storepkg.Installed, error) {
|
||||
return f.pkg, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
// The Client satisfies the access contracts the two callers depend on.
|
||||
var (
|
||||
_ access.PolicyStore = (*Client)(nil)
|
||||
_ access.DenialStore = (*Client)(nil)
|
||||
_ access.DenialRecorder = (*Client)(nil)
|
||||
_ access.PrincipalSource = (*Client)(nil)
|
||||
)
|
||||
|
||||
@@ -76,15 +76,3 @@ func (c *Client) RecordDenial(ctx context.Context, d access.Denial) error {
|
||||
_, err := c.client.RecordDenial(ctx, &pb.RecordDenialRequest{Denial: accessDenialProto(d)})
|
||||
return unmapError(err)
|
||||
}
|
||||
|
||||
func (c *Client) ListDenials(ctx context.Context, orgID org.OrgID, limit int) ([]access.Denial, error) {
|
||||
r, err := c.client.ListDenials(ctx, &pb.ListDenialsRequest{OrgId: string(orgID), Limit: int32(limit)})
|
||||
if err != nil {
|
||||
return nil, unmapError(err)
|
||||
}
|
||||
out := make([]access.Denial, len(r.Denials))
|
||||
for i := range r.Denials {
|
||||
out[i] = accessDenialValue(r.Denials[i])
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
@@ -64,7 +64,7 @@ var (
|
||||
_ storecontract.CaptureRefusalStore = (*Client)(nil)
|
||||
_ storecontract.ExecutionCanceller = (*Client)(nil)
|
||||
_ identity.Repository = (*Client)(nil)
|
||||
_ storepkg.Manager = (*Client)(nil)
|
||||
_ storepkg.Installations = (*Client)(nil)
|
||||
)
|
||||
|
||||
// Lifecycle
|
||||
|
||||
@@ -70,24 +70,24 @@ func (s *server) RemoveInstalledPackage(ctx context.Context, request *pb.RemoveI
|
||||
return &pb.RemoveInstalledPackageResponse{}, nil
|
||||
}
|
||||
|
||||
func (c *Client) InstallPackage(ctx context.Context, orgID, name, reference, digest string) (storepkg.Installed, error) {
|
||||
response, err := c.client.InstallPackage(ctx, &pb.InstallPackageRequest{OrgId: orgID, Name: name, Reference: reference, Digest: digest})
|
||||
func (c *Client) InstallPackage(ctx context.Context, name, reference, digest string) (storepkg.Installed, error) {
|
||||
response, err := c.client.InstallPackage(ctx, &pb.InstallPackageRequest{Name: name, Reference: reference, Digest: digest})
|
||||
if err != nil {
|
||||
return storepkg.Installed{}, unmapError(err)
|
||||
}
|
||||
return packageValue(response.GetPackage())
|
||||
}
|
||||
|
||||
func (c *Client) GetInstalled(ctx context.Context, orgID, name string) (storepkg.Installed, error) {
|
||||
response, err := c.client.GetInstalledPackage(ctx, &pb.GetInstalledPackageRequest{OrgId: orgID, Name: name})
|
||||
func (c *Client) GetInstalled(ctx context.Context, name string) (storepkg.Installed, error) {
|
||||
response, err := c.client.GetInstalledPackage(ctx, &pb.GetInstalledPackageRequest{Name: name})
|
||||
if err != nil {
|
||||
return storepkg.Installed{}, unmapError(err)
|
||||
}
|
||||
return packageValue(response.GetPackage())
|
||||
}
|
||||
|
||||
func (c *Client) ListInstalled(ctx context.Context, orgID string) ([]storepkg.Installed, error) {
|
||||
response, err := c.client.ListInstalledPackages(ctx, &pb.ListInstalledPackagesRequest{OrgId: orgID})
|
||||
func (c *Client) ListInstalled(ctx context.Context) ([]storepkg.Installed, error) {
|
||||
response, err := c.client.ListInstalledPackages(ctx, &pb.ListInstalledPackagesRequest{})
|
||||
if err != nil {
|
||||
return nil, unmapError(err)
|
||||
}
|
||||
@@ -102,14 +102,14 @@ func (c *Client) ListInstalled(ctx context.Context, orgID string) ([]storepkg.In
|
||||
return packages, nil
|
||||
}
|
||||
|
||||
func (c *Client) RemoveInstalled(ctx context.Context, orgID, name string) error {
|
||||
_, err := c.client.RemoveInstalledPackage(ctx, &pb.RemoveInstalledPackageRequest{OrgId: orgID, Name: name})
|
||||
func (c *Client) RemoveInstalled(ctx context.Context, name string) error {
|
||||
_, err := c.client.RemoveInstalledPackage(ctx, &pb.RemoveInstalledPackageRequest{Name: name})
|
||||
return unmapError(err)
|
||||
}
|
||||
|
||||
func (c *Client) AcceptPackageAuthority(ctx context.Context, orgID, name string, accepted storepkg.Authority) (storepkg.Installed, error) {
|
||||
func (c *Client) AcceptPackageAuthority(ctx context.Context, name string, accepted storepkg.Authority) (storepkg.Installed, error) {
|
||||
response, err := c.client.AcceptPackageAuthority(ctx, &pb.AcceptPackageAuthorityRequest{
|
||||
OrgId: orgID, Name: name, Accepted: authorityProto(accepted),
|
||||
Name: name, Accepted: authorityProto(accepted),
|
||||
})
|
||||
if err != nil {
|
||||
return storepkg.Installed{}, unmapError(err)
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
)
|
||||
|
||||
type controlPlaneCommandRequest struct {
|
||||
@@ -64,7 +63,7 @@ func (s *Server) handleControlPlaneQuery(w http.ResponseWriter, r *http.Request)
|
||||
http.Error(w, "control plane unavailable", http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
response, err := s.ControlPlane.Query(r.Context(), controlplanerpc.QueryRequest(r.Context(), r.PathValue("kind")))
|
||||
response, err := s.ControlPlane.Query(r.Context(), &controlpb.QueryRequest{Kind: r.PathValue("kind")})
|
||||
if err != nil {
|
||||
writeControlPlaneError(w, err)
|
||||
return
|
||||
@@ -77,7 +76,7 @@ func (s *Server) handleControlPlaneHistory(w http.ResponseWriter, r *http.Reques
|
||||
http.Error(w, "control plane unavailable", http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
response, err := s.ControlPlane.History(r.Context(), controlplanerpc.HistoryRequest(r.Context(), r.PathValue("kind")))
|
||||
response, err := s.ControlPlane.History(r.Context(), &controlpb.HistoryRequest{Kind: r.PathValue("kind")})
|
||||
if err != nil {
|
||||
writeControlPlaneError(w, err)
|
||||
return
|
||||
@@ -112,11 +111,11 @@ func (s *Server) handleControlPlaneCommand(w http.ResponseWriter, r *http.Reques
|
||||
http.Error(w, "cannot create request ID", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
response, err := s.ControlPlane.Command(r.Context(), controlplanerpc.CommandRequest(r.Context(), &controlpb.CommandRequest{
|
||||
response, err := s.ControlPlane.Command(r.Context(), &controlpb.CommandRequest{
|
||||
Kind: r.PathValue("kind"), Command: r.PathValue("command"), ValueJson: request.Value,
|
||||
ExpectedVersion: request.ExpectedVersion, Actor: string(audit.ActorID),
|
||||
Source: audit.Source, RequestId: audit.RequestID,
|
||||
}))
|
||||
})
|
||||
if err != nil {
|
||||
writeControlPlaneError(w, err)
|
||||
return
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"strings"
|
||||
|
||||
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
"github.com/samcharles93/archie-core/internal/domain/storepkg"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
)
|
||||
@@ -75,7 +74,7 @@ func extensionView(p storepkg.Installed, enabled bool) ExtensionView {
|
||||
// replacement must name.
|
||||
func (s *Server) extensionSettings(ctx context.Context) (controlplanerpc.ExtensionSettings, int64, error) {
|
||||
var doc controlplanerpc.ExtensionSettings
|
||||
response, err := s.ControlPlane.Query(ctx, controlplanerpc.QueryRequest(ctx, controlplanerpc.ExtensionSettingsKind))
|
||||
response, err := s.ControlPlane.Query(ctx, &controlpb.QueryRequest{Kind: controlplanerpc.ExtensionSettingsKind})
|
||||
if err != nil {
|
||||
return doc, 0, err
|
||||
}
|
||||
@@ -98,10 +97,10 @@ func (s *Server) putExtensionSettings(ctx context.Context, doc controlplanerpc.E
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = s.ControlPlane.Command(ctx, controlplanerpc.CommandRequest(ctx, &controlpb.CommandRequest{
|
||||
_, err = s.ControlPlane.Command(ctx, &controlpb.CommandRequest{
|
||||
Kind: controlplanerpc.ExtensionSettingsKind, Command: "replace", ValueJson: value,
|
||||
ExpectedVersion: version, Actor: string(audit.ActorID), Source: audit.Source, RequestId: audit.RequestID,
|
||||
}))
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -152,7 +151,7 @@ func (s *Server) handleExtensions(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.extensionsReady(w) {
|
||||
return
|
||||
}
|
||||
installed, err := s.Packages.ListInstalled(r.Context(), string(org.OrgFromContext(r.Context())))
|
||||
installed, err := s.Packages.ListInstalled(r.Context())
|
||||
if err != nil {
|
||||
writePackageError(w, err)
|
||||
return
|
||||
@@ -190,7 +189,7 @@ func (s *Server) handleExtensionInstall(w http.ResponseWriter, r *http.Request)
|
||||
http.Error(w, "invalid request body", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
p, err := s.Packages.InstallPackage(r.Context(), string(org.OrgFromContext(r.Context())),
|
||||
p, err := s.Packages.InstallPackage(r.Context(),
|
||||
strings.TrimSpace(request.Name), strings.TrimSpace(request.Reference), strings.TrimSpace(request.Digest))
|
||||
if err != nil {
|
||||
writePackageError(w, err)
|
||||
@@ -205,13 +204,13 @@ func (s *Server) handleExtensionAccept(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.extensionsReady(w) {
|
||||
return
|
||||
}
|
||||
orgID, name := string(org.OrgFromContext(r.Context())), r.PathValue("name")
|
||||
installed, err := s.Packages.GetInstalled(r.Context(), orgID, name)
|
||||
name := r.PathValue("name")
|
||||
installed, err := s.Packages.GetInstalled(r.Context(), name)
|
||||
if err != nil {
|
||||
writePackageError(w, err)
|
||||
return
|
||||
}
|
||||
p, err := s.Packages.AcceptPackageAuthority(r.Context(), orgID, name, installed.Descriptor.Authority)
|
||||
p, err := s.Packages.AcceptPackageAuthority(r.Context(), name, installed.Descriptor.Authority)
|
||||
if err != nil {
|
||||
writePackageError(w, err)
|
||||
return
|
||||
@@ -234,7 +233,7 @@ func (s *Server) handleExtensionEnabled(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
name := r.PathValue("name")
|
||||
if _, err := s.Packages.GetInstalled(r.Context(), string(org.OrgFromContext(r.Context())), name); err != nil {
|
||||
if _, err := s.Packages.GetInstalled(r.Context(), name); err != nil {
|
||||
writePackageError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -257,7 +256,7 @@ func (s *Server) handleExtensionRemove(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
name := r.PathValue("name")
|
||||
if err := s.Packages.RemoveInstalled(r.Context(), string(org.OrgFromContext(r.Context())), name); err != nil {
|
||||
if err := s.Packages.RemoveInstalled(r.Context(), name); err != nil {
|
||||
writePackageError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
|
||||
"golang.org/x/net/websocket"
|
||||
|
||||
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
)
|
||||
|
||||
// The control-plane resources the harness page reads. The kinds are spelled
|
||||
@@ -101,7 +101,7 @@ func (s *Server) handleHarnessBindings(w http.ResponseWriter, r *http.Request) {
|
||||
// captured token state. A service with no captured set is not an error: it
|
||||
// is exactly the state the setup terminal exists to change.
|
||||
func (s *Server) harnessBindings(ctx context.Context, orgID string) ([]harnessBindingView, error) {
|
||||
response, err := s.ControlPlane.Query(ctx, controlplanerpc.QueryRequest(ctx, harnessBindingsKind))
|
||||
response, err := s.ControlPlane.Query(ctx, &controlpb.QueryRequest{Kind: harnessBindingsKind})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func (s *Server) harnessBindings(ctx context.Context, orgID string) ([]harnessBi
|
||||
// harnessProfiles returns the agent profiles that name a Kit, sorted so the
|
||||
// page's list does not depend on Go's map iteration order.
|
||||
func (s *Server) harnessProfiles(ctx context.Context) ([]string, error) {
|
||||
response, err := s.ControlPlane.Query(ctx, controlplanerpc.QueryRequest(ctx, harnessProfilesKind))
|
||||
response, err := s.ControlPlane.Query(ctx, &controlpb.QueryRequest{Kind: harnessProfilesKind})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
)
|
||||
|
||||
const workflowEnablementKind = "workflow-enablement"
|
||||
@@ -20,7 +19,7 @@ func (s *Server) workflowEnablement(ctx context.Context) (task.WorkflowEnablemen
|
||||
if s.ControlPlane == nil {
|
||||
return task.WorkflowEnablement{}, 0, nil
|
||||
}
|
||||
response, err := s.ControlPlane.Query(ctx, controlplanerpc.QueryRequest(ctx, workflowEnablementKind))
|
||||
response, err := s.ControlPlane.Query(ctx, &controlpb.QueryRequest{Kind: workflowEnablementKind})
|
||||
if err != nil {
|
||||
return task.WorkflowEnablement{}, 0, err
|
||||
}
|
||||
@@ -78,11 +77,11 @@ func (s *Server) handleWorkflowEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "cannot create request ID", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if _, err := s.ControlPlane.Command(r.Context(), controlplanerpc.CommandRequest(r.Context(), &controlpb.CommandRequest{
|
||||
if _, err := s.ControlPlane.Command(r.Context(), &controlpb.CommandRequest{
|
||||
Kind: workflowEnablementKind, Command: "replace", ValueJson: value,
|
||||
ExpectedVersion: version, Actor: string(audit.ActorID),
|
||||
Source: audit.Source, RequestId: audit.RequestID,
|
||||
})); err != nil {
|
||||
}); err != nil {
|
||||
writeControlPlaneError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
||||
"github.com/samcharles93/archie-core/internal/domain/org"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
|
||||
"github.com/samcharles93/archie-core/internal/events"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
)
|
||||
|
||||
const workflowDefinitionsKind = "workflow-definitions"
|
||||
@@ -153,7 +153,7 @@ func (s *Server) workflowCollection(ctx context.Context) (task.WorkflowDefinitio
|
||||
if s.ControlPlane == nil {
|
||||
return task.WorkflowDefinitionCollection{}, nil
|
||||
}
|
||||
response, err := s.ControlPlane.Query(ctx, controlplanerpc.QueryRequest(ctx, workflowDefinitionsKind))
|
||||
response, err := s.ControlPlane.Query(ctx, &controlpb.QueryRequest{Kind: workflowDefinitionsKind})
|
||||
if err != nil {
|
||||
return task.WorkflowDefinitionCollection{}, err
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
|
||||
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/domain/identity"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
|
||||
)
|
||||
|
||||
// liveUpdate is one topic's payload. Only durable tasks and the bounded log
|
||||
@@ -117,7 +116,7 @@ func (s *Server) watchResource(ctx context.Context, kind string) {
|
||||
for ctx.Err() == nil {
|
||||
started := time.Now()
|
||||
progressed := false
|
||||
stream, err := s.ControlPlane.Watch(ctx, controlplanerpc.WatchRequest(ctx, kind, version))
|
||||
stream, err := s.ControlPlane.Watch(ctx, &controlpb.WatchRequest{Kind: kind, AfterVersion: version})
|
||||
if err == nil {
|
||||
for ctx.Err() == nil {
|
||||
response, recvErr := stream.Recv()
|
||||
|
||||
@@ -82,7 +82,7 @@ type Server struct {
|
||||
|
||||
// Packages is the State Store's installed-package surface, behind the
|
||||
// extensions page. Nil answers 503.
|
||||
Packages storepkg.Manager
|
||||
Packages storepkg.Installations
|
||||
|
||||
// ApplyStatus reports which control-plane resource version each process
|
||||
// is running. Optional: nil renders an empty page rather than failing the
|
||||
@@ -123,7 +123,7 @@ type Server struct {
|
||||
// check as the only gate.
|
||||
Access access.Authorizer
|
||||
Principals access.PrincipalSource
|
||||
Denials access.DenialStore
|
||||
Denials access.DenialRecorder
|
||||
|
||||
// Events publishes operator actions so they reach the task timeline and
|
||||
// the live activity stream. Optional: nil means the action is recorded
|
||||
|
||||
@@ -38,11 +38,12 @@ message Resource {
|
||||
google.protobuf.Timestamp updated_at = 4;
|
||||
string org_id = 5;
|
||||
}
|
||||
// Every request that names a resource acts in one org's copy of it. An empty
|
||||
// org_id is the default org.
|
||||
// Every request that names a resource acts in one org's copy of it: the org
|
||||
// the State Store derives from the caller's principal, else the default org.
|
||||
message QueryRequest {
|
||||
string kind = 1;
|
||||
string org_id = 2;
|
||||
reserved 2;
|
||||
reserved "org_id";
|
||||
}
|
||||
message QueryResponse { Resource resource = 1; }
|
||||
|
||||
@@ -61,7 +62,8 @@ message HistoryRequest {
|
||||
// Limit caps the revisions returned, newest first. Zero means the server's
|
||||
// own default.
|
||||
int32 limit = 2;
|
||||
string org_id = 3;
|
||||
reserved 3;
|
||||
reserved "org_id";
|
||||
}
|
||||
message HistoryResponse { repeated Revision revisions = 1; }
|
||||
|
||||
@@ -102,14 +104,16 @@ message CommandRequest {
|
||||
// from browser/request JSON.
|
||||
string actor = 6;
|
||||
string source = 7;
|
||||
string org_id = 8;
|
||||
reserved 8;
|
||||
reserved "org_id";
|
||||
}
|
||||
message CommandResponse { Resource resource = 1; }
|
||||
|
||||
message WatchRequest {
|
||||
string kind = 1;
|
||||
int64 after_version = 2;
|
||||
string org_id = 3;
|
||||
reserved 3;
|
||||
reserved "org_id";
|
||||
}
|
||||
message WatchResponse {
|
||||
Resource resource = 1;
|
||||
|
||||
@@ -1163,24 +1163,39 @@ message PackageAuthority {
|
||||
repeated string tools = 5;
|
||||
repeated string env = 6;
|
||||
}
|
||||
// Package and denial requests act in the org the State Store derives from the
|
||||
// caller's principal, else the default org.
|
||||
message InstallPackageRequest {
|
||||
string org_id = 1;
|
||||
reserved 1;
|
||||
reserved "org_id";
|
||||
string name = 2;
|
||||
string reference = 3;
|
||||
string digest = 4;
|
||||
}
|
||||
message InstallPackageResponse { InstalledPackage package = 1; }
|
||||
message GetInstalledPackageRequest { string org_id = 1; string name = 2; }
|
||||
message GetInstalledPackageRequest {
|
||||
reserved 1;
|
||||
reserved "org_id";
|
||||
string name = 2;
|
||||
}
|
||||
message GetInstalledPackageResponse { InstalledPackage package = 1; }
|
||||
message ListInstalledPackagesRequest { string org_id = 1; }
|
||||
message ListInstalledPackagesRequest {
|
||||
reserved 1;
|
||||
reserved "org_id";
|
||||
}
|
||||
message ListInstalledPackagesResponse { repeated InstalledPackage packages = 1; }
|
||||
message AcceptPackageAuthorityRequest {
|
||||
string org_id = 1;
|
||||
reserved 1;
|
||||
reserved "org_id";
|
||||
string name = 2;
|
||||
PackageAuthority accepted = 3;
|
||||
}
|
||||
message AcceptPackageAuthorityResponse { InstalledPackage package = 1; }
|
||||
message RemoveInstalledPackageRequest { string org_id = 1; string name = 2; }
|
||||
message RemoveInstalledPackageRequest {
|
||||
reserved 1;
|
||||
reserved "org_id";
|
||||
string name = 2;
|
||||
}
|
||||
message RemoveInstalledPackageResponse {}
|
||||
|
||||
// Task mirrors internal/domain/workflow.Task.
|
||||
@@ -1235,5 +1250,9 @@ message AccessDenial {
|
||||
}
|
||||
message RecordDenialRequest { AccessDenial denial = 1; }
|
||||
message RecordDenialResponse {}
|
||||
message ListDenialsRequest { string org_id = 1; int32 limit = 2; }
|
||||
message ListDenialsRequest {
|
||||
reserved 1;
|
||||
reserved "org_id";
|
||||
int32 limit = 2;
|
||||
}
|
||||
message ListDenialsResponse { repeated AccessDenial denials = 1; }
|
||||
Reference in new issue
Block a user