Beispiel #1
0
//rktDirectory string, ociConfig string, ociRuntimeConfig string, ociDirectory string
func (this *oci2rkt) makePod() (err error) {

	//1.covert to pod
	this.podManifest.ACVersion = types.SemVer{
		Major:      0,
		Minor:      8,
		Patch:      0,
		PreRelease: "",
		Metadata:   "",
	}

	this.podManifest.ACKind = "PodManifest"

	/*
		this.podManifest.Apps = schema.AppList{
			{
				Name: "oci",
				Image: schema.RuntimeImage{
					ID: types.Hash{
						Val: "",
					},
				},
			},
		}
	*/

	runTimeImage := schema.RuntimeImage{}
	hash, err := types.NewHash("sha512-ca0bee4ecb888d10cf0816ebe7e16499230ab349bd3126976ab60b9b1db2e120")
	if err != nil {
		return err
	}
	runTimeImage.ID = *hash
	runTimeApp := schema.RuntimeApp{
		Name: "oci",
	}
	runTimeApp.Image = runTimeImage

	this.podManifest.Apps = append(this.podManifest.Apps, runTimeApp)

	this.podManifest.Volumes = nil
	this.podManifest.Isolators = nil
	this.podManifest.Annotations = nil
	this.podManifest.Ports = nil

	//2.marshal
	podBuf, err := json.Marshal(this.podManifest)
	if err != nil {
		return err
	}

	//3.wirte pod file
	pod := this.RktBundlePath + "/pod"

	err = ioutil.WriteFile(pod, podBuf, 0755)
	if err != nil {
		return err
	}

	return nil
}