mirror of
https://github.com/clearlinux/rkt.git
synced 2026-09-01 19:31:27 +00:00
73 lines
2.4 KiB
Go
73 lines
2.4 KiB
Go
// Copyright 2014 CoreOS, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package path
|
|
|
|
//
|
|
// Functions defining paths that are shared by different parts of rkt
|
|
// (e.g. stage0 and stage1)
|
|
//
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/appc/spec/aci"
|
|
"github.com/appc/spec/schema/types"
|
|
)
|
|
|
|
const (
|
|
Stage1Dir = "/stage1"
|
|
stage2Dir = "/opt/stage2"
|
|
)
|
|
|
|
// Stage1RootfsPath returns the directory in root containing the rootfs for stage1
|
|
func Stage1RootfsPath(root string) string {
|
|
return filepath.Join(root, Stage1Dir)
|
|
}
|
|
|
|
// ContainerManifestPath returns the path in root to the Container Runtime Manifest
|
|
func ContainerManifestPath(root string) string {
|
|
return filepath.Join(root, "container")
|
|
}
|
|
|
|
// AppImagePath returns the path where an app image (i.e. unpacked ACI) is rooted (i.e.
|
|
// where its contents are extracted during stage0), based on the app image ID.
|
|
func AppImagePath(root string, imageID types.Hash) string {
|
|
return filepath.Join(root, Stage1Dir, stage2Dir, types.ShortHash(imageID.String()))
|
|
}
|
|
|
|
// AppRootfsPath returns the path to an app's rootfs.
|
|
// imageID should be the app image ID.
|
|
func AppRootfsPath(root string, imageID types.Hash) string {
|
|
return filepath.Join(AppImagePath(root, imageID), aci.RootfsDir)
|
|
}
|
|
|
|
// RelAppImagePath returns the path of an application image relative to the
|
|
// stage1 chroot
|
|
func RelAppImagePath(imageID types.Hash) string {
|
|
return filepath.Join(stage2Dir, types.ShortHash(imageID.String()))
|
|
}
|
|
|
|
// RelAppImagePath returns the path of an application's rootfs relative to the
|
|
// stage1 chroot
|
|
func RelAppRootfsPath(imageID types.Hash) string {
|
|
return filepath.Join(RelAppImagePath(imageID), aci.RootfsDir)
|
|
}
|
|
|
|
// ImageManifestPath returns the path to the app's manifest file inside the expanded ACI.
|
|
// id should be the app image ID.
|
|
func ImageManifestPath(root string, imageID types.Hash) string {
|
|
return filepath.Join(AppImagePath(root, imageID), aci.ManifestFile)
|
|
}
|