From 08d4438ae1e3e6a64179f8707eb0e3a8cdafbfa3 Mon Sep 17 00:00:00 2001 From: sophia Date: Thu, 7 Oct 2021 14:09:26 -0500 Subject: [PATCH] Start Synced folder service --- plugins/commands/serve/service.rb | 2 + .../serve/service/synced_folder_service.rb | 79 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 plugins/commands/serve/service/synced_folder_service.rb diff --git a/plugins/commands/serve/service.rb b/plugins/commands/serve/service.rb index 385a1f058..6310c86f6 100644 --- a/plugins/commands/serve/service.rb +++ b/plugins/commands/serve/service.rb @@ -7,6 +7,8 @@ module VagrantPlugins autoload :HostService, Vagrant.source_root.join("plugins/commands/serve/service/host_service").to_s autoload :InternalService, Vagrant.source_root.join("plugins/commands/serve/service/internal_service").to_s autoload :ProviderService, Vagrant.source_root.join("plugins/commands/serve/service/provider_service").to_s + autoload :SyncedFolderService, Vagrant.source_root.join("plugins/commands/serve/service/synced_folder_service").to_s + class ServiceInfo # @return [String] Name of requested plugin diff --git a/plugins/commands/serve/service/synced_folder_service.rb b/plugins/commands/serve/service/synced_folder_service.rb new file mode 100644 index 000000000..5696f295b --- /dev/null +++ b/plugins/commands/serve/service/synced_folder_service.rb @@ -0,0 +1,79 @@ +require 'google/protobuf/well_known_types' + +module VagrantPlugins + module CommandServe + module Service + class SyncedFolderService < SDK::SyncedFolderService::Service + + include CapabilityPlatformService + + def initialize(*args, **opts, &block) + caps = Vagrant.plugin("2").manager.synced_folder_capabilities + default_args = [ + # Always get a target to pass the synced folder capability + SDK::FuncSpec::Value.new( + type: "hashicorp.vagrant.sdk.Args.Target", + name: "", + ), + ] + initialize_capability_platform!(caps, default_args) + end + + def usable_spec(*_) + SDK::FuncSpec.new( + name: "usable_spec", + args: [ + SDK::FuncSpec::Value.new( + type: "hashicorp.vagrant.sdk.Args.Target.Machine", + name: "", + ) + ], + result: [ + SDK::FuncSpec::Value.new( + type: "hashicorp.vagrant.sdk.SyncedFolder.UsableResp", + name: "", + ), + ], + ) + end + + def usable(req, ctx) + with_info(ctx) do |info| + # TODO + end + end + + def enable_spec(*_) + SDK::FuncSpec.new( + name: "enable_spec", + args: [ + SDK::FuncSpec::Value.new( + type: "hashicorp.vagrant.sdk.Args.Target.Machine", + name: "", + ), + SDK::FuncSpec::Value.new( + type: "hashicorp.vagrant.sdk.Args.OptionsHash", + name: "", + ), + #TODO + ], + result: [ + SDK::FuncSpec::Value.new( + type: "hashicorp.vagrant.sdk.SyncedFolder.UsableResp", + name: "", + ), + ], + ) + end + + def enable(req, ctx) + with_info(ctx) do |info| + # TODO + end + end + + + end + end + end +end