-
Notifications
You must be signed in to change notification settings - Fork 0
/
K8sBookGenerator.java
55 lines (46 loc) · 1.66 KB
/
K8sBookGenerator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.jkube.quickstart.karaf;
import io.fabric8.kubernetes.api.model.APIGroup;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.openshift.client.OpenShiftClient;
import org.apache.camel.BeanInject;
import org.apache.camel.CamelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.util.Random;
public class K8sBookGenerator {
private int count = 1;
private final Random random = new Random();
@BeanInject
private KubernetesClient kubernetesClient;
@BeanInject
private OpenShiftClient openShiftClient;
private final Logger logger = LoggerFactory.getLogger(K8sBookGenerator.class);
public InputStream generateOrder(CamelContext camelContext) {
final int number = random.nextInt(5) + 1;
printApiGroups();
new BookService().createBook(kubernetesClient, count);
// new OpenShiftDeploymentService().printDeploymentConfigs(logger, openShiftClient);
final String orderSource = String.format("data/order%s.xml", number);
return camelContext.getClassResolver().loadResourceAsStream(orderSource);
}
public String generateFileName() {
return String.format("order%s.xml", count++);
}
private void printApiGroups() {
logger.info("Found {} apiGroups", kubernetesClient.getApiGroups().getGroups().size());
}
}