go.mod: bump images to v0.26.0
This is mainly needed in order to get the RHEL 9 SAP Azure images.
This commit is contained in:
parent
d5483ccfb0
commit
807f249146
232 changed files with 32705 additions and 3663 deletions
113
vendor/github.com/vmware/govmomi/vapi/library/library_item_updatesession_file.go
generated
vendored
113
vendor/github.com/vmware/govmomi/vapi/library/library_item_updatesession_file.go
generated
vendored
|
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
Copyright (c) 2018 VMware, Inc. All Rights Reserved.
|
||||
Copyright (c) 2019-2023 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
|
||||
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,
|
||||
|
|
@ -34,6 +34,13 @@ type TransferEndpoint struct {
|
|||
SSLCertificateThumbprint string `json:"ssl_certificate_thumbprint,omitempty"`
|
||||
}
|
||||
|
||||
type ProbeResult struct {
|
||||
Status string `json:"status"`
|
||||
SSLThumbprint string `json:"ssl_thumbprint,omitempty"`
|
||||
SSLCertificate string `json:"ssl_certificate,omitempty"`
|
||||
ErrorMessages []rest.LocalizableMessage `json:"error_messages,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateFile is the specification for the updatesession
|
||||
// operations file:add, file:get, and file:list.
|
||||
type UpdateFile struct {
|
||||
|
|
@ -48,6 +55,19 @@ type UpdateFile struct {
|
|||
UploadEndpoint *TransferEndpoint `json:"upload_endpoint,omitempty"`
|
||||
}
|
||||
|
||||
// FileValidationError contains the validation error of a file in the update session
|
||||
type FileValidationError struct {
|
||||
Name string `json:"name"`
|
||||
ErrorMessage rest.LocalizableMessage `json:"error_message"`
|
||||
}
|
||||
|
||||
// UpdateFileValidation contains the result of validating the files in the update session
|
||||
type UpdateFileValidation struct {
|
||||
HasErrors bool `json:"has_errors"`
|
||||
MissingFiles []string `json:"missing_files,omitempty"`
|
||||
InvalidFiles []FileValidationError `json:"invalid_files,omitempty"`
|
||||
}
|
||||
|
||||
// AddLibraryItemFile adds a file
|
||||
func (c *Manager) AddLibraryItemFile(ctx context.Context, sessionID string, updateFile UpdateFile) (*UpdateFile, error) {
|
||||
url := c.Resource(internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("add")
|
||||
|
|
@ -66,29 +86,31 @@ func (c *Manager) AddLibraryItemFile(ctx context.Context, sessionID string, upda
|
|||
}
|
||||
|
||||
// AddLibraryItemFileFromURI adds a file from a remote URI.
|
||||
func (c *Manager) AddLibraryItemFileFromURI(
|
||||
ctx context.Context,
|
||||
sessionID, fileName, uri string) (*UpdateFile, error) {
|
||||
|
||||
n, fingerprint, err := c.getContentLengthAndFingerprint(ctx, uri)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
func (c *Manager) AddLibraryItemFileFromURI(ctx context.Context, sessionID, name, uri string) (*UpdateFile, error) {
|
||||
source := &TransferEndpoint{
|
||||
URI: uri,
|
||||
}
|
||||
|
||||
info, err := c.AddLibraryItemFile(ctx, sessionID, UpdateFile{
|
||||
Name: fileName,
|
||||
SourceType: "PULL",
|
||||
Size: n,
|
||||
SourceEndpoint: &TransferEndpoint{
|
||||
URI: uri,
|
||||
SSLCertificateThumbprint: fingerprint,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
file := UpdateFile{
|
||||
Name: name,
|
||||
SourceType: "PULL",
|
||||
SourceEndpoint: source,
|
||||
}
|
||||
|
||||
return info, c.CompleteLibraryItemUpdateSession(ctx, sessionID)
|
||||
if res, err := c.Head(uri); err == nil {
|
||||
file.Size = res.ContentLength
|
||||
if res.TLS != nil {
|
||||
source.SSLCertificateThumbprint = soap.ThumbprintSHA1(res.TLS.PeerCertificates[0])
|
||||
}
|
||||
} else {
|
||||
res, err := c.ProbeTransferEndpoint(ctx, *source)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
source.SSLCertificateThumbprint = res.SSLThumbprint
|
||||
}
|
||||
|
||||
return c.AddLibraryItemFile(ctx, sessionID, file)
|
||||
}
|
||||
|
||||
// GetLibraryItemUpdateSessionFile retrieves information about a specific file
|
||||
|
|
@ -102,25 +124,36 @@ func (c *Manager) GetLibraryItemUpdateSessionFile(ctx context.Context, sessionID
|
|||
return &res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
|
||||
}
|
||||
|
||||
// getContentLengthAndFingerprint gets the number of bytes returned
|
||||
// by the URI as well as the SHA1 fingerprint of the peer certificate
|
||||
// if the URI's scheme is https.
|
||||
func (c *Manager) getContentLengthAndFingerprint(
|
||||
ctx context.Context, uri string) (int64, string, error) {
|
||||
resp, err := c.Head(uri)
|
||||
if err != nil {
|
||||
return 0, "", err
|
||||
}
|
||||
if resp.TLS == nil || len(resp.TLS.PeerCertificates) == 0 {
|
||||
return resp.ContentLength, "", nil
|
||||
}
|
||||
fingerprint := c.Thumbprint(resp.Request.URL.Host)
|
||||
if fingerprint == "" {
|
||||
if c.DefaultTransport().TLSClientConfig.InsecureSkipVerify {
|
||||
fingerprint = soap.ThumbprintSHA1(resp.TLS.PeerCertificates[0])
|
||||
}
|
||||
}
|
||||
return resp.ContentLength, fingerprint, nil
|
||||
// ListLibraryItemUpdateSessionFile lists all files in the library item associated with the update session
|
||||
func (c *Manager) ListLibraryItemUpdateSessionFile(ctx context.Context, sessionID string) ([]UpdateFile, error) {
|
||||
url := c.Resource(internal.LibraryItemUpdateSessionFile).WithParam("update_session_id", sessionID)
|
||||
var res []UpdateFile
|
||||
return res, c.Do(ctx, url.Request(http.MethodGet), &res)
|
||||
}
|
||||
|
||||
// ValidateLibraryItemUpdateSessionFile validates all files in the library item associated with the update session
|
||||
func (c *Manager) ValidateLibraryItemUpdateSessionFile(ctx context.Context, sessionID string) (*UpdateFileValidation, error) {
|
||||
url := c.Resource(internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("validate")
|
||||
var res UpdateFileValidation
|
||||
return &res, c.Do(ctx, url.Request(http.MethodPost), &res)
|
||||
}
|
||||
|
||||
// RemoveLibraryItemUpdateSessionFile requests a file to be removed. The file will only be effectively removed when the update session is completed.
|
||||
func (c *Manager) RemoveLibraryItemUpdateSessionFile(ctx context.Context, sessionID string, fileName string) error {
|
||||
url := c.Resource(internal.LibraryItemUpdateSessionFile).WithID(sessionID).WithAction("remove")
|
||||
spec := struct {
|
||||
Name string `json:"file_name"`
|
||||
}{fileName}
|
||||
return c.Do(ctx, url.Request(http.MethodPost, spec), nil)
|
||||
}
|
||||
|
||||
func (c *Manager) ProbeTransferEndpoint(ctx context.Context, endpoint TransferEndpoint) (*ProbeResult, error) {
|
||||
url := c.Resource(internal.LibraryItemUpdateSessionFile).WithAction("probe")
|
||||
spec := struct {
|
||||
SourceEndpoint TransferEndpoint `json:"source_endpoint"`
|
||||
}{endpoint}
|
||||
var res ProbeResult
|
||||
return &res, c.Do(ctx, url.Request(http.MethodPost, spec), &res)
|
||||
}
|
||||
|
||||
// ReadManifest converts an ovf manifest to a map of file name -> Checksum.
|
||||
|
|
|
|||
8
vendor/github.com/vmware/govmomi/vapi/rest/client.go
generated
vendored
8
vendor/github.com/vmware/govmomi/vapi/rest/client.go
generated
vendored
|
|
@ -155,6 +155,14 @@ func (e *statusError) Error() string {
|
|||
return fmt.Sprintf("%s %s: %s", e.res.Request.Method, e.res.Request.URL, e.res.Status)
|
||||
}
|
||||
|
||||
func IsStatusError(err error, code int) bool {
|
||||
statusErr, ok := err.(*statusError)
|
||||
if !ok || statusErr == nil || statusErr.res == nil {
|
||||
return false
|
||||
}
|
||||
return statusErr.res.StatusCode == code
|
||||
}
|
||||
|
||||
// RawResponse may be used with the Do method as the resBody argument in order
|
||||
// to capture the raw response data.
|
||||
type RawResponse struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue