Skip to content

Commit 54af3d5

Browse files
authored
Missing @OrasModel for reflection access (#573)
2 parents f16621f + 3ecfbc2 commit 54af3d5

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/main/java/land/oras/auth/AuthStore.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.Objects;
3333
import java.util.concurrent.ConcurrentHashMap;
3434
import land.oras.ContainerRef;
35+
import land.oras.OrasModel;
3536
import land.oras.exception.OrasException;
3637
import land.oras.utils.JsonUtils;
3738
import org.jspecify.annotations.NullMarked;
@@ -295,6 +296,7 @@ private static Credential getFromCredentialHelper(String suffix, String hostname
295296
* @param username The username for the credential.
296297
* @param password The password for the credential.
297298
*/
299+
@OrasModel
298300
public record Credential(String username, String password) {
299301
/**
300302
* Constructs a new {@code Credential} object with the specified username and password.

src/main/java/land/oras/auth/RegistriesConf.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.Objects;
3535
import java.util.Optional;
3636
import land.oras.ContainerRef;
37+
import land.oras.OrasModel;
3738
import land.oras.exception.OrasException;
3839
import land.oras.utils.Const;
3940
import land.oras.utils.TomlUtils;
@@ -105,6 +106,7 @@ public static RegistriesConf newConf() {
105106
* @param blocked Whether the registry is blocked. If true, the registry is blocked and cannot be used for pulling or pushing images.
106107
* @param insecure Whether the registry is insecure. If true, the registry is considered insecure and may allow connections over HTTP or with invalid TLS certificates.
107108
*/
109+
@OrasModel
108110
record RegistryConfig(
109111
@Nullable @JsonProperty("prefix") String prefix,
110112
@Nullable @JsonProperty("location") String location,
@@ -124,6 +126,7 @@ public boolean isInsecure() {
124126
* @param host The host component of the prefix, which can be a specific hostname or a wildcard pattern (e.g., *.example.com).
125127
* @param path The path component of the prefix, which can be a specific path or a path prefix (e.g., namespace/repo).
126128
*/
129+
@OrasModel
127130
record ParsedPrefix(String host, String path) {
128131

129132
static ParsedPrefix parse(String prefix) {
@@ -138,6 +141,7 @@ static ParsedPrefix parse(String prefix) {
138141
/**
139142
* The for handling short name
140143
*/
144+
@OrasModel
141145
enum ShortNameMode {
142146

143147
/**
@@ -179,6 +183,7 @@ public String getKey() {
179183
* @param aliases The map of registry aliases, where the key is the alias and the value is the actual registry URL.
180184
* @param unqualifiedRegistries The list of unqualified registries, which are registries that can be used without specifying a registry.
181185
*/
186+
@OrasModel
182187
record ConfigFile(
183188
@JsonProperty("short-name-mode") @Nullable ShortNameMode shortNameMode,
184189
@JsonProperty("registry") @Nullable List<RegistryConfig> registries,

src/test/java/land/oras/ClassAnnotationsTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void shouldHaveAnnotationOnModel() {
4848
.loadClasses());
4949

5050
// Check number of classes
51-
assertEquals(19, modelClasses.size());
51+
assertEquals(20, modelClasses.size());
5252

5353
// Check classes
5454
assertTrue(modelClasses.contains(Annotations.class));
@@ -68,4 +68,20 @@ void shouldHaveAnnotationOnModel() {
6868
assertTrue(modelClasses.contains(Tags.class));
6969
}
7070
}
71+
72+
@Test
73+
void shouldHaveAnnotationOnAuthPackage() {
74+
try (ScanResult scanResult = new ClassGraph()
75+
.enableClassInfo()
76+
.enableAnnotationInfo()
77+
.acceptPackages("land.oras.auth")
78+
.scan()) {
79+
Set<Class<?>> modelClasses = new HashSet<>(scanResult
80+
.getClassesWithAnnotation(OrasModel.class.getName())
81+
.loadClasses());
82+
83+
// Check number of classes
84+
assertEquals(2, modelClasses.size());
85+
}
86+
}
7187
}

0 commit comments

Comments
 (0)