Skip to content

Commit 860becc

Browse files
committed
node: Add a flag to graphman to list all deployments
Fixes #3407
1 parent 3f7fe67 commit 860becc

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

node/src/bin/manager.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ pub enum Command {
106106
/// the shard by adding `:shard` to the IPFS hash.
107107
Info {
108108
/// The deployment (see above)
109-
deployment: DeploymentSearch,
109+
deployment: Option<DeploymentSearch>,
110+
/// List all the deployments in the graph-node
111+
#[clap(long, short)]
112+
all: bool,
110113
/// List only current version
111114
#[clap(long, short)]
112115
current: bool,
@@ -979,14 +982,29 @@ async fn main() -> anyhow::Result<()> {
979982
pending,
980983
status,
981984
used,
985+
all,
982986
} => {
983987
let (primary, store) = if status {
984988
let (store, primary) = ctx.store_and_primary();
985989
(primary, Some(store))
986990
} else {
987991
(ctx.primary_pool(), None)
988992
};
989-
commands::info::run(primary, store, deployment, current, pending, used)
993+
994+
Ok(match deployment {
995+
Some(deployment) => {
996+
commands::info::run(primary, store, deployment, current, pending, used).err();
997+
}
998+
None => {
999+
if all {
1000+
let deployment = DeploymentSearch::All;
1001+
commands::info::run(primary, store, deployment, current, pending, used)
1002+
.err();
1003+
} else {
1004+
bail!("Please specify a deployment or use --all to list all deployments");
1005+
}
1006+
}
1007+
})
9901008
}
9911009
Unused(cmd) => {
9921010
let store = ctx.subgraph_store();

node/src/manager/deployment.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ lazy_static! {
3131
pub enum DeploymentSearch {
3232
Name { name: String },
3333
Hash { hash: String, shard: Option<String> },
34+
All,
3435
Deployment { namespace: String },
3536
}
3637

@@ -42,6 +43,7 @@ impl fmt::Display for DeploymentSearch {
4243
hash,
4344
shard: Some(shard),
4445
} => write!(f, "{}:{}", hash, shard),
46+
DeploymentSearch::All => Ok(()),
4547
DeploymentSearch::Hash { hash, shard: None } => write!(f, "{}", hash),
4648
DeploymentSearch::Deployment { namespace } => write!(f, "{}", namespace),
4749
}
@@ -115,6 +117,7 @@ impl DeploymentSearch {
115117
DeploymentSearch::Deployment { namespace } => {
116118
query.filter(ds::name.eq(&namespace)).load(conn)?
117119
}
120+
DeploymentSearch::All => query.load(conn)?,
118121
};
119122
Ok(deployments)
120123
}

0 commit comments

Comments
 (0)