示例#1
0
文件: aci.go 项目: vcaputo/cnt
func (cnt *Img) tarAci(zip bool) {
	target := PATH_IMAGE_ACI[1:]
	if zip {
		target = PATH_IMAGE_ACI_ZIP[1:]
	}
	dir, _ := os.Getwd()
	log.Debug("chdir to", cnt.target)
	os.Chdir(cnt.target)
	utils.Tar(zip, target, PATH_MANIFEST[1:], PATH_ROOTFS[1:])
	log.Debug("chdir to", dir)
	os.Chdir(dir)
}
示例#2
0
文件: config.go 项目: vcaputo/cnt
func init() {
	cntConfig = CntConfig{Path: "/root/.config/cnt"}
	user := os.Getenv("SUDO_USER")
	if user != "" {
		home, err := utils.ExecCmdGetOutput("bash", "-c", "echo ~"+user)
		if err != nil {
			panic("Cannot find user home" + err.Error())
		}
		cntConfig.Path = home + "/.config/cnt"
	}
	//	switch runtime.GOOS {
	//	case "windows":
	//		cntConfig.Path = utils.UserHomeOrFatal() + "/AppData/Local/Cnt"
	//	case "darwin":
	//		cntConfig.Path = utils.UserHomeOrFatal() + "/Library/Cnt"
	//	case "linux":
	//		cntConfig.Path = utils.UserHomeOrFatal() + "/.config/cnt"
	//	default:
	//		log.Get().Panic("Unsupported OS, please fill a bug repost")
	//	}

	if source, err := ioutil.ReadFile(cntConfig.Path + "/config.yml"); err == nil {
		err = yaml.Unmarshal([]byte(source), &cntConfig)
		if err != nil {
			panic(err)
		}
	}

	log.Debug("Home folder is " + cntConfig.Path)
}
示例#3
0
func (n ACFullname) LatestVersion() (string, error) {
	app, err := discovery.NewAppFromString(n.Name() + ":latest")
	if app.Labels["os"] == "" {
		app.Labels["os"] = "linux"
	}
	if app.Labels["arch"] == "" {
		app.Labels["arch"] = "amd64"
	}

	endpoint, _, err := discovery.DiscoverEndpoints(*app, false)
	if err != nil {
		return "", errors.Annotate(err, "Latest discovery fail")
	}

	r, _ := regexp.Compile(`^(\d+\.)?(\d+\.)?(\*|\d+)$`)

	url := getRedirectForLatest(endpoint.ACIEndpoints[0].ACI)
	log.Debug("latest version url is ", url)

	for _, part := range strings.Split(url, "/") {
		if r.Match([]byte(part)) {
			return part, nil
		}
	}
	return "", errors.New("No latest version found")
}
示例#4
0
文件: aci.go 项目: vcaputo/cnt
func NewAci(path string, args BuildArgs) (*Img, error) {
	manifest, err := readManifest(path + PATH_CNT_MANIFEST)
	if err != nil {
		log.Debug(path, PATH_CNT_MANIFEST+" does not exists")
		return nil, err
	}
	return NewAciWithManifest(path, args, *manifest, nil)
}
示例#5
0
文件: aci.go 项目: vcaputo/cnt
func NewAciWithManifest(path string, args BuildArgs, manifest spec.AciManifest, checked *chan bool) (*Img, error) {
	log.Debug("New aci", path, args, manifest)
	cnt, err := PrepAci(path, args)
	if err != nil {
		return nil, err
	}
	cnt.manifest = manifest

	go cnt.checkLatestVersions(checked)

	return cnt, nil
}
示例#6
0
文件: aci.go 项目: vcaputo/cnt
func (cnt *Img) checkLatestVersions(checked *chan bool) {
	if cnt.manifest.From != "" {
		version, _ := cnt.manifest.From.LatestVersion()
		log.Debug("latest version of from : " + cnt.manifest.NameAndVersion.Name() + ":" + version)
		if version != "" && utils.Version(cnt.manifest.From.Version()).LessThan(utils.Version(version)) {
			log.Warn("---------------------------------")
			log.Warn("From has newer version : " + cnt.manifest.From.Name() + ":" + version)
			log.Warn("---------------------------------")
		}
	}
	for _, dep := range cnt.manifest.Aci.Dependencies {
		version, _ := dep.LatestVersion()
		if version != "" && utils.Version(dep.Version()).LessThan(utils.Version(version)) {
			log.Warn("---------------------------------")
			log.Warn("Newer dependency version : " + dep.Name() + ":" + version)
			log.Warn("---------------------------------")
		}
	}
	if checked != nil {
		*checked <- true
	}
}
示例#7
0
文件: aci-build.go 项目: vcaputo/cnt
func (cnt *Img) writeImgManifest() {
	log.Debug("Writing aci manifest")
	utils.WriteImageManifest(&cnt.manifest, cnt.target+PATH_MANIFEST, cnt.manifest.NameAndVersion.Name())
}