Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ettec committed Dec 16, 2024
1 parent b403079 commit 6e30294
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 47 deletions.
14 changes: 14 additions & 0 deletions pkg/capabilities/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ type RemoteTargetConfig struct {

type RemoteExecutableConfig struct {
RequestHashExcludedAttributes []string
RegistrationRefresh time.Duration
RegistrationExpiry time.Duration
}

// NOTE: consider splitting this config into values stored in Registry (KS-118)
Expand All @@ -375,6 +377,18 @@ func (c *RemoteTriggerConfig) ApplyDefaults() {
}
}

func (c *RemoteExecutableConfig) ApplyDefaults() {
if c == nil {
return
}
if c.RegistrationRefresh == 0 {
c.RegistrationRefresh = DefaultRegistrationRefresh
}
if c.RegistrationExpiry == 0 {
c.RegistrationExpiry = DefaultRegistrationExpiry
}
}

type CapabilityConfiguration struct {
DefaultConfig *values.Map
RemoteTriggerConfig *RemoteTriggerConfig
Expand Down
122 changes: 75 additions & 47 deletions pkg/capabilities/pb/registry.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/capabilities/pb/registry.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ message RemoteExecutableConfig {
// when calculating the hash of the request. This is useful for excluding attributes that are not deterministic to ensure
// that the hash of logically identical requests is consistent.
repeated string requestHashExcludedAttributes = 1;
google.protobuf.Duration registrationRefresh = 2;
google.protobuf.Duration registrationExpiry = 3;
}

message CapabilityConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func (cr *capabilitiesRegistryClient) ConfigForCapability(ctx context.Context, c
prtc := res.CapabilityConfig.GetRemoteExecutableConfig()
remoteExecutableConfig = &capabilities.RemoteExecutableConfig{}
remoteExecutableConfig.RequestHashExcludedAttributes = prtc.RequestHashExcludedAttributes
remoteExecutableConfig.RegistrationRefresh = prtc.RegistrationRefresh.AsDuration()
remoteExecutableConfig.RegistrationExpiry = prtc.RegistrationExpiry.AsDuration()
}

return capabilities.CapabilityConfiguration{
Expand Down Expand Up @@ -352,6 +354,16 @@ func (c *capabilitiesRegistryServer) ConfigForCapability(ctx context.Context, re
}
}

if cc.RemoteExecutableConfig != nil {
ccp.RemoteConfig = &capabilitiespb.CapabilityConfig_RemoteExecutableConfig{
RemoteExecutableConfig: &capabilitiespb.RemoteExecutableConfig{
RequestHashExcludedAttributes: cc.RemoteExecutableConfig.RequestHashExcludedAttributes,
RegistrationRefresh: durationpb.New(cc.RemoteExecutableConfig.RegistrationRefresh),
RegistrationExpiry: durationpb.New(cc.RemoteExecutableConfig.RegistrationExpiry),
},
}
}

return &pb.ConfigForCapabilityReply{
CapabilityConfig: ccp,
}, nil
Expand Down

0 comments on commit 6e30294

Please sign in to comment.