Apply target related updates

This commit is contained in:
Chris Roberts 2021-04-19 16:45:50 -07:00 committed by Paul Hinze
parent 37c2e3fd51
commit 40361a2160
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
4 changed files with 109 additions and 58 deletions

View File

@ -14,7 +14,7 @@ type Project struct {
// These should _roughly_ map to existing Vagrantfile configurations
Vagrant *Vagrant `hcl:"vagrant,block"`
Machines []*Machine `hcl:"machine,block"`
Targets []*Target `hcl:"machine,block"`
Communicators []*Communicator `hcl:"communicator,block"`
Body hcl.Body `hcl:",body"`

View File

@ -4,9 +4,8 @@ import (
"github.com/hashicorp/hcl/v2"
)
type Machine struct {
type Target struct {
Name string `hcl:"name,label"`
Box string `hcl:"box,label"`
Body hcl.Body `hcl:",body"`
Remain hcl.Body `hcl:",remain"`

View File

@ -14,17 +14,18 @@ import (
"github.com/hashicorp/vagrant-plugin-sdk/component"
"github.com/hashicorp/vagrant-plugin-sdk/datadir"
"github.com/hashicorp/vagrant-plugin-sdk/proto/vagrant_plugin_sdk"
"github.com/hashicorp/vagrant-plugin-sdk/terminal"
"github.com/hashicorp/vagrant/internal/server/proto/vagrant_server"
)
type Machine struct {
type Target struct {
name string
resourceid string
project *Project
logger hclog.Logger
config *config.Machine
dir *datadir.Machine
config *config.Target
dir *datadir.Target
labels map[string]string
overrideLabels map[string]string
@ -33,12 +34,12 @@ type Machine struct {
UI terminal.UI
}
func (m *Machine) Ui() terminal.UI {
return m.UI
func (t *Target) Ui() terminal.UI {
return t.UI
}
func (m *Machine) Ref() interface{} {
return &vagrant_server.Ref_Machine{
func (t *Target) Ref() interface{} {
return &vagrant_plugin_sdk.Ref_Target{
ResourceId: m.resourceid,
Name: m.name,
Project: m.project.Ref().(*vagrant_server.Ref_Project),

View File

@ -4,6 +4,7 @@ package hashicorp.vagrant;
option go_package = "github.com/hashicorp/vagrant/internal/server/proto/vagrant_server";
import "google/protobuf/any.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "google/rpc/status.proto";
@ -187,42 +188,20 @@ message Basis {
// Unique resource identifier (internal use)
string resource_id = 1;
// Name for this basis (the path for now)
// Name for this basis
string name = 2;
// Path to this basis
string path = 3;
// Projects within this basis
repeated Ref.Project projects = 4;
// If true, then the `-remote` flag or the `vagrant build project/app`
// syntax can be used with a remote runner. If this is false, then
// this is not allowed. This is typically configured using the
// `runner {}` block in the vagrant config.
bool remote_enabled = 5;
// Custom metadata
map<string, string> metadata = 5;
// Where data is sourced for remote operations. If this isn't set, then
// there is no default data source and it will be an error if a job is
// queued for this project without a data source set. This is usually
// set using the `runner {}` block in the vagrant config.
Job.DataSource data_source = 6;
}
message Project {
// Unique resource identifier (internal use)
string resource_id = 1;
// Name of this project (the path for now)
string name = 2;
// Path where this project lives
string path = 3;
// Machines associated with this project
repeated Ref.Machine machines = 4;
// The basis which this project is within
Ref.Basis basis = 5;
// TODO(spox): look back over these options and see if we
// still care about them (i'm thinking no)
// If true, then the `-remote` flag or the `vagrant build project/app`
// syntax can be used with a remote runner. If this is false, then
@ -237,36 +216,110 @@ message Project {
Job.DataSource data_source = 7;
}
message Project {
// Unique resource identifier
string resource_id = 1;
// Name of this project
string name = 2;
// Path where this project lives
string path = 3;
// Targets associated with this project
repeated Ref.Target targets = 4;
// The basis which this project is within
Ref.Basis basis = 5;
// Custom metadata
map<string, string> metadata = 6;
// Serialized configuration of the project (Vagrantfile)
google.protobuf.Any configuration = 7;
// TODO(spox): look back over these options and see if we
// still care about them (i'm thinking no)
// If true, then the `-remote` flag or the `vagrant build project/app`
// syntax can be used with a remote runner. If this is false, then
// this is not allowed. This is typically configured using the
// `runner {}` block in the vagrant config.
bool remote_enabled = 8;
// Where data is sourced for remote operations. If this isn't set, then
// there is no default data source and it will be an error if a job is
// queued for this project without a data source set. This is usually
// set using the `runner {}` block in the vagrant config.
Job.DataSource data_source = 9;
}
message Target {
// Unique resource identifier
string resource_id = 1;
// Data directory for target specific files
sdk.Args.DataDir.Target datadir = 2;
// Name of the target
string name = 3;
// Project the target is associated
Ref.Project project = 4;
// Status of the target
Status status = 5;
// Targets contained within this target
repeated Target subtargets = 6;
// Parent if this target is a subtarget
Target parent = 7;
// Public unique identifier for target
string uuid = 8;
// Custom metadata
map<string, string> metadata = 9;
// Serialized configuration of the target (Vagrantfile)
google.protobuf.Any configuration = 10;
// Specialized target information (from provider)
google.protobuf.Any record = 11;
// TODO(spox): look back over these options and see if we
// still care about them (i'm thinking no)
// If true, then the `-remote` flag or the `vagrant build project/app`
// syntax can be used with a remote runner. If this is false, then
// this is not allowed. This is typically configured using the
// `runner {}` block in the vagrant config.
bool remote_enabled = 12;
// Where data is sourced for remote operations. If this isn't set, then
// there is no default data source and it will be an error if a job is
// queued for this project without a data source set. This is usually
// set using the `runner {}` block in the vagrant config.
Job.DataSource data_source = 13;
}
message Machine {
sdk.Args.DataDir.Machine datadir = 1;
// Unique resource identifier (internal use)
string resource_id = 2;
// ID of machine as assigned by provider
string id = 3;
// Name of the machine
string name = 4;
// Project the machine is associated
Ref.Project project = 5;
// status of the machine
Status status = 6;
string id = 1;
// Box information for guest
sdk.Args.Box box = 7;
// Public unique identifier for machine
string uuid = 8;
// User ID of machine creator
string uid = 9;
// State of the machine (Vagrant representation)
sdk.Args.MachineState state = 10;
// Provider name backing machine
string provider = 11;
Operation.PhysicalState physical_state = 50;
// If true, then the `-remote` flag or the `vagrant build project/app`
@ -280,8 +333,6 @@ message Machine {
// queued for this project without a data source set. This is usually
// set using the `runner {}` block in the vagrant config.
Job.DataSource data_source = 52;
string provider = 53;
}
/********************************************************************