Set box id

This commit is contained in:
sophia 2021-11-10 16:21:24 -06:00 committed by Paul Hinze
parent 085e30053e
commit 1545093be2
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -65,6 +65,7 @@ func NewBox(opts ...BoxOption) (b *Box, err error) {
return nil, err
}
mapstructure.Decode(metadata, &b.box.Metadata)
b.box.Id = b.box.Name + "-" + b.box.Version + "-" + b.box.Provider
b.Save()
return
}
@ -338,6 +339,10 @@ func (b *Box) Compare(box core.Box) (int, error) {
return 0, errors.New("Box name and provider does not match, can't compare")
}
func (b *Box) ToProto() *vagrant_server.Box {
return b.box
}
func (b *Box) Save() error {
b.m.Lock()
defer b.m.Unlock()