Skip to content

Commit

Permalink
node: Add a flag to graphman to list all deployments
Browse files Browse the repository at this point in the history
Fixes #3407
  • Loading branch information
incrypto32 committed Feb 24, 2023
1 parent 3f7fe67 commit 860becc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
22 changes: 20 additions & 2 deletions node/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ pub enum Command {
/// the shard by adding `:shard` to the IPFS hash.
Info {
/// The deployment (see above)
deployment: DeploymentSearch,
deployment: Option<DeploymentSearch>,
/// List all the deployments in the graph-node
#[clap(long, short)]
all: bool,
/// List only current version
#[clap(long, short)]
current: bool,
Expand Down Expand Up @@ -979,14 +982,29 @@ async fn main() -> anyhow::Result<()> {
pending,
status,
used,
all,
} => {
let (primary, store) = if status {
let (store, primary) = ctx.store_and_primary();
(primary, Some(store))
} else {
(ctx.primary_pool(), None)
};
commands::info::run(primary, store, deployment, current, pending, used)

Ok(match deployment {
Some(deployment) => {
commands::info::run(primary, store, deployment, current, pending, used).err();
}
None => {
if all {
let deployment = DeploymentSearch::All;
commands::info::run(primary, store, deployment, current, pending, used)
.err();
} else {
bail!("Please specify a deployment or use --all to list all deployments");
}
}
})
}
Unused(cmd) => {
let store = ctx.subgraph_store();
Expand Down
3 changes: 3 additions & 0 deletions node/src/manager/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ lazy_static! {
pub enum DeploymentSearch {
Name { name: String },
Hash { hash: String, shard: Option<String> },
All,
Deployment { namespace: String },
}

Expand All @@ -42,6 +43,7 @@ impl fmt::Display for DeploymentSearch {
hash,
shard: Some(shard),
} => write!(f, "{}:{}", hash, shard),
DeploymentSearch::All => Ok(()),
DeploymentSearch::Hash { hash, shard: None } => write!(f, "{}", hash),
DeploymentSearch::Deployment { namespace } => write!(f, "{}", namespace),
}
Expand Down Expand Up @@ -115,6 +117,7 @@ impl DeploymentSearch {
DeploymentSearch::Deployment { namespace } => {
query.filter(ds::name.eq(&namespace)).load(conn)?
}
DeploymentSearch::All => query.load(conn)?,
};
Ok(deployments)
}
Expand Down

0 comments on commit 860becc

Please sign in to comment.