Skip to content

[per-OS Packages] in devbox add, allow multiple --platform/--exclude-platform flag values #1363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 12, 2023

Conversation

savil
Copy link
Collaborator

@savil savil commented Aug 10, 2023

Summary

This PR enables calling --platform with multiple values with devbox add.

It gives the user an option to user either or both (1) comma-separated flag values (2) multiple flag invocations. Like:
--platform <platform>,<platform>...,<platform> --platform <platform> --platform <platform>

Ditto for --exclude-platform

How was it tested?

Augmented testscript unit test

@savil savil requested review from mikeland73 and gcurtis and removed request for mikeland73 August 10, 2023 22:45
@savil savil changed the title [Config Packages] in devbox add, allow multiple --platform/--exclude-platform flag values [per-OS Packages] in devbox add, allow multiple --platform/--exclude-platform flag values Aug 11, 2023
if len(platforms) == 0 {
return nil
}
for _, platform := range platforms {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make nix.EnsureValidPlatform take ...string ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 78 to 81
for _, platform := range platforms {
// Append if the platform is not already present
if !lo.SomeBy(pkg.Platforms, func(p string) bool { return p == platform }) {
pkg.Platforms = append(pkg.Platforms, platform)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg.Platforms = lo.Uniq(append(pkg.Platforms, platforms...))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if existing == platform {
alreadyPresent = true
break
for _, platform := range platforms {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lo.uniq

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -34,7 +34,7 @@ func (d *Devbox) Update(ctx context.Context, pkgs ...string) error {
// Calling Add function with the original package names, since
// Add will automatically append @latest if search is able to handle that.
// If not, it will fallback to the nixpkg format.
if err := d.Add(ctx, "" /*platform*/, "" /*excludePlatform*/, pkg.Raw); err != nil {
if err := d.Add(ctx, nil /*platforms*/, nil /*excludePlatforms*/, pkg.Raw); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pain

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we fill these in next PR

@savil savil force-pushed the savil/config-packages-2 branch from 81606cd to 0dbee1d Compare August 11, 2023 22:18
@savil savil force-pushed the savil/config-packages-3 branch from f65133a to 8790b47 Compare August 11, 2023 22:18
@savil savil force-pushed the savil/config-packages-2 branch from 0dbee1d to 25122b6 Compare August 11, 2023 22:36
@savil savil force-pushed the savil/config-packages-3 branch from 8790b47 to 1453300 Compare August 11, 2023 22:36
@savil savil force-pushed the savil/config-packages-2 branch from 25122b6 to 7f2bc7a Compare August 11, 2023 22:46
@savil savil force-pushed the savil/config-packages-3 branch from 1453300 to af97428 Compare August 11, 2023 22:46
@savil savil force-pushed the savil/config-packages-2 branch from 7f2bc7a to fbba263 Compare August 11, 2023 23:05
@savil savil force-pushed the savil/config-packages-3 branch from af97428 to d8304fd Compare August 11, 2023 23:05
@savil savil force-pushed the savil/config-packages-2 branch from fbba263 to 8bf71ad Compare August 11, 2023 23:09
@savil savil force-pushed the savil/config-packages-3 branch 3 times, most recently from e0f4a8b to a9bec28 Compare August 12, 2023 00:05
Base automatically changed from savil/config-packages-2 to main August 12, 2023 00:28
@savil savil force-pushed the savil/config-packages-3 branch from a9bec28 to fe32133 Compare August 12, 2023 00:29
@savil savil merged commit aaace72 into main Aug 12, 2023
@savil savil deleted the savil/config-packages-3 branch August 12, 2023 00:29
Copy link
Collaborator Author

@savil savil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops forgot to submit comments

@@ -34,7 +34,7 @@ func (d *Devbox) Update(ctx context.Context, pkgs ...string) error {
// Calling Add function with the original package names, since
// Add will automatically append @latest if search is able to handle that.
// If not, it will fallback to the nixpkg format.
if err := d.Add(ctx, "" /*platform*/, "" /*excludePlatform*/, pkg.Raw); err != nil {
if err := d.Add(ctx, nil /*platforms*/, nil /*excludePlatforms*/, pkg.Raw); err != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we fill these in next PR

if len(platforms) == 0 {
return nil
}
for _, platform := range platforms {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 78 to 81
for _, platform := range platforms {
// Append if the platform is not already present
if !lo.SomeBy(pkg.Platforms, func(p string) bool { return p == platform }) {
pkg.Platforms = append(pkg.Platforms, platform)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if existing == platform {
alreadyPresent = true
break
for _, platform := range platforms {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants