-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add container information to .containerenv #2821
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -216,16 +216,28 @@ func (b *Builder) Run(command []string, options RunOptions) error { | |||||||
} | ||||||||
// Empty file, so no need to recreate if it exists | ||||||||
if _, ok := bindFiles["/run/.containerenv"]; !ok { | ||||||||
// Empty string for now, but we may consider populating this later | ||||||||
containerenvPath := filepath.Join(path, "/run/.containerenv") | ||||||||
if err = os.MkdirAll(filepath.Dir(containerenvPath), 0755); err != nil { | ||||||||
return err | ||||||||
} | ||||||||
emptyFile, err := os.Create(containerenvPath) | ||||||||
if err != nil { | ||||||||
|
||||||||
rootless := 0 | ||||||||
if unshare.IsRootless() { | ||||||||
rootless = 1 | ||||||||
} | ||||||||
// Populate the .containerenv with container information | ||||||||
containerenv := fmt.Sprintf(`\ | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks weird. Why is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes the code easier to read, i figure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That backslash makes it into the file, though, which is what makes it look weird. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok perhaps we should remove it then. |
||||||||
engine="buildah-%s" | ||||||||
name=%q | ||||||||
id=%q | ||||||||
image=%q | ||||||||
imageid=%q | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
rootless=%d | ||||||||
`, Version, b.Container, b.ContainerID, b.FromImage, b.FromImageID, rootless) | ||||||||
|
||||||||
if err = ioutils.AtomicWriteFile(containerenvPath, []byte(containerenv), 0755); err != nil { | ||||||||
return err | ||||||||
} | ||||||||
emptyFile.Close() | ||||||||
if err := label.Relabel(containerenvPath, b.MountLabel, false); err != nil { | ||||||||
return err | ||||||||
} | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.