-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Quadlet: add -list-images #23065
Quadlet: add -list-images #23065
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 |
---|---|---|
|
@@ -27,11 +27,12 @@ import ( | |
// for more details. | ||
|
||
var ( | ||
verboseFlag bool // True if -v passed | ||
noKmsgFlag bool | ||
isUserFlag bool // True if run as quadlet-user-generator executable | ||
dryRunFlag bool // True if -dryrun is used | ||
versionFlag bool // True if -version is used | ||
verboseFlag bool // True if -v passed | ||
noKmsgFlag bool | ||
isUserFlag bool // True if run as quadlet-user-generator executable | ||
dryRunFlag bool // True if -dryrun is used | ||
versionFlag bool // True if -version is used | ||
listImagesFlag string // Set if -list-images is used | ||
) | ||
|
||
const ( | ||
|
@@ -549,7 +550,7 @@ func process() error { | |
prevError = err | ||
} | ||
|
||
if !dryRunFlag && flag.NArg() < 1 { | ||
if !dryRunFlag && flag.NArg() < 1 && len(listImagesFlag) == 0 { | ||
reportError(errors.New("missing output directory argument")) | ||
return prevError | ||
} | ||
|
@@ -586,6 +587,31 @@ func process() error { | |
} | ||
} | ||
|
||
if len(listImagesFlag) > 0 { | ||
fd, err := os.OpenFile(listImagesFlag, os.O_WRONLY, 0644) | ||
if err != nil { | ||
return err | ||
} | ||
for _, unit := range units { | ||
if !strings.HasSuffix(unit.Filename, ".image") { | ||
continue | ||
} | ||
imageName, err := quadlet.ListImage(unit) | ||
if err != nil { | ||
reportError(err) | ||
} | ||
if !isUnambiguousName(imageName) { | ||
Logf("Warning: %s specifies the image \"%s\" which not a fully qualified image name and is hence being ignored.", unit.Filename, imageName) | ||
continue | ||
} | ||
fmt.Fprintf(fd, "%s\n", imageName) | ||
} | ||
if err := fd.Close(); err != nil { | ||
reportError(err) | ||
} | ||
return prevError | ||
} | ||
|
||
if !dryRunFlag { | ||
err := os.MkdirAll(outputPath, os.ModePerm) | ||
if err != nil { | ||
|
@@ -681,4 +707,5 @@ func init() { | |
flag.BoolVar(&isUserFlag, "user", false, "Run as systemd user") | ||
flag.BoolVar(&dryRunFlag, "dryrun", false, "Run in dryrun mode printing debug information") | ||
flag.BoolVar(&versionFlag, "version", false, "Print version information and exit") | ||
flag.StringVar(&listImagesFlag, "list-images", "", "Write a list of all images being references in .image Quadlets to specified file") | ||
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. Given that we're likely to want to add something like a new flag to opt-in to pinning like I think we'll need to either:
I think the second part is important: Consider the case where I want to use a custom pull secret just for some images. In that general case today, we need the This type of thing implies actually that what we will need as a next step is a way to pass the output of this tool (probably a full 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. Podman should not parse quadlet files. That is breaking the well build separation we have. And quite frankly it cannot work as systemd untis may contain systemd specifiers that must be expanded first and this is not logic we should try to mirror because we will fail to match it 1 to 1. As such I fail to see how we can generate the command exactly the way systemd would execute it. 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. Specifiers are a complex topic indeed. I think Would people use e.g. 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. So to combine these then, what we could output instead is say JSON, with a list of 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. Although it's a bit messy because if we also want to do pinning via 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. I want to extract some requirements from the conversation:
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.
It's subtler than that I think. We want to "logically bind", and that means that bootc must not queue a new bootloader entry unless the logically bound images have been pulled and are known to be present. A whole big point of bootc (and ostree before it, and image based systems in general) is having "transactional updates" where the system is known to either be in state A or B. If we did the naive thing of:
Then some tool doing a This subtlety is why this is hard to implement without changes to both bootc and podman today. |
||
} |
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.
Minor, but best practice to wrap in a bufio.BufWriter right?