MCPcopy Create free account
hub / github.com/containers/image / processDefFile

Function processDefFile

sif/load.go:72–94  ·  view source on GitHub ↗

processDefFile finds sif.DataDeffile in sifImage, if any, and returns: - the command to run - contents of a script to inject as injectedScriptTargetPath, or nil

(sifImage *sif.FileImage)

Source from the content-addressed store, hash-verified

70// - the command to run
71// - contents of a script to inject as injectedScriptTargetPath, or nil
72func processDefFile(sifImage *sif.FileImage) (string, []byte, error) {
73 var environment, runscript []string
74
75 desc, err := sifImage.GetDescriptor(sif.WithDataType(sif.DataDeffile))
76 if err == nil {
77 environment, runscript, err = parseDefFile(desc.GetReader())
78 if err != nil {
79 return "", nil, err
80 }
81 }
82
83 var command string
84 var injectedScript []byte
85 if len(environment) == 0 && len(runscript) == 0 {
86 command = "bash"
87 injectedScript = nil
88 } else {
89 injectedScript = generateInjectedScript(environment, runscript)
90 command = injectedScriptTargetPath
91 }
92
93 return command, injectedScript, nil
94}
95
96func writeInjectedScript(extractedRootPath string, injectedScript []byte) error {
97 if injectedScript == nil {

Callers 1

convertSIFToElementsFunction · 0.85

Calls 2

parseDefFileFunction · 0.85
generateInjectedScriptFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…