Commit d933e905 authored by Yann Hodique's avatar Yann Hodique Committed by GitHub

feat(kurtosis-devnet): expose the devnet features (#13802)

parent 316ed4b4
...@@ -49,4 +49,6 @@ type WalletMap map[string]Wallet ...@@ -49,4 +49,6 @@ type WalletMap map[string]Wallet
type DevnetEnvironment struct { type DevnetEnvironment struct {
L1 *Chain `json:"l1"` L1 *Chain `json:"l1"`
L2 []*Chain `json:"l2"` L2 []*Chain `json:"l2"`
Features []string `json:"features,omitempty"`
} }
...@@ -164,6 +164,7 @@ func (d *KurtosisDeployer) GetEnvironmentInfo(ctx context.Context, spec *spec.En ...@@ -164,6 +164,7 @@ func (d *KurtosisDeployer) GetEnvironmentInfo(ctx context.Context, spec *spec.En
env := &KurtosisEnvironment{ env := &KurtosisEnvironment{
DevnetEnvironment: descriptors.DevnetEnvironment{ DevnetEnvironment: descriptors.DevnetEnvironment{
L2: make([]*descriptors.Chain, 0, len(spec.Chains)), L2: make([]*descriptors.Chain, 0, len(spec.Chains)),
Features: spec.Features,
}, },
} }
......
...@@ -16,6 +16,7 @@ type ChainSpec struct { ...@@ -16,6 +16,7 @@ type ChainSpec struct {
// EnclaveSpec represents the parsed chain specifications from the YAML // EnclaveSpec represents the parsed chain specifications from the YAML
type EnclaveSpec struct { type EnclaveSpec struct {
Chains []ChainSpec Chains []ChainSpec
Features []string
} }
// NetworkParams represents the network parameters section in the YAML // NetworkParams represents the network parameters section in the YAML
...@@ -29,8 +30,14 @@ type ChainConfig struct { ...@@ -29,8 +30,14 @@ type ChainConfig struct {
NetworkParams NetworkParams `yaml:"network_params"` NetworkParams NetworkParams `yaml:"network_params"`
} }
// InteropConfig represents the interop section in the YAML
type InteropConfig struct {
Enabled bool `yaml:"enabled"`
}
// OptimismPackage represents the optimism_package section in the YAML // OptimismPackage represents the optimism_package section in the YAML
type OptimismPackage struct { type OptimismPackage struct {
Interop InteropConfig `yaml:"interop"`
Chains []ChainConfig `yaml:"chains"` Chains []ChainConfig `yaml:"chains"`
} }
...@@ -51,6 +58,16 @@ func NewSpec(opts ...SpecOption) *Spec { ...@@ -51,6 +58,16 @@ func NewSpec(opts ...SpecOption) *Spec {
return s return s
} }
type featureExtractor func(YAMLSpec, string) bool
var featuresMap = map[string]featureExtractor{
"interop": interopExtractor,
}
func interopExtractor(yamlSpec YAMLSpec, chainName string) bool {
return yamlSpec.OptimismPackage.Interop.Enabled
}
// ExtractData parses a YAML document and returns the chain specifications // ExtractData parses a YAML document and returns the chain specifications
func (s *Spec) ExtractData(r io.Reader) (*EnclaveSpec, error) { func (s *Spec) ExtractData(r io.Reader) (*EnclaveSpec, error) {
var yamlSpec YAMLSpec var yamlSpec YAMLSpec
...@@ -59,8 +76,16 @@ func (s *Spec) ExtractData(r io.Reader) (*EnclaveSpec, error) { ...@@ -59,8 +76,16 @@ func (s *Spec) ExtractData(r io.Reader) (*EnclaveSpec, error) {
return nil, fmt.Errorf("failed to decode YAML: %w", err) return nil, fmt.Errorf("failed to decode YAML: %w", err)
} }
var features []string
for feature, extractor := range featuresMap {
if extractor(yamlSpec, feature) {
features = append(features, feature)
}
}
result := &EnclaveSpec{ result := &EnclaveSpec{
Chains: make([]ChainSpec, 0, len(yamlSpec.OptimismPackage.Chains)), Chains: make([]ChainSpec, 0, len(yamlSpec.OptimismPackage.Chains)),
Features: features,
} }
// Extract chain specifications // Extract chain specifications
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment