Skip to content

Commit 754d347

Browse files
authored
Add some constants for other CNCF projects (#710)
Signed-off-by: Valentin Delaye <jonesbusy@users.noreply.github.com>
1 parent 3c4a84b commit 754d347

3 files changed

Lines changed: 24 additions & 8 deletions

File tree

src/main/java/land/oras/utils/Const.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,24 @@ public static String currentTimestamp() {
460460
* Metric name for token refresh duration
461461
*/
462462
public static final String METRIC_TAG_REALM = "realm";
463+
464+
/**
465+
* Flux CD config media type
466+
*/
467+
public static final String FLUX_CD_CONFIG_MEDIA_TYPE = "application/vnd.cncf.flux.config.v1+json";
468+
469+
/**
470+
* Flux CD content media type
471+
*/
472+
public static final String FLUX_CD_CONTENT_MEDIA_TYPE = "application/vnd.cncf.flux.content.v1.tar+gzip";
473+
474+
/**
475+
* Helm config media type
476+
*/
477+
public static final String HELM_CONFIG_MEDIA_TYPE = "application/vnd.cncf.helm.config.v1+json";
478+
479+
/**
480+
* Helm content media type
481+
*/
482+
public static final String HELM_CONTENT_MEDIA_TYPE = "application/vnd.cncf.helm.chart.content.v1.tar+gzip";
463483
}

src/test/java/land/oras/FluxCDITCase.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,15 @@ void shouldAssembleArtifact() {
4949

5050
// The compressed manifests
5151
Path archive = Paths.get("src/test/resources/archives").resolve("flux-manifests.tgz");
52-
String configMediaType = "application/vnd.cncf.flux.config.v1+json";
53-
String contentMediaType = "application/vnd.cncf.flux.content.v1.tar+gzip";
5452

5553
Map<String, String> annotations = Map.of(
5654
Const.ANNOTATION_REVISION, "@sha1:6d63912ed9a9443dd01fbfd2991173a246050079",
5755
Const.ANNOTATION_SOURCE, "git@github.com:jonesbusy/oras-java.git",
5856
Const.ANNOTATION_CREATED, Const.currentTimestamp());
5957

6058
// Create objects
61-
Config config = Config.empty().withMediaType(configMediaType);
62-
Layer layer = Layer.fromFile(archive).withMediaType(contentMediaType);
59+
Config config = Config.empty().withMediaType(Const.FLUX_CD_CONFIG_MEDIA_TYPE);
60+
Layer layer = Layer.fromFile(archive).withMediaType(Const.FLUX_CD_CONTENT_MEDIA_TYPE);
6361
Manifest manifest =
6462
Manifest.empty().withConfig(config).withLayers(List.of(layer)).withAnnotations(annotations);
6563

src/test/java/land/oras/HelmITCase.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,15 @@ void shouldAssembleArtifact() {
4949

5050
// The compressed manifests
5151
Path archive = Paths.get("src/test/resources/archives").resolve("jenkins-chart.tgz");
52-
String configMediaType = "application/vnd.cncf.helm.config.v1+json";
53-
String contentMediaType = "application/vnd.cncf.helm.chart.content.v1.tar+gzip";
5452

5553
Map<String, String> annotations = Map.of(
5654
Const.ANNOTATION_DESCRIPTION, "Test helm chart",
5755
Const.ANNOTATION_SOURCE, "git@github.com:jonesbusy/oras-java.git",
5856
Const.ANNOTATION_CREATED, Const.currentTimestamp());
5957

6058
// Create objects
61-
Config config = Config.empty().withMediaType(configMediaType);
62-
Layer layer = Layer.fromFile(archive).withMediaType(contentMediaType);
59+
Config config = Config.empty().withMediaType(Const.HELM_CONFIG_MEDIA_TYPE);
60+
Layer layer = Layer.fromFile(archive).withMediaType(Const.HELM_CONTENT_MEDIA_TYPE);
6361
Manifest manifest =
6462
Manifest.empty().withConfig(config).withLayers(List.of(layer)).withAnnotations(annotations);
6563

0 commit comments

Comments
 (0)