Skip to content

Commit 971037d

Browse files
authored
Merge pull request #3643 from ActiveState/mitchell/dx-3216
List architecture in `state platforms`.
2 parents 6eb18c5 + 7672f4a commit 971037d

File tree

3 files changed

+7
-43
lines changed

3 files changed

+7
-43
lines changed

internal/locale/locales/en-us.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,8 @@ arg_platforms_shared_name_description:
485485
other: Name[@<version>]
486486
field_version:
487487
other: Version
488+
field_arch:
489+
other: Arch
488490
field_bitwidth:
489491
other: Bit Width
490492
fileutils_err_amend_file:

internal/runners/platforms/platforms.go

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ package platforms
22

33
import (
44
"sort"
5-
"strconv"
65
"strings"
76
"time"
87

9-
"github.com/ActiveState/cli/pkg/sysinfo"
10-
"github.com/go-openapi/strfmt"
11-
128
"github.com/ActiveState/cli/internal/captain"
139
"github.com/ActiveState/cli/internal/locale"
1410
"github.com/ActiveState/cli/pkg/platform/model"
@@ -30,6 +26,7 @@ func (pv *PlatformVersion) Set(arg string) error {
3026
type Platform struct {
3127
Name string `json:"name"`
3228
Version string `json:"version"`
29+
Arch string `json:"arch"`
3330
BitWidth string `json:"bitWidth"`
3431
}
3532

@@ -49,6 +46,7 @@ func makePlatformsFromModelPlatforms(platforms []*model.Platform) []*Platform {
4946
p.Version = *platform.KernelVersion.Version
5047
}
5148
if platform.CPUArchitecture != nil && platform.CPUArchitecture.BitWidth != nil {
49+
p.Arch = *platform.CPUArchitecture.Name
5250
p.BitWidth = *platform.CPUArchitecture.BitWidth
5351
}
5452

@@ -71,42 +69,3 @@ type Params struct {
7169
resolvedName string // Holds the provided platforn name, or defaults to curernt platform name if not provided
7270
resolvedVersion string // Holds the provided platform version, or defaults to latest version if not provided
7371
}
74-
75-
func prepareParams(ps Params) (Params, error) {
76-
ps.resolvedName = ps.Platform.Name()
77-
if ps.resolvedName == "" {
78-
ps.resolvedName = sysinfo.OS().String()
79-
}
80-
ps.resolvedVersion = ps.Platform.Version()
81-
if ps.resolvedVersion == "" {
82-
return prepareLatestVersion(ps)
83-
}
84-
85-
if ps.BitWidth == 0 {
86-
ps.BitWidth = 32 << (^uint(0) >> 63) // gets host word size
87-
}
88-
89-
return ps, nil
90-
}
91-
92-
func prepareLatestVersion(params Params) (Params, error) {
93-
platformUUID, err := model.PlatformNameToPlatformID(params.Platform.Name())
94-
if err != nil {
95-
return params, locale.WrapExternalError(err, "err_resolve_platform_id", "Could not resolve platform ID from name: {{.V0}}", params.Platform.Name())
96-
}
97-
98-
platform, err := model.FetchPlatformByUID(strfmt.UUID(platformUUID))
99-
if err != nil {
100-
return params, locale.WrapError(err, "err_fetch_platform", "Could not get platform details")
101-
}
102-
params.resolvedName = *platform.Kernel.Name
103-
params.resolvedVersion = *platform.KernelVersion.Version
104-
105-
bitWidth, err := strconv.Atoi(*platform.CPUArchitecture.BitWidth)
106-
if err != nil {
107-
return params, locale.WrapError(err, "err_platform_bitwidth", "Unable to determine platform bit width")
108-
}
109-
params.BitWidth = bitWidth
110-
111-
return params, nil
112-
}

test/integration/platforms_int_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func (suite *PlatformsIntegrationTestSuite) TestPlatforms_listSimple() {
4949
expectations := []string{
5050
"Linux",
5151
"4.18.0",
52+
"x86",
5253
"64",
5354
}
5455
for _, expectation := range expectations {
@@ -86,6 +87,7 @@ func (suite *PlatformsIntegrationTestSuite) TestPlatforms_addRemove() {
8687
expectations := []string{
8788
platform,
8889
version,
90+
"x86",
8991
"64",
9092
}
9193
for _, expectation := range expectations {
@@ -120,6 +122,7 @@ func (suite *PlatformsIntegrationTestSuite) TestPlatforms_addRemoveLatest() {
120122
cp = ts.Spawn("platforms")
121123
cp.Expect(platform)
122124
cp.Expect(version)
125+
cp.Expect("x86")
123126
cp.Expect("64")
124127
cp.ExpectExitCode(0)
125128
}

0 commit comments

Comments
 (0)