This simplifies the stand-up of a sandbox:
Only 2 main Vagrant calls are now needed (`vagrant up` and `vagrant up machine1`). This PR only updates the Vagrant Virtualbox setup. The Vagrant Libvirt and Terraform still need to be updated. This uses docker-compose as the entry point for standing up the stack and makes the stand-up of the sandbox more portal. Vagrant and Terraform are only responsible for standing up infrastructure and then running docker-compose, not for running any glue scripts. The docker-compose calls out to single-shot services to do all the glue required to get the fully functional Tinkerbell stack up and running. All the single-shot services are idempotent. This increases portability and the development iteration loop. This also simplifies the required steps needed to get a fully functioning sandbox up and running. This is intended to help people looking to get started by getting them to a provisioned machine quicker and more easily. Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
This commit is contained in:
24
releases/cmd/bump-version/image/image.go
Normal file
24
releases/cmd/bump-version/image/image.go
Normal file
@ -0,0 +1,24 @@
|
||||
package image
|
||||
|
||||
import "fmt"
|
||||
|
||||
var ErrCommitTooShort = fmt.Errorf("commit to short, it needs at least 8 characters")
|
||||
|
||||
type Image struct {
|
||||
name string
|
||||
}
|
||||
|
||||
// TagFromSha returns an image tag from a commit sha following the
|
||||
// convention we have in Tinkerbell
|
||||
// Commit: a7e947efc194fb0375f88cccc67f2fde5e0c85c1
|
||||
// -> Tag: sha-a7e947ef
|
||||
func TagFromSha(commit string) (string, error) {
|
||||
if len(commit) < 8 {
|
||||
return "", ErrCommitTooShort
|
||||
}
|
||||
return "sha-" + commit[0:8], nil
|
||||
}
|
||||
|
||||
func NewImage(name string) *Image {
|
||||
return &Image{name: name}
|
||||
}
|
39
releases/cmd/bump-version/image/image_test.go
Normal file
39
releases/cmd/bump-version/image/image_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package image_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/tinkerbell/sandbox/cmd/bump-version/image"
|
||||
)
|
||||
|
||||
func TestTagFromSha(t *testing.T) {
|
||||
s := []struct {
|
||||
Err error
|
||||
Commit string
|
||||
Tag string
|
||||
}{
|
||||
{
|
||||
Commit: "a7e947efc194fb0375f88cccc67f2fde5e0c85c1",
|
||||
Tag: "sha-a7e947ef",
|
||||
},
|
||||
{
|
||||
Commit: "0",
|
||||
Err: image.ErrCommitTooShort,
|
||||
},
|
||||
}
|
||||
|
||||
for _, v := range s {
|
||||
t.Run(fmt.Sprintf("%s -> %s", v.Commit, v.Tag), func(t *testing.T) {
|
||||
tag, err := image.TagFromSha(v.Commit)
|
||||
errors.Is(err, v.Err)
|
||||
if v.Err != err {
|
||||
t.Error(err)
|
||||
}
|
||||
if tag != v.Tag {
|
||||
t.Errorf("expected %s got %s", v.Tag, tag)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user