Example #1
0
func (aci *Aci) buildTestAci() (string, error) {
	manifest, err := common.ExtractManifestFromAci(aci.target + common.PathImageAci)
	if err != nil {
		return "", errs.WithEF(err, aci.fields.WithField("file", aci.target+common.PathImageAci), "Failed to extract manifest from aci")
	}

	name := prefixTest + manifest.Name.String()
	if version, ok := manifest.Labels.Get("version"); ok {
		name += ":" + version
	}

	fullname := common.NewACFullName(name)
	resultMountName, _ := types.NewACName(mountAcname)

	aciManifest := &common.AciManifest{
		Builder: aci.manifest.Tester.Builder,
		Aci: common.AciDefinition{
			App: common.DgrApp{
				Exec:              aci.manifest.Aci.App.Exec,
				MountPoints:       []types.MountPoint{{Path: pathTestsResult, Name: *resultMountName}},
				WorkingDirectory:  aci.manifest.Aci.App.WorkingDirectory,
				User:              aci.manifest.Aci.App.User,
				Group:             aci.manifest.Aci.App.Group,
				SupplementaryGIDs: aci.manifest.Aci.App.SupplementaryGIDs,
				Environment:       aci.manifest.Aci.App.Environment,
				Ports:             aci.manifest.Aci.App.Ports,
				Isolators:         aci.manifest.Aci.App.Isolators,
			},
			Dependencies:  append(aci.manifest.Tester.Aci.Dependencies, *common.NewACFullName(name[len(prefixTest):])),
			Annotations:   aci.manifest.Aci.Annotations,
			PathWhitelist: aci.manifest.Aci.PathWhitelist,
		},
		NameAndVersion: *fullname,
	}

	content, err := yaml.Marshal(aciManifest)
	if err != nil {
		return "", errs.WithEF(err, aci.fields, "Failed to marshall manifest for test aci")
	}

	testAci, err := NewAciWithManifest(aci.path, aci.args, string(content), aci.checkWg)
	if err != nil {
		return "", errs.WithEF(err, aci.fields, "Failed to prepare test's build aci")
	}

	testAci.FullyResolveDep = false // this is required to run local tests without discovery
	testAci.target = aci.target + pathTestsTarget

	if err := testAci.CleanAndBuild(); err != nil {
		return "", errs.WithEF(err, aci.fields, "Build of test aci failed")
	}
	hash, err := Home.Rkt.Fetch(aci.target + pathTestsTarget + pathImageAci)
	if err != nil {
		return "", errs.WithEF(err, aci.fields, "fetch of test aci failed")
	}
	return hash, nil
}
Example #2
0
File: pod.go Project: blablacar/dgr
func (p *Pod) toAciManifestTemplate(e common.RuntimeApp) (string, error) {
	fullname := common.NewACFullName(p.manifest.Name.Name() + "_" + e.Name + ":" + p.manifest.Name.Version())
	manifest := &common.AciManifest{
		Aci: common.AciDefinition{
			Annotations:   e.Annotations,
			App:           e.App,
			Dependencies:  e.Dependencies,
			PathWhitelist: nil, // TODO
		},
		NameAndVersion: *fullname,
	}
	content, err := yaml.Marshal(manifest)
	if err != nil {
		return "", errs.WithEF(err, p.fields, "Failed to prepare manifest template")
	}
	return string(content), nil
}
Example #3
0
File: rkt.go Project: blablacar/dgr
package main

import (
	"io/ioutil"
	"math/rand"
	"os"
	"sync"
	"time"

	"github.com/blablacar/dgr/dgr/common"
	"github.com/blablacar/dgr/dist"
	"github.com/n0rad/go-erlog/logs"
)

var aciBuilder = common.NewACFullName("blablacar.github.io/dgr/aci-builder")
var aciTester = common.NewACFullName("blablacar.github.io/dgr/aci-tester")
var importMutex = sync.Mutex{}
var builderImported = false
var testerImported = false

func ImportInternalBuilderIfNeeded(manifest *common.AciManifest) {
	if manifest.Builder.Image.String() == "" {
		manifest.Builder.Image = *aciBuilder

		importMutex.Lock()
		defer importMutex.Unlock()
		if builderImported {
			return
		}

		importInternalAci("aci-builder.aci")