idx
int64
0
41.8k
question
stringlengths
65
3.39k
target
stringlengths
10
1.09k
41,800
func ( p * Pod ) isRunning ( ) bool { return ! p . isEmbryo && ! p . isAbortedPrepare && ! p . isPreparing && ! p . isPrepared && ! p . isExited && ! p . isExitedGarbage && ! p . isExitedDeleting && ! p . isGarbage && ! p . isDeleting && ! p . isGone }
isRunning does the annoying tests to infer if a pod is in a running state
41,801
func ( p * Pod ) PodManifestAvailable ( ) bool { if p . isPreparing || p . isAbortedPrepare || p . isDeleting { return false } return true }
PodManifestAvailable returns whether the caller should reasonably expect PodManifest to function in the pod s current state . Namely in Preparing AbortedPrepare and Deleting it s possible for the manifest to not be present
41,802
func ( p * Pod ) IsAfterRun ( ) bool { return p . isExitedDeleting || p . isDeleting || p . isExited || p . isGarbage }
IsAfterRun returns true if the pod is in a post - running state otherwise it returns false .
41,803
func ( p * Pod ) IsFinished ( ) bool { return p . isExited || p . isAbortedPrepare || p . isGarbage || p . isGone }
IsFinished returns true if the pod is in a terminal state else false .
41,804
func ( p * Pod ) AppExitCode ( appName string ) ( int , error ) { stage1RootfsPath , err := p . Stage1RootfsPath ( ) if err != nil { return - 1 , err } statusFile := common . AppStatusPathFromStage1Rootfs ( stage1RootfsPath , appName ) return p . readIntFromFile ( statusFile ) }
AppExitCode returns the app s exit code . It returns an error if the exit code file doesn t exit or the content of the file is invalid .
41,805
func StopPod ( dir string , force bool , uuid * types . UUID ) error { s1rootfs := common . Stage1RootfsPath ( dir ) if err := os . Chdir ( dir ) ; err != nil { return fmt . Errorf ( "failed changing to dir: %v" , err ) } ep , err := getStage1Entrypoint ( dir , stopEntrypoint ) if err != nil { return fmt . Erro...
StopPod stops the given pod .
41,806
func ( c * Config ) MarshalJSON ( ) ( [ ] byte , error ) { stage0 := [ ] interface { } { } for host , auth := range c . AuthPerHost { var typ string var credentials interface { } switch h := auth . ( type ) { case * basicAuthHeaderer : typ = "basic" credentials = h . auth case * oAuthBearerTokenHeaderer : typ...
MarshalJSON marshals the config for user output .
41,807
func ResolveAuthPerHost ( authPerHost map [ string ] Headerer ) map [ string ] http . Header { hostHeaders := make ( map [ string ] http . Header , len ( authPerHost ) ) for k , v := range authPerHost { hostHeaders [ k ] = v . GetHeader ( ) } return hostHeaders }
ResolveAuthPerHost takes a map of strings to Headerer and resolves the Headerers to http . Headers
41,808
func GetConfigFrom ( dirs ... string ) ( * Config , error ) { cfg := newConfig ( ) for _ , cd := range dirs { subcfg , err := GetConfigFromDir ( cd ) if err != nil { return nil , err } mergeConfigs ( cfg , subcfg ) } return cfg , nil }
GetConfigFrom gets the Config instance with configuration taken from given paths . Subsequent paths override settings from the previous paths .
41,809
func GetConfigFromDir ( dir string ) ( * Config , error ) { subcfg := newConfig ( ) if valid , err := validDir ( dir ) ; err != nil { return nil , err } else if ! valid { return subcfg , nil } if err := readConfigDir ( subcfg , dir ) ; err != nil { return nil , err } return subcfg , nil }
GetConfigFromDir gets the Config instance with configuration taken from given directory .
41,810
func WriteEnvFile ( env [ ] string , uidRange * user . UidRange , envFilePath string ) error { ef := bytes . Buffer { } for _ , v := range env { fmt . Fprintf ( & ef , "%s\n" , \n ) } v if err := os . MkdirAll ( filepath . Dir ( envFilePath ) , 0755 ) ; err != nil { return err } if err := ioutil . WriteFile...
WriteEnvFile creates an environment file for given app name . To ensure the minimum required environment variables by the appc spec are set to sensible defaults env should be the result of calling ComposeEnviron . The containing directory and its ancestors will be created if necessary .
41,811
func ComposeEnviron ( env types . Environment ) [ ] string { var composed [ ] string for dk , dv := range defaultEnv { if _ , exists := env . Get ( dk ) ; ! exists { composed = append ( composed , fmt . Sprintf ( "%s=%s" , dk , dv ) ) } } for _ , e := range env { composed = append ( composed , fmt . Sprintf ( "...
ComposeEnviron formats the environment into a slice of strings each of the form key = value . The minimum required environment variables by the appc spec will be set to sensible defaults here if they re not provided by env .
41,812
func ( f mountFlags ) String ( ) string { var s [ ] string maybeAppendFlag := func ( ff uintptr , desc string ) { if uintptr ( f ) & ff != 0 { s = append ( s , desc ) } } maybeAppendFlag ( syscall . MS_DIRSYNC , "MS_DIRSYNC" ) maybeAppendFlag ( syscall . MS_MANDLOCK , "MS_MANDLOCK" ) maybeAppendFlag ( sysca...
String returns a human readable representation of mountFlags based on which bits are set . E . g . for a value of syscall . MS_RDONLY|syscall . MS_BIND it will print MS_RDONLY|MS_BIND
41,813
func newValidator ( image io . ReadSeeker ) ( * validator , error ) { manifest , err := aci . ManifestFromImage ( image ) if err != nil { return nil , err } v := & validator { image : image , manifest : manifest , } return v , nil }
newValidator returns a validator instance if passed image is indeed an ACI .
41,814
func ( v * validator ) ValidateName ( imageName string ) error { name := v . ImageName ( ) if name != imageName { return fmt . Errorf ( "error when reading the app name: %q expected but %q found" , imageName , name ) } return nil }
ValidateName checks if desired image name is actually the same as the one in the image manifest .
41,815
func ( v * validator ) ValidateLabels ( labels map [ types . ACIdentifier ] string ) error { for n , rv := range labels { if av , ok := v . manifest . GetLabel ( n . String ( ) ) ; ok { if rv != av { return fmt . Errorf ( "requested value for label %q: %q differs from fetched aci label value: %q" , n , rv , av ) } ...
ValidateLabels checks if desired image labels are actually the same as the ones in the image manifest .
41,816
func ( v * validator ) ValidateWithSignature ( ks * keystore . Keystore , sig io . ReadSeeker ) ( * openpgp . Entity , error ) { if ks == nil { return nil , nil } if _ , err := v . image . Seek ( 0 , 0 ) ; err != nil { return nil , errwrap . Wrap ( errors . New ( "error seeking ACI file" ) , err ) } if _ , err ...
ValidateWithSignature verifies the image against a given signature file .
41,817
func Register ( distType Type , f newDistribution ) { if _ , ok := distributions [ distType ] ; ok { panic ( fmt . Errorf ( "distribution %q already registered" , distType ) ) } distributions [ distType ] = f }
Register registers a function that returns a new instance of the given distribution . This is intended to be called from the init function in packages that implement distribution functions .
41,818
func Get ( u * url . URL ) ( Distribution , error ) { c , err := parseCIMD ( u ) if err != nil { return nil , fmt . Errorf ( "malformed distribution uri %q: %v" , u . String ( ) , err ) } if u . Scheme != Scheme { return nil , fmt . Errorf ( "malformed distribution uri %q" , u . String ( ) ) } if _ , ok := di...
Get returns a Distribution from the input URI . It returns an error if the uri string is wrong or referencing an unknown distribution type .
41,819
func Parse ( rawuri string ) ( Distribution , error ) { u , err := url . Parse ( rawuri ) if err != nil { return nil , fmt . Errorf ( "cannot parse uri: %q: %v" , rawuri , err ) } return Get ( u ) }
Parse parses the provided distribution URI string and returns a Distribution .
41,820
func newCompletion ( w io . Writer ) func ( * cobra . Command , [ ] string ) int { return func ( cmd * cobra . Command , args [ ] string ) int { return runCompletion ( w , cmd , args ) } }
newCompletion creates a new command with a bounded writer . Writer is used to print the generated shell - completion script which is intended to be consumed by the CLI users .
41,821
func runCompletion ( w io . Writer , cmd * cobra . Command , args [ ] string ) ( exit int ) { if len ( args ) == 0 { stderr . Print ( "shell type is not specified" ) return 254 } if len ( args ) > 1 { stderr . Print ( "too many arguments, only shell type is expected" ) return 254 } completion , ok := comple...
runCompletion is a command handler to generate the shell script with shell completion functions . It ensures that there are enough arguments to generate the completion scripts .