Skip to content

Commit

Permalink
Merge pull request #13244 from tomponline/stable-5.21
Browse files Browse the repository at this point in the history
Backports and gomod dependency updates (stable-5.21)
  • Loading branch information
tomponline authored Apr 2, 2024
2 parents 7a46ef0 + 7d3ae3e commit 3ffeadc
Show file tree
Hide file tree
Showing 38 changed files with 983 additions and 170 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ lxd-*.tar.gz
.vagrant
*~
tags
**/*.bak

# Potential binaries
fuidshift/fuidshift
Expand Down
6 changes: 6 additions & 0 deletions client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,12 @@ type InstanceFileArgs struct {
// File permissions
Mode int

// Whether to modify the permissions of existing files (see the
// instances_files_modify_permissions api extension)
GIDModifyExisting bool
UIDModifyExisting bool
ModeModifyExisting bool

// File type (file or directory)
Type string

Expand Down
14 changes: 9 additions & 5 deletions client/lxd_containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,12 +809,16 @@ func (r *ProtocolLXD) GetContainerFile(containerName string, path string) (io.Re
}

// Parse the headers
uid, gid, mode, fileType, _ := shared.ParseLXDFileHeaders(resp.Header)
headers, err := shared.ParseLXDFileHeaders(resp.Header)
if err != nil {
return nil, nil, fmt.Errorf("Failed to parse response headers: %w", err)
}

fileResp := ContainerFileResponse{
UID: uid,
GID: gid,
Mode: mode,
Type: fileType,
UID: headers.UID,
GID: headers.GID,
Mode: headers.Mode,
Type: headers.Type,
}

if fileResp.Type == "directory" {
Expand Down
32 changes: 27 additions & 5 deletions client/lxd_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -1492,12 +1492,16 @@ func (r *ProtocolLXD) GetInstanceFile(instanceName string, filePath string) (io.
}

// Parse the headers
uid, gid, mode, fileType, _ := shared.ParseLXDFileHeaders(resp.Header)
headers, err := shared.ParseLXDFileHeaders(resp.Header)
if err != nil {
return nil, nil, err
}

fileResp := InstanceFileResponse{
UID: uid,
GID: gid,
Mode: mode,
Type: fileType,
UID: headers.UID,
GID: headers.GID,
Mode: headers.Mode,
Type: headers.Type,
}

if fileResp.Type == "directory" {
Expand Down Expand Up @@ -1593,6 +1597,24 @@ func (r *ProtocolLXD) CreateInstanceFile(instanceName string, filePath string, a
req.Header.Set("X-LXD-write", args.WriteMode)
}

var modifyPerm []string

if args.UIDModifyExisting {
modifyPerm = append(modifyPerm, "uid")
}

if args.GIDModifyExisting {
modifyPerm = append(modifyPerm, "gid")
}

if args.ModeModifyExisting {
modifyPerm = append(modifyPerm, "mode")
}

if len(modifyPerm) != 0 && r.CheckExtension("instance_files_modify_permissions") == nil {
req.Header.Set("X-LXD-modify-perm", strings.Join(modifyPerm, ","))
}

// Send the request
resp, err := r.DoHTTP(req)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions doc/api-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2392,3 +2392,9 @@ Adds the ability to limit disk I/O for virtual machines.
## `storage_volumes_all`

This API extension adds support for listing storage volumes from all storage pools via `/1.0/storage-volumes` or `/1.0/storage-volumes/{type}` to filter by volume type. Also adds a `pool` field to storage volumes.

## `instances_files_modify_permissions`

Adds the ability for `POST /1.0/instances/{name}/files` to modify the permissions of files that already exist via the `X-LXD-modify-perm` header.

`X-LXD-modify-perm` should be a comma-separated list of 0 or more of `mode`, `uid`, and `gid`.
6 changes: 6 additions & 0 deletions doc/rest-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10247,6 +10247,12 @@ paths:
name: X-LXD-mode
schema:
type: integer
- description: Comma-separated list of permissions to set for pre-existing files (0 or more of `uid`, `gid`, `mode`)
example: uid,gid,mode
in: header
name: X-LXD-modify-perm
schema:
type: integer
- description: Type of file (file, symlink or directory)
example: file
in: header
Expand Down
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/oklog/ulid/v2 v2.1.0
github.com/olekukonko/tablewriter v0.0.5
github.com/openfga/api/proto v0.0.0-20240318145204-66b9e5cb403c
github.com/openfga/language/pkg/go v0.0.0-20240312214103-2c2688b46b9c
github.com/openfga/language/pkg/go v0.0.0-20240401190211-052b5357673a
github.com/openfga/openfga v1.5.1
github.com/osrg/gobgp/v3 v3.24.0
github.com/pkg/sftp v1.13.6
Expand All @@ -48,7 +48,7 @@ require (
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/vishvananda/netlink v1.2.1-beta.2
github.com/zitadel/oidc/v2 v2.12.0
go.starlark.net v0.0.0-20240307200823-981680b3e495
go.starlark.net v0.0.0-20240329153429-e6e8e7ce1b7a
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.21.0
golang.org/x/oauth2 v0.18.0
Expand All @@ -59,18 +59,18 @@ require (
google.golang.org/protobuf v1.33.0
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637
gopkg.in/yaml.v2 v2.4.0
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
k8s.io/utils v0.0.0-20240310230437-4693a0247e57
)

require (
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/digitalocean/go-libvirt v0.0.0-20240229222500-83343b985513 // indirect
github.com/digitalocean/go-libvirt v0.0.0-20240308204700-df736b2945cf // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/eapache/channels v1.1.0 // indirect
github.com/eapache/queue v1.1.0 // indirect
Expand All @@ -82,7 +82,7 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.20.1 // indirect
github.com/google/renameio v1.0.1 // indirect
github.com/gorilla/schema v1.2.1 // indirect
github.com/gorilla/schema v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
Expand All @@ -106,7 +106,7 @@ require (
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mdlayher/socket v0.5.0 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
Expand All @@ -115,12 +115,12 @@ require (
github.com/muhlemmer/gu v0.3.1 // indirect
github.com/muhlemmer/httpforwarded v0.1.0 // indirect
github.com/natefinch/wrap v0.2.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.50.0 // indirect
github.com/prometheus/common v0.51.1 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rs/cors v1.10.1 // indirect
Expand All @@ -145,13 +145,13 @@ require (
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
go.uber.org/mock v0.4.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240308144416-29370a3891b7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240308144416-29370a3891b7 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.62.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
Expand Down
Loading

0 comments on commit 3ffeadc

Please sign in to comment.