use of io.fabric8.kubernetes.client.CustomResource in project strimzi-kafka-operator by strimzi.
the class CrdGenerator method main.
public static void main(String[] args) throws IOException, ClassNotFoundException {
CommandOptions opts = new CommandOptions(args);
CrdGenerator generator = new CrdGenerator(opts.targetKubeVersions, opts.crdApiVersion, opts.yaml ? YAML_MAPPER.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true) : JSON_MATTER, opts.labels, new DefaultReporter(), opts.apiVersions, opts.storageVersion, null, opts.conversionStrategy, opts.describeVersions);
for (Map.Entry<String, Class<? extends CustomResource>> entry : opts.classes.entrySet()) {
File file = new File(entry.getKey());
if (file.getParentFile().exists()) {
if (!file.getParentFile().isDirectory()) {
generator.err(file.getParentFile() + " is not a directory");
}
} else if (!file.getParentFile().mkdirs()) {
generator.err(file.getParentFile() + " does not exist and could not be created");
}
try (Writer w = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
generator.generate(entry.getValue(), w);
}
}
if (generator.numErrors > 0) {
System.err.println("There were " + generator.numErrors + " errors");
System.exit(1);
} else {
System.exit(0);
}
}
use of io.fabric8.kubernetes.client.CustomResource in project strimzi-kafka-operator by strimzi.
the class MockKube method mockCrs.
@SuppressWarnings({ "unchecked", "deprecation" })
public void mockCrs(KubernetesClient mockClient) {
when(mockClient.customResources(any(CustomResourceDefinitionContext.class), any(Class.class), any(Class.class))).thenAnswer(invocation -> {
Class<CustomResource> crClass = invocation.getArgument(1);
String key = crdKey(crClass);
CreateOrReplaceable createOrReplaceable = crdMixedOps.get(key);
if (createOrReplaceable == null) {
throw new RuntimeException("Unknown CRD " + key);
}
return createOrReplaceable;
});
when(mockClient.customResources(any(Class.class), any(Class.class))).thenAnswer(invocation -> {
Class<CustomResource> crClass = invocation.getArgument(0);
String key = crdKey(crClass);
CreateOrReplaceable createOrReplaceable = crdMixedOps.get(key);
if (createOrReplaceable == null) {
throw new RuntimeException("Unknown CRD " + key);
}
return createOrReplaceable;
});
when(mockClient.resources(any(Class.class), any(Class.class))).thenAnswer(invocation -> {
Class<CustomResource> crClass = invocation.getArgument(0);
String key = crdKey(crClass);
CreateOrReplaceable createOrReplaceable = crdMixedOps.get(key);
if (createOrReplaceable == null) {
throw new RuntimeException("Unknown CRD " + key);
}
return createOrReplaceable;
});
}
Aggregations