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: Read install arg from file #3431

Merged
merged 7 commits into from
Nov 6, 2023
Merged

Conversation

bitdivine
Copy link
Member

@bitdivine bitdivine commented Nov 3, 2023

Description

This PR adds support for providing install arguments from a file.

This is motivated by these issues:

  • It is impossible to pass a large canister init arg as the length of shell arguments is limited by the terminal (which in turn may be limited by the operating system).
  • For shorter arguments, it is more convenient to write --argument-file somefile.hex than --argument "$(cat somefile.hex)".
  • The dfx canister call method supports --argument-file for similar reasons. It would be nice to be consistent.

How Has This Been Tested?

e2e tests are included in the PR.

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@test "installing multiple canisters with arguments fails" {
assert_command_fail dfx canister install --all --argument hello
assert_command_fail dfx canister install --all --argument '()'
Copy link
Member Author

Choose a reason for hiding this comment

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

This is so that the commands that succeed and fail are as similar as possible.

@bitdivine bitdivine changed the title Read install arg from file feat: Read install arg from file Nov 3, 2023
@bitdivine bitdivine marked this pull request as ready for review November 6, 2023 11:06
@@ -438,6 +438,7 @@ You can use the following optional flags with the `dfx canister install` command

| Flag | Description |
|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `--argument-file` | Specifies the file from which to read the argument to pass to the init method. Stdin may be referred to as `-`. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Stdin may be referred to as -.

This is not tested. Can you maybe add a test for that too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure thing. Done.

@bitdivine bitdivine enabled auto-merge (squash) November 6, 2023 13:21
@bitdivine bitdivine merged commit 12a8ea1 into master Nov 6, 2023
169 checks passed
@bitdivine bitdivine deleted the dfx-canister-install-arg-as-file branch November 6, 2023 13:57
smallstepman pushed a commit that referenced this pull request Nov 17, 2023
* feat: Read install arg from file (#3431)

# Description
This PR adds support for providing install arguments from a file.

This is motivated by these issues:

* It is impossible to pass a large canister init arg as the length of shell arguments is limited by the terminal (which in turn may be limited by the operating system).
* For shorter arguments, it is more convenient to write `--argument-file somefile.hex` than `--argument "$(cat somefile.hex)"`.
* The `dfx canister call` method supports `--argument-file` for similar reasons.  It would be nice to be consistent.

* fix: output .env file is now relative to project root, not cwd (#3435)

dfx.json can specify `output_env_file` (the default for new projects is `".env"`), and some commands accept `--output-env-file .env` on the command line.

If `dfx deploy`, `dfx build`, or `dfx canister install` were executed in a subdirectory of a project, they would create/read this file in that subdirectory, rather than the same directory as dfx.json (the project root).

With this change, the location of the env file is taken to be relative to the project root, and furthermore must be contained within the project directory.

Also fixed three places that could output "No such file or directory (OS error 2)" without telling which path wasn't found.

Fixes: https://dfinity.atlassian.net/browse/SDK-1028

* fix: dfx extension install will no longer create a corrupt cache directory (#3436)

Running `dfx extension install <extension>` immediately after installing a new dfx version, or after `dfx cache delete`, would result in a cache directory that contained only an `extensions` subdirectory.

Later, dfx would see that the cache directory exists and therefore not install it.  Then, commands like `dfx start` or `dfx build` would fail due to missing files.

Fixes: https://dfinity.atlassian.net/browse/SDK-1240

* ci: add workflow to update bitcoin canister sources (#3438)

* chore: Update Bitcoin Canister to release/2023-10-13 (#3439)

Co-authored-by: github-actions <[email protected]>

* chore: update Motoko version to 0.10.2 (#3441)

## Suggested [CHANGELOG.md](https://github.com/dfinity/sdk/edit/chore-update-motoko-0.10.2/CHANGELOG.md) changes
```
## Dependencies

### Motoko

Updated Motoko to [0.10.2](https://github.com/dfinity/motoko/releases/tag/0.10.2)

* fix: deleting project canister by id will clean up canister id store. (#3442)

`dfx canister delete <by id>` would leave entries (canister name -> canister id) in the canister id store.  A subsequent `dfx deploy` would then fail because it would try to install to the deleted canister rather than creating a new one.

Fixes https://dfinity.atlassian.net/browse/SDK-1143

* chore: Update to new ic-agent version (#3445)

* Update to new ic-agent version

* .

* fix some tests, add env var for disabling query cert

* per command

* fix other tests

* 0.30.2

* chore: Release 0.15.2-beta.2

Signed-off-by: Marcin Nowak-Liebiediew <[email protected]>

---------

Signed-off-by: Marcin Nowak-Liebiediew <[email protected]>
Co-authored-by: Max <[email protected]>
Co-authored-by: Eric Swanson <[email protected]>
Co-authored-by: DFINITY bot <[email protected]>
Co-authored-by: github-actions <[email protected]>
Co-authored-by: Adam Spofford <[email protected]>
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.

2 participants