コード例 #1
0
ファイル: verify.go プロジェクト: rupakg/zodiac
func verifyEndpoint(e endpoint.Endpoint) error {
	version, err := e.Version()
	if err != nil {
		return err
	}

	log.Infof("%s reported version %s", e.Name(), version)

	isSwarm := false
	if strings.HasPrefix(version, "swarm/") {
		isSwarm = true
		parts := strings.Split(version, "/")
		version = parts[1]
	}

	semver, err := semver.Make(version)
	if err != nil {
		return fmt.Errorf("can't understand version '%s'", version)
	}

	if isSwarm && semver.LT(RequiredSwarmAPIVersion) {
		return fmt.Errorf("Swarm API must be %s or above, but it is %s", RequiredSwarmAPIVersion, semver)
	}

	if !isSwarm && semver.LT(RequiredDockerAPIVersion) {
		return fmt.Errorf("Docker API must be %s or above, but it is %s", RequiredDockerAPIVersion, semver)
	}

	return nil
}
コード例 #2
0
ファイル: actions.go プロジェクト: rupakg/zodiac
func startServices(services []Service, manifests DeploymentManifests, endpoint endpoint.Endpoint) error {
	manifestsBlob, err := json.Marshal(manifests)
	if err != nil {
		return err
	}

	for _, svc := range services {
		if svc.ContainerConfig.Labels == nil {
			svc.ContainerConfig.Labels = make(map[string]string)
		}
		svc.ContainerConfig.Labels["zodiacManifest"] = string(manifestsBlob)
		svc.ContainerConfig.Labels["com.centurylinklabs.zodiac.original-image"] = svc.OriginalImage

		fmt.Printf("Creating %s\n", svc.Name)

		if err := endpoint.StartContainer(svc.Name, svc.ContainerConfig); err != nil {
			return err
		}
	}

	return nil
}
コード例 #3
0
ファイル: actions.go プロジェクト: rupakg/zodiac
func getDeploymentManifests(reqs []proxy.ContainerRequest, endpoint endpoint.Endpoint) (DeploymentManifests, error) {
	var manifests DeploymentManifests
	var inspectError error

	for _, req := range reqs {
		ci, err := endpoint.InspectContainer(req.Name)
		inspectError = err
		if err != nil {
			continue
		}

		if err := json.Unmarshal([]byte(ci.Config.Labels["zodiacManifest"]), &manifests); err != nil {
			return nil, err
		}

		break
	}

	if inspectError != nil {
		return nil, inspectError
	}

	return manifests, nil
}