Add Vagrantfile to proto data model

This commit is contained in:
sophia 2021-05-07 13:07:37 -05:00 committed by Paul Hinze
parent 71f3b99819
commit 3d25e71970
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
5 changed files with 62 additions and 41 deletions

View File

@ -55,36 +55,38 @@ message ParseVagrantfileRequest {
message ParseVagrantfileResponse {
// Vagrantfile representation
Vagrantfile vagrantfile = 1;
VagrantfileComponents.Vagrantfile vagrantfile = 1;
}
// TODO: Review what needs to be sent here
message Provisioner {
string name = 1;
google.protobuf.Any config = 2;
}
message VagrantfileComponents {
// TODO: Review what needs to be sent here
message Provisioner {
string name = 1;
google.protobuf.Any config = 2;
}
// TODO: Review what needs to be sent here
message MachineConfig {
string name = 1;
string box = 2;
repeated Provisioner provisioners = 3;
}
// TODO: Review what needs to be sent here
message MachineConfig {
string name = 1;
string box = 2;
repeated Provisioner provisioners = 3;
}
// TODO: Review what needs to be sent here
message Communicator {
string name = 1;
// This is the config that belongs to the communicator.
// Should be a message type from the core plugin or defined
// by a plugin author
google.protobuf.Any config = 2;
}
// TODO: Review what needs to be sent here
message Communicator {
string name = 1;
// This is the config that belongs to the communicator.
// Should be a message type from the core plugin or defined
// by a plugin author
google.protobuf.Any config = 2;
}
// TODO: Review what needs to be sent here
message Vagrantfile {
string path = 1;
string raw = 2;
string current_version = 3;
repeated MachineConfig machine_configs = 4;
repeated Communicator communicators = 5;
// TODO: Review what needs to be sent here
message Vagrantfile {
string path = 1;
string raw = 2;
string current_version = 3;
repeated MachineConfig machine_configs = 4;
repeated Communicator communicators = 5;
}
}

View File

@ -328,6 +328,17 @@ message Target {
Job.DataSource data_source = 101;
}
message Vagrantfile {
// Unique resource identifier (internal use)
string resource_id = 1;
// TODO: not sure about this path
// Path where this Vagarant lives
string path = 2;
// TODO: Determine Vagrantfile representation in DB
}
/********************************************************************
* Shared Messages
********************************************************************/

View File

@ -15,7 +15,7 @@ import (
type RubyVagrant interface {
GetPlugins() ([]*ruby_vagrant.Plugin, error)
ParseVagrantfile(string) (*ruby_vagrant.Vagrantfile, error)
ParseVagrantfile(string) (*ruby_vagrant.VagrantfileComponents_Vagrantfile, error)
}
// This is the implementation of plugin.GRPCPlugin so we can serve/consume this.
@ -65,7 +65,7 @@ func (r *RubyVagrantClient) GetPlugins() ([]*ruby_vagrant.Plugin, error) {
}
// TODO: This should return an hcl Vagrantfile representation
func (r *RubyVagrantClient) ParseVagrantfile(path string) (*ruby_vagrant.Vagrantfile, error) {
func (r *RubyVagrantClient) ParseVagrantfile(path string) (*ruby_vagrant.VagrantfileComponents_Vagrantfile, error) {
vf, err := r.client.ParseVagrantfile(
context.Background(),
&ruby_vagrant.ParseVagrantfileRequest{Path: path},

View File

@ -27,27 +27,29 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
optional :path, :string, 1
end
add_message "hashicorp.vagrant.ParseVagrantfileResponse" do
optional :vagrantfile, :message, 1, "hashicorp.vagrant.Vagrantfile"
optional :vagrantfile, :message, 1, "hashicorp.vagrant.VagrantfileComponents.Vagrantfile"
end
add_message "hashicorp.vagrant.Provisioner" do
add_message "hashicorp.vagrant.VagrantfileComponents" do
end
add_message "hashicorp.vagrant.VagrantfileComponents.Provisioner" do
optional :name, :string, 1
optional :config, :message, 2, "google.protobuf.Any"
end
add_message "hashicorp.vagrant.MachineConfig" do
add_message "hashicorp.vagrant.VagrantfileComponents.MachineConfig" do
optional :name, :string, 1
optional :box, :string, 2
repeated :provisioners, :message, 3, "hashicorp.vagrant.Provisioner"
repeated :provisioners, :message, 3, "hashicorp.vagrant.VagrantfileComponents.Provisioner"
end
add_message "hashicorp.vagrant.Communicator" do
add_message "hashicorp.vagrant.VagrantfileComponents.Communicator" do
optional :name, :string, 1
optional :config, :message, 2, "google.protobuf.Any"
end
add_message "hashicorp.vagrant.Vagrantfile" do
add_message "hashicorp.vagrant.VagrantfileComponents.Vagrantfile" do
optional :path, :string, 1
optional :raw, :string, 2
optional :current_version, :string, 3
repeated :machine_configs, :message, 4, "hashicorp.vagrant.MachineConfig"
repeated :communicators, :message, 5, "hashicorp.vagrant.Communicator"
repeated :machine_configs, :message, 4, "hashicorp.vagrant.VagrantfileComponents.MachineConfig"
repeated :communicators, :message, 5, "hashicorp.vagrant.VagrantfileComponents.Communicator"
end
end
end
@ -59,9 +61,10 @@ module Hashicorp
Plugin::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Plugin.Type").enummodule
ParseVagrantfileRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.ParseVagrantfileRequest").msgclass
ParseVagrantfileResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.ParseVagrantfileResponse").msgclass
Provisioner = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Provisioner").msgclass
MachineConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.MachineConfig").msgclass
Communicator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Communicator").msgclass
Vagrantfile = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Vagrantfile").msgclass
VagrantfileComponents = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.VagrantfileComponents").msgclass
VagrantfileComponents::Provisioner = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.VagrantfileComponents.Provisioner").msgclass
VagrantfileComponents::MachineConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.VagrantfileComponents.MachineConfig").msgclass
VagrantfileComponents::Communicator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.VagrantfileComponents.Communicator").msgclass
VagrantfileComponents::Vagrantfile = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.VagrantfileComponents.Vagrantfile").msgclass
end
end

View File

@ -55,6 +55,10 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
optional :data_source, :message, 52, "hashicorp.vagrant.Job.DataSource"
optional :provider, :string, 53
end
add_message "hashicorp.vagrant.Vagrantfile" do
optional :resource_id, :string, 1
optional :path, :string, 2
end
add_message "hashicorp.vagrant.Ref" do
end
add_message "hashicorp.vagrant.Ref.Machine" do
@ -851,6 +855,7 @@ module Hashicorp
Basis = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Basis").msgclass
Project = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Project").msgclass
Machine = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Machine").msgclass
Vagrantfile = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Vagrantfile").msgclass
Ref = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Ref").msgclass
Ref::Machine = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Ref.Machine").msgclass
Ref::Project = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.Ref.Project").msgclass