fix: Azure SEV-SNP version always gets overwritten by latest API versions (#1930)

* fix that manual version gets overwritten by latest

* put azure in seperate config file

* otto feedback
This commit is contained in:
Adrian Stobbe 2023-06-14 14:17:52 +02:00 committed by GitHub
parent c1f9d86cd3
commit c5f75513b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 202 additions and 142 deletions

View file

@ -17,20 +17,20 @@ const placeholderVersionValue = 0
// NewLatestPlaceholderVersion returns the latest version with a placeholder version value.
func NewLatestPlaceholderVersion() AttestationVersion {
return AttestationVersion{
Value: placeholderVersionValue,
IsLatest: true,
Value: placeholderVersionValue,
WantLatest: true,
}
}
// AttestationVersion is a type that represents a version of a SNP.
type AttestationVersion struct {
Value uint8
IsLatest bool
Value uint8
WantLatest bool
}
// MarshalYAML implements a custom marshaller to resolve "latest" values.
func (v AttestationVersion) MarshalYAML() (any, error) {
if v.IsLatest {
if v.WantLatest {
return "latest", nil
}
return v.Value, nil
@ -48,7 +48,7 @@ func (v *AttestationVersion) UnmarshalYAML(unmarshal func(any) error) error {
// MarshalJSON implements a custom marshaller to resolve "latest" values.
func (v AttestationVersion) MarshalJSON() ([]byte, error) {
if v.IsLatest {
if v.WantLatest {
return json.Marshal("latest")
}
return json.Marshal(v.Value)
@ -67,7 +67,7 @@ func (v *AttestationVersion) parseRawUnmarshal(rawUnmarshal any) error {
switch s := rawUnmarshal.(type) {
case string:
if strings.ToLower(s) == "latest" {
v.IsLatest = true
v.WantLatest = true
v.Value = placeholderVersionValue
} else {
return fmt.Errorf("invalid version value: %s", s)