diff --git a/internal/locale/locales/en-us.yaml b/internal/locale/locales/en-us.yaml index d5475f5f0b..2ad2a09797 100644 --- a/internal/locale/locales/en-us.yaml +++ b/internal/locale/locales/en-us.yaml @@ -485,6 +485,8 @@ arg_platforms_shared_name_description: other: Name[@] field_version: other: Version +field_arch: + other: Arch field_bitwidth: other: Bit Width fileutils_err_amend_file: diff --git a/internal/runners/platforms/platforms.go b/internal/runners/platforms/platforms.go index 5cd12af476..b024b93286 100644 --- a/internal/runners/platforms/platforms.go +++ b/internal/runners/platforms/platforms.go @@ -2,13 +2,9 @@ package platforms import ( "sort" - "strconv" "strings" "time" - "github.com/ActiveState/cli/pkg/sysinfo" - "github.com/go-openapi/strfmt" - "github.com/ActiveState/cli/internal/captain" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/pkg/platform/model" @@ -30,6 +26,7 @@ func (pv *PlatformVersion) Set(arg string) error { type Platform struct { Name string `json:"name"` Version string `json:"version"` + Arch string `json:"arch"` BitWidth string `json:"bitWidth"` } @@ -49,6 +46,7 @@ func makePlatformsFromModelPlatforms(platforms []*model.Platform) []*Platform { p.Version = *platform.KernelVersion.Version } if platform.CPUArchitecture != nil && platform.CPUArchitecture.BitWidth != nil { + p.Arch = *platform.CPUArchitecture.Name p.BitWidth = *platform.CPUArchitecture.BitWidth } @@ -71,42 +69,3 @@ type Params struct { resolvedName string // Holds the provided platforn name, or defaults to curernt platform name if not provided resolvedVersion string // Holds the provided platform version, or defaults to latest version if not provided } - -func prepareParams(ps Params) (Params, error) { - ps.resolvedName = ps.Platform.Name() - if ps.resolvedName == "" { - ps.resolvedName = sysinfo.OS().String() - } - ps.resolvedVersion = ps.Platform.Version() - if ps.resolvedVersion == "" { - return prepareLatestVersion(ps) - } - - if ps.BitWidth == 0 { - ps.BitWidth = 32 << (^uint(0) >> 63) // gets host word size - } - - return ps, nil -} - -func prepareLatestVersion(params Params) (Params, error) { - platformUUID, err := model.PlatformNameToPlatformID(params.Platform.Name()) - if err != nil { - return params, locale.WrapExternalError(err, "err_resolve_platform_id", "Could not resolve platform ID from name: {{.V0}}", params.Platform.Name()) - } - - platform, err := model.FetchPlatformByUID(strfmt.UUID(platformUUID)) - if err != nil { - return params, locale.WrapError(err, "err_fetch_platform", "Could not get platform details") - } - params.resolvedName = *platform.Kernel.Name - params.resolvedVersion = *platform.KernelVersion.Version - - bitWidth, err := strconv.Atoi(*platform.CPUArchitecture.BitWidth) - if err != nil { - return params, locale.WrapError(err, "err_platform_bitwidth", "Unable to determine platform bit width") - } - params.BitWidth = bitWidth - - return params, nil -} diff --git a/test/integration/platforms_int_test.go b/test/integration/platforms_int_test.go index cf87bf57ad..9fb5860e99 100644 --- a/test/integration/platforms_int_test.go +++ b/test/integration/platforms_int_test.go @@ -49,6 +49,7 @@ func (suite *PlatformsIntegrationTestSuite) TestPlatforms_listSimple() { expectations := []string{ "Linux", "4.18.0", + "x86", "64", } for _, expectation := range expectations { @@ -86,6 +87,7 @@ func (suite *PlatformsIntegrationTestSuite) TestPlatforms_addRemove() { expectations := []string{ platform, version, + "x86", "64", } for _, expectation := range expectations { @@ -120,6 +122,7 @@ func (suite *PlatformsIntegrationTestSuite) TestPlatforms_addRemoveLatest() { cp = ts.Spawn("platforms") cp.Expect(platform) cp.Expect(version) + cp.Expect("x86") cp.Expect("64") cp.ExpectExitCode(0) }