Skip to content
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

incus-simplestreams: Simplify and add documentation #622

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 26 additions & 40 deletions cmd/incus-simplestreams/main_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,55 +65,41 @@ func (c *cmdRemove) Run(cmd *cobra.Command, args []string) error {
}

for kVersion, version := range product.Versions {
// Find the incus.tar.xz and figure out what to delete.
var deleteDisk bool
var deleteSquashfs bool
var metadataPath string

for _, item := range version.Items {
if item.FileType != "incus.tar.xz" {
continue
}

metadataPath = item.Path

if item.CombinedSha256DiskKvmImg == image.Fingerprint {
deleteDisk = true
break
}

if item.CombinedSha256SquashFs == image.Fingerprint {
deleteSquashfs = true
break
}
// Get the metadata entry.
metaEntry, ok := version.Items["incus.tar.xz"]
if !ok {
// Image isn't using our normal structure.
continue
}

// Delete the entry and associated files.
for kItem, item := range version.Items {
if deleteDisk && item.FileType == "disk-kvm.img" {
err = os.Remove(item.Path)
if err != nil && !os.IsNotExist(err) {
return err
}

delete(version.Items, kItem)
break
if metaEntry.CombinedSha256DiskKvmImg == image.Fingerprint {
// Deleting a VM image.
err = os.Remove(version.Items["disk-kvm.img"].Path)
if err != nil && !os.IsNotExist(err) {
return err
}

if deleteSquashfs && item.FileType == "squashfs" {
err = os.Remove(item.Path)
if err != nil && !os.IsNotExist(err) {
return err
}

delete(version.Items, kItem)
break
delete(version.Items, "disk-kvm.img")
metaEntry.CombinedSha256DiskKvmImg = ""
} else if metaEntry.CombinedSha256SquashFs == image.Fingerprint {
// Deleting a container image.
err = os.Remove(version.Items["squashfs"].Path)
if err != nil && !os.IsNotExist(err) {
return err
}

delete(version.Items, "squashfs")
metaEntry.CombinedSha256SquashFs = ""
} else {
continue
}

// Update the metadata entry.
version.Items["incus.tar.xz"] = metaEntry

// Delete the version if it's now empty.
if len(version.Items) == 1 {
err = os.Remove(metadataPath)
err = os.Remove(metaEntry.Path)
if err != nil && !os.IsNotExist(err) {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion doc/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Manage images <howto/images_manage>
Copy and import images <howto/images_copy>
Create images <howto/images_create>
Associate profiles <howto/images_profiles>
reference/remote_image_servers
reference/image_format
reference/image_servers
```
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
(remote-image-servers)=
# Remote image servers
(image-servers)=
# Default image server

The [`incus`](incus.md) CLI command comes pre-configured with the following default remote image servers:
The [`incus`](incus.md) CLI command comes pre-configured with the following default remote image server:

`images:`
: This server provides unofficial images for a variety of Linux distributions.
The images are maintained by the [Linux Containers](https://linuxcontainers.org/) team and are built to be compact and minimal.

See [`images.linuxcontainers.org`](https://images.linuxcontainers.org) for an overview of available images.

(remote-image-server-types)=
## Remote server types
Additional image servers can be added through `incus remote add`.

(image-server-types)=
## Image server types

Incus supports the following types of remote image servers:

Simple streams servers
: Pure image servers that use the [simple streams format](https://git.launchpad.net/simplestreams/tree/).
The default image servers are simple streams servers.
No special software is required to run such a server as it's only made of static files.
The default `images:` server uses simplestreams.

Public Incus servers
: Incus servers that are used solely to serve images and do not run instances themselves.
Expand All @@ -29,3 +32,16 @@ Incus servers

For security reasons, you should restrict the access to the remote API and configure an authentication method to control access.
See {ref}`server-expose` and {ref}`authentication` for more information.

(image-server-tooling)=
## Tooling to manage a simplestreams server
Incus includes a tool called `incus-simplestreams` which can be used to manage a file system tree using the Simple streams format.

It supports importing either a container (`squashfs`) or virtual-machine (`qcow2`) image
with `incus-simplestreams add`, list all images available as well as their fingerprints
with `incus-simplestreams list` and remove images from the server with `incus-simplestreams remove`.

That file system tree must then be placed on a regular web server which supports HTTPS with a valid certificate.

When importing an image that doesn't come with an Incus metadata tarball, the `incus-simplestreams generate-metadata` command
can be used to generate a new basic metadata tarball from a few questions.
Loading