-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose repository hosts through authenticated api call
- Loading branch information
Showing
16 changed files
with
158 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
## deployable containers have a semantic and build tag | ||
# version tag: major.minor.patch | ||
# build version tag: timestamp | ||
VER=0.23.0 | ||
VER=0.23.1 | ||
TAGS="${VER} ${VER}-$(date -u +"%Y%m%dT%H%M%S")" | ||
unset VER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
skaha/src/main/java/org/opencadc/skaha/repository/GetAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.opencadc.skaha.repository; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStreamWriter; | ||
import java.io.Writer; | ||
import java.util.Arrays; | ||
import org.json.JSONWriter; | ||
import org.opencadc.skaha.SkahaAction; | ||
|
||
/** | ||
* Output the resource context information. | ||
* | ||
* @author majorb | ||
*/ | ||
public class GetAction extends SkahaAction { | ||
|
||
@Override | ||
public void doAction() throws Exception { | ||
initRequest(); | ||
final Writer writer = initWriter(); | ||
final JSONWriter jsonWriter = new JSONWriter(writer).array(); | ||
try { | ||
Arrays.stream(getHarborHosts()).forEach(jsonWriter::value); | ||
} finally { | ||
jsonWriter.endArray(); | ||
writer.flush(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void initRequest() throws Exception { | ||
super.initRequest(); | ||
} | ||
|
||
Writer initWriter() throws IOException { | ||
this.syncOutput.setHeader("content-type", "application/json"); | ||
return new OutputStreamWriter(syncOutput.getOutputStream()); | ||
} | ||
|
||
String[] getHarborHosts() { | ||
return this.harborHosts.toArray(new String[0]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
skaha/src/test/java/org/opencadc/skaha/repository/GetActionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.opencadc.skaha.repository; | ||
|
||
import java.io.StringWriter; | ||
import java.io.Writer; | ||
import org.json.JSONArray; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class GetActionTest { | ||
@Test | ||
public void ensureJSON() throws Exception { | ||
final String[] hostArray = new String[] {"images.example.org", "images2.example.org"}; | ||
final Writer writer = new StringWriter(); | ||
final GetAction testSubject = new GetAction() { | ||
@Override | ||
protected void initRequest() { | ||
// Do nothing. | ||
} | ||
|
||
@Override | ||
Writer initWriter() { | ||
return writer; | ||
} | ||
|
||
@Override | ||
String[] getHarborHosts() { | ||
return hostArray; | ||
} | ||
}; | ||
|
||
testSubject.doAction(); | ||
|
||
final JSONArray resultArray = new JSONArray(writer.toString()); | ||
final String[] resultStringArray = | ||
resultArray.toList().stream().map(Object::toString).toArray(String[]::new); | ||
|
||
Assert.assertArrayEquals("Wrong host array", hostArray, resultStringArray); | ||
} | ||
} |
Oops, something went wrong.