github.com/stackdocker/rkt@v0.10.1-0.20151109095037-1aa827478248/stage0/entrypoint.go (about) 1 // Copyright 2015 The rkt Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 //+build linux 16 17 package stage0 18 19 import ( 20 "encoding/json" 21 "fmt" 22 "io/ioutil" 23 24 "github.com/coreos/rkt/Godeps/_workspace/src/github.com/appc/spec/schema" 25 "github.com/coreos/rkt/common" 26 ) 27 28 const ( 29 enterEntrypoint = "coreos.com/rkt/stage1/enter" 30 runEntrypoint = "coreos.com/rkt/stage1/run" 31 gcEntrypoint = "coreos.com/rkt/stage1/gc" 32 ) 33 34 // getStage1Entrypoint retrieves the named entrypoint from the stage1 manifest for a given pod 35 func getStage1Entrypoint(cdir string, entrypoint string) (string, error) { 36 b, err := ioutil.ReadFile(common.Stage1ManifestPath(cdir)) 37 if err != nil { 38 return "", fmt.Errorf("error reading pod manifest: %v", err) 39 } 40 41 s1m := schema.ImageManifest{} 42 if err := json.Unmarshal(b, &s1m); err != nil { 43 return "", fmt.Errorf("error unmarshaling stage1 manifest: %v", err) 44 } 45 46 if ep, ok := s1m.Annotations.Get(entrypoint); ok { 47 return ep, nil 48 } 49 50 return "", fmt.Errorf("entrypoint %q not found", entrypoint) 51 }