Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion go.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ flowchart LR
capabilities/integration_tests --> chainlink/v2
capabilities/integration_tests --> cre-sdk-go/capabilities/blockchain/evm
click capabilities/integration_tests href "https://github.com/smartcontractkit/capabilities"
capabilities/libs --> chainlink-common
capabilities/libs --> chainlink-common/x/config
click capabilities/libs href "https://github.com/smartcontractkit/capabilities"
ccip-contract-examples/chains/evm
click ccip-contract-examples/chains/evm href "https://github.com/smartcontractkit/ccip-contract-examples"
Expand Down Expand Up @@ -101,6 +101,8 @@ flowchart LR
click chainlink-common/pkg/chipingress href "https://github.com/smartcontractkit/chainlink-common"
chainlink-common/pkg/monitoring
click chainlink-common/pkg/monitoring href "https://github.com/smartcontractkit/chainlink-common"
chainlink-common/x/config --> chainlink-common
click chainlink-common/x/config href "https://github.com/smartcontractkit/chainlink-common"
chainlink-data-streams --> chainlink-common/keystore
chainlink-data-streams --> chainlink-evm/gethwrappers
click chainlink-data-streams href "https://github.com/smartcontractkit/chainlink-data-streams"
Expand Down Expand Up @@ -265,6 +267,7 @@ flowchart LR
chainlink-common/keystore
chainlink-common/pkg/chipingress
chainlink-common/pkg/monitoring
chainlink-common/x/config
end
click chainlink-common-repo href "https://github.com/smartcontractkit/chainlink-common"

Expand Down
17 changes: 10 additions & 7 deletions libs/capability/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ type Capability interface {
Service() protoreflect.ServiceDescriptor
}

// capabilityConfig is what a capability binary needs from the node it runs beside.
type capabilityConfig struct {
ProxyURL string `usage:"gRPC target of the node's capability registry proxy (e.g. localhost:9000), used to resolve capabilities this binary does not host. Unset resolves only the capabilities this binary hosts"`
CapabilityDonID uint32 `usage:"on-chain DON ID of the capability DON this process was spawned for"`

// Serves the Debug UI
HTTPDebug bool `usage:"serve the capability debug UI on the shared HTTP server, under /debug/capabilities"`
// CapabilitiesConfig is what a capability binary needs from the node it runs beside.
type CapabilitiesConfig struct {
// ProxyURL is the gRPC target of the node's capability registry proxy (e.g. localhost:9000), used
// to resolve capabilities this binary does not host. Unset resolves only the capabilities this
// binary hosts.
ProxyURL string
// CapabilityDonID is the on-chain DON ID of the capability DON this process was spawned for.
CapabilityDonID uint32
// HTTPDebug serves the capability debug UI on the shared HTTP server, under /debug/capabilities.
HTTPDebug bool
}
55 changes: 31 additions & 24 deletions libs/capability/config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package capability

//go:generate go run ./internal/docgen

import (
"fmt"
"errors"

"github.com/spf13/cobra"

"github.com/smartcontractkit/chainlink-common/x/config/cli"
"github.com/smartcontractkit/chainlink-common/x/config/markup/tomlmarkup"
)

const capabilitiesNamespace = "capabilities"
Expand All @@ -14,41 +19,43 @@ const settingsNamespace = "settings"

const defaultHost = "localhost"

type grpcConfig struct {
AdvertiseHost string `usage:"host the gRPC servers this process opens bind to and are advertised at; empty binds every interface"`
// GRPCConfig configures the gRPC servers this process opens.
type GRPCConfig struct {
// AdvertiseHost is the host the gRPC servers this process opens bind to and are advertised at.
// Empty binds every interface.
AdvertiseHost string
}

// the standard configuration for a capability; does not include the config that a capability may request via its constructor.
type config struct {
observability observability
capabilities capabilityConfig
grpc grpcConfig
settings settingsConfig
capabilities CapabilitiesConfig
grpc GRPCConfig
settings SettingsConfig
}

func defaultConfig() *config {
return &config{
observability: *defaultObservability(),
grpc: grpcConfig{AdvertiseHost: defaultHost},
grpc: GRPCConfig{AdvertiseHost: defaultHost},
}
}

// namespaced pairs every config with the namespace it is registered under, in the order the flags
// are registered.
func (c *config) namespaced() []section {
return append(c.observability.namespaced(),
section{capabilitiesNamespace, &c.capabilities},
section{grpcNamespace, &c.grpc},
section{settingsNamespace, &c.settings},
)
}

// bind binds every config to root, each under the namespace that owns it.
func (c *config) bind(root *cobra.Command) error {
for _, s := range c.namespaced() {
if err := bindFlags(root, s.namespace, s.target); err != nil {
return fmt.Errorf("failed to register the %s settings: %w", s.namespace, err)
}
// bind binds every config to root, each under the namespace that owns it. Each is settable by
// flag, CRE_/CL_ env var, or config file, in that order of precedence, over its defaults.
func (c *config) bind(root *cobra.Command) (*cli.Binder, error) {
b, err := cli.New(cli.Options{Markup: tomlmarkup.New(), Prefixes: []string{"CRE", "CL"}})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing used this, I don't care about preservation.

if err != nil {
return nil, err
}
return nil
return b, errors.Join(
b.RegisterInNamespace(root, telemetryNamespace, &c.observability.telemetry),
b.RegisterInNamespace(root, tracingNamespace, &c.observability.tracing),
b.RegisterInNamespace(root, chipIngressNamespace, &c.observability.chipIngress),
b.RegisterInNamespace(root, pyroscopeNamespace, &c.observability.pyroscope),
b.RegisterInNamespace(root, httpNamespace, &c.observability.http),
b.RegisterInNamespace(root, capabilitiesNamespace, &c.capabilities),
b.RegisterInNamespace(root, grpcNamespace, &c.grpc),
b.RegisterInNamespace(root, settingsNamespace, &c.settings),
)
}
67 changes: 67 additions & 0 deletions libs/capability/doccomments_gen.go

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

182 changes: 0 additions & 182 deletions libs/capability/flags.go

This file was deleted.

Loading
Loading