mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-06-08 14:42:53 -04:00
cli: fix Azure SEV-SNP latest version logic (#2343)
This commit is contained in:
parent
2776e40df7
commit
118f789c2f
26 changed files with 547 additions and 245 deletions
|
@ -8,13 +8,11 @@ package attestationconfigapi
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
)
|
||||
|
||||
// attestationURLPath is the URL path to the attestation versions.
|
||||
|
@ -41,11 +39,6 @@ type AzureSEVSNPVersionAPI struct {
|
|||
AzureSEVSNPVersion
|
||||
}
|
||||
|
||||
// URL returns the URL for the request to the config api.
|
||||
func (i AzureSEVSNPVersionAPI) URL() (string, error) {
|
||||
return getURL(i)
|
||||
}
|
||||
|
||||
// JSONPath returns the path to the JSON file for the request to the config api.
|
||||
func (i AzureSEVSNPVersionAPI) JSONPath() string {
|
||||
return path.Join(attestationURLPath, variant.AzureSEVSNP{}.String(), i.Version)
|
||||
|
@ -67,11 +60,6 @@ func (i AzureSEVSNPVersionAPI) Validate() error {
|
|||
// AzureSEVSNPVersionList is the request to list all versions in the config api.
|
||||
type AzureSEVSNPVersionList []string
|
||||
|
||||
// URL returns the URL for the request to the config api.
|
||||
func (i AzureSEVSNPVersionList) URL() (string, error) {
|
||||
return getURL(i)
|
||||
}
|
||||
|
||||
// JSONPath returns the path to the JSON file for the request to the config api.
|
||||
func (i AzureSEVSNPVersionList) JSONPath() string {
|
||||
return path.Join(attestationURLPath, variant.AzureSEVSNP{}.String(), "list")
|
||||
|
@ -94,16 +82,3 @@ func (i AzureSEVSNPVersionList) Validate() error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getURL(obj jsoPather) (string, error) {
|
||||
url, err := url.Parse(constants.CDNRepositoryURL)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("parsing CDN URL: %w", err)
|
||||
}
|
||||
url.Path = obj.JSONPath()
|
||||
return url.String(), nil
|
||||
}
|
||||
|
||||
type jsoPather interface {
|
||||
JSONPath() string
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue