Skip to content
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

feat(wash-lib)!: add support for inspecting wit #1161

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

brooksmtownsend
Copy link
Member

Feature or Problem

This PR allows wash users to add --wit after or before their file/oci reference to print out the embedded wit world in a WASI preview 2 component. In the case that it is an empty wit world, it's assumed that it is a WASI preview 1 component and we output a message accordingly.

I also changed the heading from the claims inspect from Module to Actor and Provider Archive to Capability Provider. Keeping it as module just felt confusing when we'll be inspecting components too.

cargo run -- inspect wasmcloud.azurecr.io/echo:0.3.4      
    Finished dev [unoptimized + debuginfo] target(s) in 0.36s
     Running `/Users/brooks/github.com/wasmcloud/wasmCloud/target/debug/wash inspect 'wasmcloud.azurecr.io/echo:0.3.4'`

                                                                          
                               Echo - Actor                               
  Account       ACOJJN6WUP4ODD75XEBKKTCCUJJCY5ZKQ56XVKYK4BEJWGVAOOQHZMCW  
  Actor         MBCFOPM6JW2APJLXJD3Z5O4CN7CPYJ2B4FTKLJUR5YR5MITIU7HD3WD5  
  Expires                                                          never  
  Can Be Used                                                immediately  
  Version                                                      0.3.4 (4)  
  Call Alias                                                   (Not set)  
                               Capabilities                               
  HTTP Server                                                             
                                   Tags                                   
  None  

Related Issues

Related to #336

Release Information

wash-lib 0.16.0

Consumer Impact

This is a backwards compatible change in wash-cli, but consumers of wash-lib that are instantiating the full InspectCommand struct will need to add the wit boolean field.

Testing

Unit Test(s)

Acceptance or Integration

Manual Verification

Module

cargo run -- inspect wasmcloud.azurecr.io/echo:0.3.4 --wit                    
    Finished dev [unoptimized + debuginfo] target(s) in 0.38s
     Running `/Users/brooks/github.com/wasmcloud/wasmCloud/target/debug/wash inspect 'wasmcloud.azurecr.io/echo:0.3.4' --wit`

WIT World 'root' is empty, this looks like a WASI Preview 1 Module

Component

➜ cargo run -- inspect ~/demo/componentize-js/hello_s.component.wasm --wit 
    Finished dev [unoptimized + debuginfo] target(s) in 0.38s
     Running `/Users/brooks/github.com/wasmcloud/wasmCloud/target/debug/wash inspect /Users/brooks/demo/componentize-js/hello_s.component.wasm --wit`

package root:component;

world root {
  import wasi:io/error@0.2.0-rc-2023-11-10;
  import wasi:io/streams@0.2.0-rc-2023-11-10;
  import wasi:filesystem/types@0.2.0-rc-2023-11-10;
  import wasi:filesystem/preopens@0.2.0-rc-2023-11-10;
  import wasi:sockets/tcp@0.2.0-rc-2023-11-10;
  import wasi:cli/stdin@0.2.0-rc-2023-11-10;
  import wasi:cli/stdout@0.2.0-rc-2023-11-10;
  import wasi:cli/stderr@0.2.0-rc-2023-11-10;
  import wasi:cli/terminal-input@0.2.0-rc-2023-11-10;
  import wasi:cli/terminal-output@0.2.0-rc-2023-11-10;
  import wasi:cli/terminal-stdin@0.2.0-rc-2023-11-10;
  import wasi:cli/terminal-stdout@0.2.0-rc-2023-11-10;
  import wasi:cli/terminal-stderr@0.2.0-rc-2023-11-10;

  export wasmcloud:bus/guest;
}

@brooksmtownsend brooksmtownsend requested a review from a team as a code owner December 12, 2023 19:34
@brooksmtownsend brooksmtownsend force-pushed the feat/inspect-wit-support branch 2 times, most recently from b8119a8 to c86f7b9 Compare December 12, 2023 21:32
rvolosatovs

This comment was marked as outdated.

crates/wash-lib/src/cli/inspect.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@vados-cosmonic vados-cosmonic left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

crates/wash-lib/src/cli/claims.rs Show resolved Hide resolved
crates/wash-lib/src/cli/inspect.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@connorsmith256 connorsmith256 left a comment

Choose a reason for hiding this comment

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

A couple in-line questions, and one here: I see updated tests for the default case, but not a test case for the new functionality. Shouldn't we have a new test for that?

crates/wash-lib/src/cli/inspect.rs Outdated Show resolved Hide resolved
crates/wash-lib/src/cli/inspect.rs Outdated Show resolved Hide resolved
crates/wash-lib/src/cli/inspect.rs Show resolved Hide resolved
crates/wash-lib/src/cli/claims.rs Show resolved Hide resolved
Signed-off-by: Brooks Townsend <brooksmtownsend@gmail.com>

satisfy overlord

Signed-off-by: Brooks Townsend <brooksmtownsend@gmail.com>

edge case

Signed-off-by: Brooks Townsend <brooksmtownsend@gmail.com>

use wasmparser to parse inspect

Signed-off-by: Brooks Townsend <brooksmtownsend@gmail.com>

address PR comments

Signed-off-by: Brooks Townsend <brooksmtownsend@gmail.com>
@brooksmtownsend brooksmtownsend merged commit a864157 into main Dec 13, 2023
50 checks passed
@brooksmtownsend brooksmtownsend deleted the feat/inspect-wit-support branch December 13, 2023 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants