match

package
v1.13.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package match provides matching presets and utils for selecting devstack components.

Matchers can be composed, e.g.: - `And(OpGeth, WithLabel("name", "alice"))` to select the op-geth node named "alice". - `Or(OpGeth, OpReth)` to select an op-geth or op-reth node. - `Not(OpGeth)` to select anything but an op-geth node.

Custom matchers can also be implemented: - MatchFn can filter a list of elements down to just the matched elements - MatchElemFn can filter by checking each individual element

For convenience, aliases for common matchers are also provided, e.g. for matching "chain A", or matching the first L2 EL node.

Index

Constants

View Source
const (
	LabelVendor = "vendor"
)

Variables

View Source
var FirstCluster = First[stack.ClusterID, stack.Cluster]()
View Source
var FirstFaucet = First[stack.FaucetID, stack.Faucet]()
View Source
var FirstL1Network = First[stack.L1NetworkID, stack.L1Network]()
View Source
var FirstL2Batcher = First[stack.L2BatcherID, stack.L2Batcher]()
View Source
var FirstL2Challenger = First[stack.L2ChallengerID, stack.L2Challenger]()
View Source
var FirstL2Network = First[stack.L2NetworkID, stack.L2Network]()
View Source
var FirstL2Proposer = First[stack.L2ProposerID, stack.L2Proposer]()
View Source
var FirstSequencer = First[stack.SequencerID, stack.Sequencer]()
View Source
var FirstSuperchain = First[stack.SuperchainID, stack.Superchain]()
View Source
var FirstSupervisor = First[stack.SupervisorID, stack.Supervisor]()

L2ChainA is an alias for the first L2 network.

L2ChainB is an alias for the second L2 network.

Functions

func And

func And[I comparable, E stack.Identifiable[I]](matchers ...stack.Matcher[I, E]) stack.Matcher[I, E]

And combines all the matchers, by running them all, narrowing down the set with each application. If none are provided, all inputs are matched.

func Assume

func Assume[I comparable, E stack.Identifiable[I]](t devtest.T, inner stack.Matcher[I, E]) stack.Matcher[I, E]

Assume skips the test if no elements were matched with the inner matcher

func ByIndex

func ByIndex[I comparable, E stack.Identifiable[I]](index int) stack.Matcher[I, E]

ByIndex matches element i (zero-indexed).

func First

func First[I comparable, E stack.Identifiable[I]]() stack.Matcher[I, E]

func Last

func Last[I comparable, E stack.Identifiable[I]]() stack.Matcher[I, E]

Last matches the last element.

func Not

func Not[I comparable, E stack.Identifiable[I]](matcher stack.Matcher[I, E]) stack.Matcher[I, E]

Not matches the elements that do not match the given matcher.

func Only

func Only[I comparable, E stack.Identifiable[I]]() stack.Matcher[I, E]

Only matches the only value. If there are none, or more than one, then no value is matched.

func Or

func Or[I comparable, E stack.Identifiable[I]](matchers ...stack.Matcher[I, E]) stack.Matcher[I, E]

Or returns each of the inputs that have a match with any of the matchers. All inputs are applied to all matchers, even if matched previously.

func Second

func Second[I comparable, E stack.Identifiable[I]]() stack.Matcher[I, E]

func WithLabel

func WithLabel[I comparable, E interface {
	stack.Identifiable[I]
	Label(key string) string
}](key, value string) stack.Matcher[I, E]

Types

type L2ELVendor

type L2ELVendor string
const (
	OpReth L2ELVendor = "op-reth"
	OpGeth L2ELVendor = "op-geth"
	Proxyd L2ELVendor = "proxyd"
)

func (L2ELVendor) Match

func (v L2ELVendor) Match(elems []stack.L2ELNode) []stack.L2ELNode

func (L2ELVendor) String

func (v L2ELVendor) String() string

type MatchElemFn

type MatchElemFn[I comparable, E stack.Identifiable[I]] func(elem E) bool

MatchElemFn implements stack.Matcher, checking one element at a time.

func (MatchElemFn[I, E]) Match

func (m MatchElemFn[I, E]) Match(elems []E) (out []E)

func (MatchElemFn[I, E]) String

func (m MatchElemFn[I, E]) String() string

type MatchFn

type MatchFn[I comparable, E stack.Identifiable[I]] func(elems []E) []E

MatchFn implements stack.Matcher, checking all elements at once.

func (MatchFn[I, E]) Match

func (m MatchFn[I, E]) Match(elems []E) []E

func (MatchFn[I, E]) String

func (m MatchFn[I, E]) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL