Skip to content

Commit

Permalink
Merge pull request #261 from open-amt-cloud-toolkit/featurespayload
Browse files Browse the repository at this point in the history
feat: add features field to message payload
  • Loading branch information
rjbrache authored Oct 13, 2023
2 parents b9ac2ae + 184f9d8 commit 6db0cd3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/local/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (service *ProvisioningService) DisplayAMTInfo() utils.ReturnCode {
}
}
if service.flags.AmtInfo.Ver && service.flags.AmtInfo.Sku {
result := decodeAMT(dataStruct["amt"].(string), dataStruct["sku"].(string))
result := DecodeAMT(dataStruct["amt"].(string), dataStruct["sku"].(string))
dataStruct["features"] = strings.TrimSpace(result)
if !service.flags.JsonOutput {
println("Features : " + result)
Expand Down Expand Up @@ -259,7 +259,7 @@ func (service *ProvisioningService) DisplayAMTInfo() utils.ReturnCode {
return utils.Success
}

func decodeAMT(version, SKU string) string {
func DecodeAMT(version, SKU string) string {
amtParts := strings.Split(version, ".")
if len(amtParts) <= 1 {
return "Invalid AMT version format"
Expand Down
4 changes: 2 additions & 2 deletions internal/local/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ func TestDecodeAMT(t *testing.T) {
}

for _, tc := range testCases {
got := decodeAMT(tc.version, tc.SKU)
got := DecodeAMT(tc.version, tc.SKU)
if got != tc.want {
t.Errorf("decodeAMT(%q, %q) = %v; want %v", tc.version, tc.SKU, got, tc.want)
t.Errorf("DecodeAMT(%q, %q) = %v; want %v", tc.version, tc.SKU, got, tc.want)
}
}
}
5 changes: 5 additions & 0 deletions internal/rps/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os"
"rpc/internal/amt"
"rpc/internal/flags"
"rpc/internal/local"
"rpc/pkg/utils"
"time"

Expand Down Expand Up @@ -47,6 +48,7 @@ type MessagePayload struct {
Version string `json:"ver"`
Build string `json:"build"`
SKU string `json:"sku"`
Features string `json:"features"`
UUID string `json:"uuid"`
Username string `json:"username"`
Password string `json:"password"`
Expand Down Expand Up @@ -86,6 +88,9 @@ func (p Payload) createPayload(dnsSuffix string, hostname string, amtTimeout tim
if err != nil {
return payload, err
}

payload.Features = local.DecodeAMT(payload.Version, payload.SKU)

payload.UUID, err = p.AMT.GetUUID()
if err != nil {
return payload, err
Expand Down

0 comments on commit 6db0cd3

Please sign in to comment.