Plug machine#uid methods into remote go backend

This commit is contained in:
sophia 2022-04-25 16:50:17 -05:00
parent 5ab49f33bc
commit b4fbf76a33
3 changed files with 14 additions and 10 deletions

View File

@ -2,6 +2,7 @@ package core
import (
"fmt"
"os/user"
"reflect"
"sort"
@ -38,6 +39,15 @@ func (m *Machine) ID() (id string, err error) {
// SetID implements core.Machine
func (m *Machine) SetID(value string) (err error) {
m.machine.Id = value
// Also set uid
user, err := user.Current()
if err != nil {
return err
}
m.machine.Uid = user.Uid
// Persist changes
if value == "" {
m.target.Record = nil
err = m.Destroy()

View File

@ -237,10 +237,7 @@ module Vagrant
end
def uid
path = uid_file
return nil if !path
return nil if !path.file?
return uid_file.read.chomp
client.uid
end
def with_ui(ui)
@ -255,11 +252,6 @@ module Vagrant
end
end
def uid_file
return nil if !@data_dir
@data_dir.join("creator_uid")
end
def check_cwd
desired_encoding = @env.root_path.to_s.encoding
vagrant_cwd_filepath = @data_dir.join('vagrant_cwd')

View File

@ -118,7 +118,9 @@ module VagrantPlugins
# @return [Integer] user ID that owns machine
def uid
client.uid(Empty.new).user_id
user_id = client.uid(Empty.new).user_id
return nil if user_id == ""
return user_id
end
def _cleaned_folder_hash(folder)