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

Add cli to generate and install plugin bundle #6397

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

andreievg
Copy link
Collaborator

Fixes #6396

πŸ‘©πŸ»β€πŸ’» What does this PR do?

Add install-plugin-bundle cli and general-and-install-plugin-bundle cli, see amc.js on notes of how to use.

πŸ’Œ Any notes for the reviewer?

There is now API accessor in the cli (api struct), which is similar to what was done in the report_builder but a bit easier on the consumer, we would use this abstraction when time comes to delete report builder

πŸ§ͺ Testing

Make changes to amc.js
Run
cargo run --bin remote_server_cli -- generate-and-install-plugin-bundle -i './service/src/backend_plugin/examples/amc' -u 'http://localhost:8000' --username 'test' --password 'pass', and see your AMC values update when looking at catalogue

@github-actions github-actions bot added this to the v2.6.0 milestone Feb 3, 2025
@github-actions github-actions bot added enhancement New feature or request feature: plugin labels Feb 3, 2025
@@ -154,6 +154,10 @@ enum Action {
},
/// Will generate a plugin bundle
GeneratePluginBundle(GeneratePluginBundle),
/// Will insert generated plugin bundle
InstallPluginBundle(InstallPluginBundle),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Was thinking maybe we just need generate and install, kept this one however as a manual was to install via CLI

@@ -0,0 +1,16 @@
pub(super) const AUTH_QUERY: &str = r#"
query AuthToken($username: String!, $password: String) {
root: authToken(password: $password, username: $username) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this root relates to the GraphQlResponse struct and Root struct, it seems cleaner to use struct with auto derived de/se and map graphql field to root, rather then manually accessing serde_json::Value type

)
.await?;

let token = result["token"].as_str().unwrap().to_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.

extracting and saving token, unwrap should be save as we've checked 'expected_typename' and query is const

.header("Cookie", auth_cooke_value);

// Add file to request
let mut file_handle =
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copied from

fn to_reqwest_multipart(
json_reqwest: &SyncUploadFileRequestV6,

query: &str,
variables: serde_json::Value,
token: Option<&str>,
expected_typename: Option<&str>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will check typename at the 'root' if specified

@@ -36,6 +42,9 @@ let plugins = {
const sql_result = sql(sql_statement);
const response = {};

// Fill all item_ids with default
item_ids.forEach((itemId) => (response[itemId] = { average_monthly_consumption: 1 }));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If there is not 'consumption' then it will be zero, changed to '1' to see effect of the plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature: plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it easier to generate and install plugin bundle
1 participant