go.mod: update osbuild/images to v0.69.0

This commit is contained in:
Achilleas Koutsou 2024-07-02 14:42:15 +02:00
parent 1cc90c6a0b
commit 8ac80e8abc
611 changed files with 28281 additions and 32629 deletions

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2018-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2018-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -31,6 +31,7 @@ const (
LibraryItemFileData = "/com/vmware/cis/data"
LibraryItemPath = "/com/vmware/content/library/item"
LibraryItemFilePath = "/com/vmware/content/library/item/file"
LibraryItemStoragePath = "/com/vmware/content/library/item/storage"
LibraryItemUpdateSession = "/com/vmware/content/library/item/update-session"
LibraryItemUpdateSessionFile = "/com/vmware/content/library/item/updatesession/file"
LibraryItemDownloadSession = "/com/vmware/content/library/item/download-session"

View file

@ -0,0 +1,132 @@
/*
Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package finder
import (
"context"
"fmt"
"net/url"
"path"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vapi/library"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/types"
)
// PathFinder is used to find the Datastore path of a library.Library, library.Item or library.File.
type PathFinder struct {
m *library.Manager
c *vim25.Client
cache map[string]string
}
// NewPathFinder creates a new PathFinder instance.
func NewPathFinder(m *library.Manager, c *vim25.Client) *PathFinder {
return &PathFinder{
m: m,
c: c,
cache: make(map[string]string),
}
}
// Path returns the absolute datastore path for a Library, Item or File.
// The cache is used by DatastoreName().
func (f *PathFinder) Path(ctx context.Context, r FindResult) (string, error) {
switch l := r.GetResult().(type) {
case library.Library:
id := ""
if len(l.Storage) != 0 {
var err error
id, err = f.datastoreName(ctx, l.Storage[0].DatastoreID)
if err != nil {
return "", err
}
}
return fmt.Sprintf("[%s] contentlib-%s", id, l.ID), nil
case library.Item:
p, err := f.Path(ctx, r.GetParent())
if err != nil {
return "", err
}
return fmt.Sprintf("%s/%s", p, l.ID), nil
case library.File:
return f.getFileItemPath(ctx, r)
default:
return "", fmt.Errorf("unsupported type=%T", l)
}
}
// getFileItemPath returns the absolute datastore path for a library.File
func (f *PathFinder) getFileItemPath(ctx context.Context, r FindResult) (string, error) {
name := r.GetName()
dir, err := f.Path(ctx, r.GetParent())
if err != nil {
return "", err
}
p := path.Join(dir, name)
lib := r.GetParent().GetParent().GetResult().(library.Library)
if len(lib.Storage) == 0 {
return p, nil
}
// storage file name includes a uuid, for example:
// "ubuntu-14.04.6-server-amd64.iso" -> "ubuntu-14.04.6-server-amd64_0653e3f3-b4f4-41fb-9b72-c4102450e3dc.iso"
s, err := f.m.GetLibraryItemStorage(ctx, r.GetParent().GetID(), name)
if err != nil {
return p, err
}
// Currently there can only be 1 storage URI
if len(s) == 0 {
return p, nil
}
uris := s[0].StorageURIs
if len(uris) == 0 {
return p, nil
}
u, err := url.Parse(uris[0])
if err != nil {
return p, err
}
return path.Join(dir, path.Base(u.Path)), nil
}
// datastoreName returns the Datastore.Name for the given id.
func (f *PathFinder) datastoreName(ctx context.Context, id string) (string, error) {
if name, ok := f.cache[id]; ok {
return name, nil
}
obj := types.ManagedObjectReference{
Type: "Datastore",
Value: id,
}
ds := object.NewDatastore(f.c, obj)
name, err := ds.ObjectName(ctx)
if err != nil {
return "", err
}
f.cache[id] = name
return name, nil
}

View file

@ -28,27 +28,28 @@ import (
"github.com/vmware/govmomi/vapi/rest"
)
// StorageBackings for Content Libraries
type StorageBackings struct {
// StorageBacking defines a storage location where content in a library will be stored.
type StorageBacking struct {
DatastoreID string `json:"datastore_id,omitempty"`
Type string `json:"type,omitempty"`
StorageURI string `json:"storage_uri,omitempty"`
}
// Library provides methods to create, read, update, delete, and enumerate libraries.
type Library struct {
CreationTime *time.Time `json:"creation_time,omitempty"`
Description *string `json:"description,omitempty"`
ID string `json:"id,omitempty"`
LastModifiedTime *time.Time `json:"last_modified_time,omitempty"`
LastSyncTime *time.Time `json:"last_sync_time,omitempty"`
Name string `json:"name,omitempty"`
Storage []StorageBackings `json:"storage_backings,omitempty"`
Type string `json:"type,omitempty"`
Version string `json:"version,omitempty"`
Subscription *Subscription `json:"subscription_info,omitempty"`
Publication *Publication `json:"publish_info,omitempty"`
SecurityPolicyID string `json:"security_policy_id,omitempty"`
UnsetSecurityPolicyID bool `json:"unset_security_policy_id,omitempty"`
CreationTime *time.Time `json:"creation_time,omitempty"`
Description *string `json:"description,omitempty"`
ID string `json:"id,omitempty"`
LastModifiedTime *time.Time `json:"last_modified_time,omitempty"`
LastSyncTime *time.Time `json:"last_sync_time,omitempty"`
Name string `json:"name,omitempty"`
Storage []StorageBacking `json:"storage_backings,omitempty"`
Type string `json:"type,omitempty"`
Version string `json:"version,omitempty"`
Subscription *Subscription `json:"subscription_info,omitempty"`
Publication *Publication `json:"publish_info,omitempty"`
SecurityPolicyID string `json:"security_policy_id,omitempty"`
UnsetSecurityPolicyID bool `json:"unset_security_policy_id,omitempty"`
}
// Subscription info

View file

@ -0,0 +1,53 @@
/*
Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package library
import (
"context"
"net/http"
"github.com/vmware/govmomi/vapi/internal"
)
// Storage is an expanded form of library.File that includes details about the
// storage backing for a file in a library item
type Storage struct {
Checksum Checksum `json:"checksum_info,omitempty"`
StorageBacking StorageBacking `json:"storage_backing"`
StorageURIs []string `json:"storage_uris"`
Name string `json:"name"`
Size int64 `json:"size"`
Cached bool `json:"cached"`
Version string `json:"version"`
}
// ListLibraryItemStorage returns a list of all the storage for a library item.
func (c *Manager) ListLibraryItemStorage(ctx context.Context, id string) ([]Storage, error) {
url := c.Resource(internal.LibraryItemStoragePath).WithParam("library_item_id", id)
var res []Storage
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
}
// GetLibraryItemStorage returns the storage for a specific file in a library item.
func (c *Manager) GetLibraryItemStorage(ctx context.Context, id, fileName string) ([]Storage, error) {
url := c.Resource(internal.LibraryItemStoragePath).WithID(id).WithAction("get")
spec := struct {
Name string `json:"file_name"`
}{fileName}
var res []Storage
return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
}