Add globalrefdb show-ref command Change-Id: I0451f9da00e5149ca3b976923cd72f0bc0beca57
diff --git a/multi-primary/globalrefdb.groovy b/multi-primary/globalrefdb.groovy index 7ad1ecf..65f6803 100644 --- a/multi-primary/globalrefdb.groovy +++ b/multi-primary/globalrefdb.groovy
@@ -174,5 +174,31 @@ } } -commands = [ ProjectRefsCheck, ProjectRefsUpdate ] +@Export("show-ref") +@CommandMetaData(description = "Get global-refdb refs values for a project") +@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER) +class ProjectRefsGet extends BaseSshCommand { + + @Argument(index = 0, usage = "Project name", metaVar = "PROJECT", required = true) + String project + + @Option(name = "--ref", usage = "Global-refdb ref(s) requested", required = true) + ArrayList<String> refs + + @Inject + DynamicItem<GlobalRefDatabase> globalRefDb + + public void run() { + def projectName = Project.nameKey(project) + + refs.each { ref -> + def sha = globalRefDb.get().get(projectName, ref, String.class) + if (sha.isPresent()) { + println "${sha.get()} ${ref}" + } + } + } +} + +commands = [ ProjectRefsCheck, ProjectRefsUpdate, ProjectRefsGet ]
diff --git a/multi-primary/globalrefdb.md b/multi-primary/globalrefdb.md index 45a5d0f..1ae826c 100644 --- a/multi-primary/globalrefdb.md +++ b/multi-primary/globalrefdb.md
@@ -13,6 +13,7 @@ -------- > ssh -p <port> <host> globalrefdb check PROJECT [--ref <ref name>] [--verbose] > ssh -p <port> <host> globalrefdb update-ref PROJECT REF-NAME NEW-VALUE +> ssh -p <port> <host> globalrefdb show-ref PROJECT [--ref <ref name>]* DESCRIPTION ----------- @@ -27,6 +28,9 @@ the latest. This can happen if the global-refdb finds itself behind other nodes. +## Show-ref +Shows the global-refdb ref value, when present. + ACCESS ------ Any user who has been granted the 'Administrate Server' capability.