Skip to content

Commit

Permalink
Restore requirementBitWidth parameter.
Browse files Browse the repository at this point in the history
It's needed for identifying languages to install. Without it, we'd get a "Unsupported platform: Windows -1 10.0.17134.1" error.

Also fix some nil pointer exceptions.
  • Loading branch information
mitchell-as committed Dec 15, 2023
1 parent 4cb78a5 commit 021913e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 4 deletions.
9 changes: 6 additions & 3 deletions internal/runbits/requirements/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type ErrNoMatches struct {
// The refactor should clean this up.
func (r *RequirementOperation) ExecuteRequirementOperation(
requirementName, requirementVersion string,
requirementBitWidth int,
operation bpModel.Operation, ns *model.Namespace, nsType *model.NamespaceType, ts *time.Time) (rerr error) {
defer r.rationalizeError(&rerr)

Expand Down Expand Up @@ -130,10 +131,14 @@ func (r *RequirementOperation) ExecuteRequirementOperation(
} else {
logging.Debug("Could not get language from project: %v", err)
}
case model.NamespaceLanguage:
ns = ptr.To(model.NewNamespaceLanguage())
case model.NamespacePlatform:
ns = ptr.To(model.NewNamespacePlatform())
}
}

var validatePkg = operation == bpModel.OperationAdded && (ns.Type() == model.NamespacePackage || ns.Type() == model.NamespaceBundle)
var validatePkg = operation == bpModel.OperationAdded && ns != nil && (ns.Type() == model.NamespacePackage || ns.Type() == model.NamespaceBundle)
if (ns == nil || !ns.IsValid()) && nsType != nil && (*nsType == model.NamespacePackage || *nsType == model.NamespaceBundle) {
pg = output.StartSpinner(out, locale.Tr("progress_pkg_nolang", requirementName), constants.TerminalAnimationInterval)

Expand Down Expand Up @@ -243,8 +248,6 @@ func (r *RequirementOperation) ExecuteRequirementOperation(
}
timestamp := strfmt.DateTime(*ts)

// MUST ADDRESS: we're no longer passing bitwidth, but this needs it. Need to figure out why.
requirementBitWidth := -1
name, version, err := model.ResolveRequirementNameAndVersion(requirementName, requirementVersion, requirementBitWidth, *ns)
if err != nil {
return errs.Wrap(err, "Could not resolve requirement name and version")
Expand Down
2 changes: 1 addition & 1 deletion internal/runners/languages/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (u *Update) Run(params *UpdateParams) error {
return errs.Wrap(err, "Could not create requirement operation.")
}

err = op.ExecuteRequirementOperation(lang.Name, lang.Version, bpModel.OperationAdded, nil, &model.NamespaceLanguage, nil)
err = op.ExecuteRequirementOperation(lang.Name, lang.Version, 0, bpModel.OperationAdded, nil, &model.NamespaceLanguage, nil)
if err != nil {
return locale.WrapError(err, "err_language_update", "Could not update language: {{.V0}}", lang.Name)
}
Expand Down
1 change: 1 addition & 0 deletions internal/runners/packages/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (a *Install) Run(params InstallRunParams, nsType model.NamespaceType) (rerr
return requirements.NewRequirementOperation(a.prime).ExecuteRequirementOperation(
params.Package.Name,
params.Package.Version,
0,

This comment has been minimized.

Copy link
@MDrakos

MDrakos Dec 15, 2023

Member

It might be good to have a constant that describes what this is so that we don't have to look elsewhere when working on this code

bpModel.OperationAdded,
ns,
nsTypeV,
Expand Down
1 change: 1 addition & 0 deletions internal/runners/packages/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (u *Uninstall) Run(params UninstallRunParams, nsType model.NamespaceType) (
return requirements.NewRequirementOperation(u.prime).ExecuteRequirementOperation(
params.Package.Name,
"",
0,
bpModel.OperationRemoved,
ns,
nsTypeV,
Expand Down
1 change: 1 addition & 0 deletions internal/runners/platforms/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (a *Add) Run(ps AddRunParams) error {
if err := requirements.NewRequirementOperation(a.prime).ExecuteRequirementOperation(
params.name,
params.version,
params.BitWidth,
bpModel.OperationAdded,
nil,
&model.NamespacePlatform,
Expand Down
1 change: 1 addition & 0 deletions internal/runners/platforms/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (r *Remove) Run(ps RemoveRunParams) error {
if err := requirements.NewRequirementOperation(r.prime).ExecuteRequirementOperation(
params.name,
params.version,
params.BitWidth,
bpModel.OperationRemoved,
nil,
&model.NamespacePlatform,
Expand Down

0 comments on commit 021913e

Please sign in to comment.