Update mappers to include maps from funcspec value to proto
This commit is contained in:
parent
2513d21054
commit
3cc92280f8
@ -1,6 +1,39 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class NamedCapabilityProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.NamedCapability" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::NamedCapability,
|
||||
func: method(:converter),
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::NamedCapability.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
class NamedCapabilityFromProto < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [Input.new(type: SDK::Args::NamedCapability)],
|
||||
output: Symbol,
|
||||
func: method(:converter),
|
||||
)
|
||||
end
|
||||
|
||||
def converter(n)
|
||||
n.capability.to_s.to_sym
|
||||
end
|
||||
end
|
||||
|
||||
# Build a machine client from a FuncSpec value
|
||||
class NamedCapabilityFromSpec < Mapper
|
||||
def initialize
|
||||
|
||||
@ -2,7 +2,7 @@ module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
# Build a command arguments from a FuncSpec value
|
||||
class CommandArgumentsFromSpec < Mapper
|
||||
class CommandArgumentsProtoFromSpec < Mapper
|
||||
def initialize
|
||||
inputs = [].tap do |i|
|
||||
i << Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
|
||||
@ -1,6 +1,24 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class GuestProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.Guest" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::Guest,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::Guest.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
# Build a guest client from a FuncSpec value
|
||||
class GuestFromSpec < Mapper
|
||||
def initialize
|
||||
@ -33,21 +51,6 @@ module VagrantPlugins
|
||||
Client::Guest.load(proto, broker: broker)
|
||||
end
|
||||
end
|
||||
|
||||
# Build a guest client from a serialized proto string
|
||||
class GuestFromString < Mapper
|
||||
def initialize
|
||||
inputs = [].tap do |i|
|
||||
i << Input.new(type: String)
|
||||
i << Input.new(type: Broker)
|
||||
end
|
||||
super(inputs: inputs, output: Client::Guest, func: method(:converter))
|
||||
end
|
||||
|
||||
def converter(proto, broker)
|
||||
Client::Guest.load(proto, broker: broker)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class MachineProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.Target.Machine" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::Target::Machine,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::Target::Machine.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
# Build a machine client from a FuncSpec value
|
||||
class MachineFromSpec < Mapper
|
||||
def initialize
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class PathnameProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.Path" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::Path,
|
||||
func: method(:converter),
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::Path.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
class PathnameToProto < Mapper
|
||||
def initialize
|
||||
super(
|
||||
|
||||
@ -1,6 +1,24 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class ProjectProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.Project" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::Project,
|
||||
func: method(:converter),
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::Project.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
# Build a project client from a FuncSpec value
|
||||
class ProjectFromSpec < Mapper
|
||||
def initialize
|
||||
|
||||
@ -1,8 +1,44 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class StateBagProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.StateBag" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::StateBag,
|
||||
func: method(:converter),
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::StateBag.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
class StateBagFromProto < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: SDK::Args::StateBag),
|
||||
Input.new(type: Broker),
|
||||
],
|
||||
output: Client::StateBag,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(proto, broker)
|
||||
Client::StateBag.load(proto, broker)
|
||||
end
|
||||
end
|
||||
|
||||
# Extracts a statebag from a Funcspec value
|
||||
class StateBag < Mapper
|
||||
class StateBagFromSpec < Mapper
|
||||
def initialize
|
||||
inputs = [].tap do |i|
|
||||
i << Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class TargetProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.Target" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::Target,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::Target.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
# Build a target client from a FuncSpec value
|
||||
class TargetFromSpec < Mapper
|
||||
def initialize
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class TargetIndexProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.TargetIndex" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::TargetIndex,
|
||||
func: method(:converter)
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::TargetIndex.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
# Build a target index client from a FuncSpec value
|
||||
class TargetIndexFromSpec < Mapper
|
||||
def initialize
|
||||
|
||||
@ -1,6 +1,25 @@
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
class Mappers
|
||||
class TerminalProtoFromSpec < Mapper
|
||||
def initialize
|
||||
super(
|
||||
inputs: [
|
||||
Input.new(type: SDK::FuncSpec::Value) { |arg|
|
||||
arg.type == "hashicorp.vagrant.sdk.Args.TerminalUI" &&
|
||||
!arg&.value&.value.nil?
|
||||
}
|
||||
],
|
||||
output: SDK::Args::TerminalUI,
|
||||
func: method(:converter),
|
||||
)
|
||||
end
|
||||
|
||||
def converter(fv)
|
||||
SDK::Args::TerminalUI.decode(fv.value.value)
|
||||
end
|
||||
end
|
||||
|
||||
# Build a terminal client from a FuncSpec value
|
||||
class TerminalFromSpec < Mapper
|
||||
def initialize
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user