コード例 #1
0
ファイル: aci-test.go プロジェクト: nyodas/cnt
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
}
コード例 #2
0
ファイル: pod.go プロジェクト: nyodas/cnt
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
}
コード例 #3
0
ファイル: rkt.go プロジェクト: nyodas/cnt
package main

import (
	"github.com/blablacar/dgr/bin-dgr/common"
	"github.com/blablacar/dgr/dist"
	"github.com/n0rad/go-erlog/logs"
	"io/ioutil"
	"math/rand"
	"os"
	"sync"
	"time"
)

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")
		builderImported = true
コード例 #4
0
ファイル: rkt.go プロジェクト: puckel/dgr
package main

import (
	"github.com/blablacar/dgr/bin-dgr/common"
	"github.com/blablacar/dgr/dist"
	"github.com/n0rad/go-erlog/logs"
	"io/ioutil"
	"math/rand"
	"os"
	"time"
)

var aciBuilder = common.NewACFullName("dgrtool.com/aci-builder:1")
var aciTester = common.NewACFullName("dgrtool.com/aci-tester:1")

//var internalAcis = []*spec.ACFullname{ACI_BATS, ACI_BUILDER}

func ImportInternalBuilderIfNeeded(manifest *common.AciManifest) {
	if manifest.Builder.Image.String() == "" {
		manifest.Builder.Image = *aciBuilder
		importInternalAci("aci-builder.aci") // TODO
	}
}

func ImportInternalTesterIfNeeded(manifest *common.AciManifest) {
	ImportInternalBuilderIfNeeded(manifest)
	if manifest.Tester.Builder.Image.String() == "" {
		manifest.Tester.Builder.Image = *aciTester
		importInternalAci("aci-tester.aci") // TODO
	}
}