本文整理汇总了Java中io.fabric8.openshift.api.model.Template类的典型用法代码示例。如果您正苦于以下问题:Java Template类的具体用法?Java Template怎么用?Java Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Template类属于io.fabric8.openshift.api.model包,在下文中一共展示了Template类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: OpenShiftTemplate
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
public OpenShiftTemplate(OpenShiftClient client, OpenShiftRuntimeConfig runtimeConfig) {
Loadable<TemplateResource<Template, KubernetesList, DoneableTemplate>> loadable = null;
String prjName = runtimeConfig.getProjectName();
String templateUri = runtimeConfig.getResourceTemplateUri();
String templateName = runtimeConfig.getResourceTemplateName();
if (prjName != null) {
loadable = client.getDelegate().templates().inNamespace(prjName);
} else {
loadable = client.getDelegate().templates();
}
TemplateResource<Template, KubernetesList, DoneableTemplate> res = null;
if (templateUri != null) {
URL templateUrl = client.toUrl(templateUri);
if (templateUrl != null) {
res = loadable.load(templateUrl);
}
} else if (templateName != null && !templateName.isEmpty()) {
res = loadable.load(templateName);
}
resource = res;
template = res != null ? res.get() : null;
if (template == null) {
throw new OpenShiftClientException(String.format("could not load template with project [%s] and uri [%s] or name [%s]", prjName, templateUri, templateName));
}
}
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:26,代码来源:OpenShiftTemplate.java
示例2: applyParameterValueProperties
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
private void applyParameterValueProperties(final OpenShiftProject project, final Template template) {
RouteList routes = null;
for (Parameter parameter : template.getParameters()) {
// Find any parameters with special "fabric8-value" properties
if (parameter.getAdditionalProperties().containsKey("fabric8-value")
&& parameter.getValue() == null) {
String value = parameter.getAdditionalProperties().get("fabric8-value").toString();
Matcher m = PARAM_VAR_PATTERN.matcher(value);
StringBuffer newval = new StringBuffer();
while (m.find()) {
String type = m.group(1);
String routeName = m.group(2);
String propertyPath = m.group(3);
String propertyValue = "";
// We only support "route/XXX[.spec.host]" for now,
// but we're prepared for future expansion
if ("route".equals(type) && ".spec.host".equals(propertyPath)) {
// Try to find a Route with that name and use its host name
if (routes == null) {
routes = client.routes().inNamespace(project.getName()).list();
}
propertyValue = routes.getItems().stream()
.filter(r -> routeName.equals(r.getMetadata().getName()))
.map(r -> r.getSpec().getHost())
.filter(Objects::nonNull)
.findAny()
.orElse(propertyValue);
}
m.appendReplacement(newval, Matcher.quoteReplacement(propertyValue));
}
m.appendTail(newval);
parameter.setValue(newval.toString());
}
}
}
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:36,代码来源:Fabric8OpenShiftServiceImpl.java
示例3: processTemplate
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
public KubernetesList processTemplate(Template template, Map<String, String> parameters) {
ParameterValue[] values = processParameters(parameters);
return withDefaultUser(client -> {
client.templates().createOrReplace(template);
return client.templates().withName(template.getMetadata().getName()).process(values);
});
}
开发者ID:syndesisio,项目名称:syndesis-qe,代码行数:10,代码来源:OpenShiftUtils.java
示例4: getTemplate
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
public static Template getTemplate() {
try (InputStream is = new URL(TEMPLATE_URL).openStream()) {
return OpenShiftUtils.getInstance().withDefaultUser(client -> client.templates().load(is).get());
} catch (IOException ex) {
throw new IllegalArgumentException("Unable to read template ", ex);
}
}
开发者ID:syndesisio,项目名称:syndesis-qe,代码行数:8,代码来源:SyndesisTemplate.java
示例5: deploy
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
public static void deploy() {
Template template = null;
try (InputStream is = ClassLoader.getSystemResourceAsStream("templates/syndesis-amq.yml")) {
template = OpenShiftUtils.getInstance().withDefaultUser(client -> client.templates().load(is).get());
} catch (IOException ex) {
throw new IllegalArgumentException("Unable to read template ", ex);
}
Map<String, String> templateParams = new HashMap<>();
templateParams.put("MQ_USERNAME", "amq");
templateParams.put("MQ_PASSWORD", "topSecret");
// try to clean previous broker
cleanUp();
OpenShiftUtils.getInstance().withDefaultUser(c -> c.templates().withName("syndesis-amq").delete());
KubernetesList processedTemplate = OpenShiftUtils.getInstance().processTemplate(template, templateParams);
OpenShiftUtils.getInstance().createResources(processedTemplate);
try {
OpenShiftWaitUtils.waitFor(OpenShiftWaitUtils.isAPodReady("application", "broker"));
} catch (InterruptedException | TimeoutException e) {
log.error("Wait for syndesis-rest failed ", e);
}
Account amqAccount = new Account();
amqAccount.setService("amq");
Map<String, String> accountParameters = new HashMap<>();
accountParameters.put("brokerUrl", "tcp://broker-amq:61616");
accountParameters.put("username", "amq");
accountParameters.put("password", "topSecret");
accountParameters.put("clientId", UUID.randomUUID().toString());
amqAccount.setProperties(accountParameters);
AccountsDirectory.getInstance().addAccount("AMQ", amqAccount);
}
开发者ID:syndesisio,项目名称:syndesis-qe,代码行数:34,代码来源:AmqTemplate.java
示例6: processTemplate
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
/**
* This method will delete the existing template and replace it with a new
* one (all in current namespace) and process it afterwards.
*/
public KubernetesList processTemplate(Template template, Map<String, String> parameters) {
ParameterValue[] values = processParameters(parameters);
return withDefaultUser(client -> {
// delete existing
client.templates().withName(template.getMetadata().getName()).delete();
// create new
client.templates().create(template);
// return processed template
return client.templates().withName(template.getMetadata().getName()).process(values);
});
}
开发者ID:xtf-cz,项目名称:xtf,代码行数:17,代码来源:OpenshiftUtil.java
示例7: applyParameterValueProperties
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
private void applyParameterValueProperties(final OpenShiftProject project, final Template template) {
RouteList routes = null;
for (Parameter parameter : template.getParameters()) {
// Find any parameters with special "fabric8-value" properties
if (parameter.getAdditionalProperties().containsKey("fabric8-value")
&& parameter.getValue() == null) {
String value = parameter.getAdditionalProperties().get("fabric8-value").toString();
Matcher m = PARAM_VAR_PATTERN.matcher(value);
StringBuffer newval = new StringBuffer();
while (m.find()) {
String type = m.group(1);
String routeName = m.group(2);
String propertyPath = m.group(3);
String propertyValue = "";
// We only support "route/XXX[.spec.host]" for now,
// but we're prepared for future expansion
if ("route".equals(type) && ".spec.host".equals(propertyPath)) {
// Try to find a Route with that name and use its host name
if (routes == null) {
routes = client.routes().inNamespace(project.getName()).list();
}
propertyValue = routes.getItems().stream()
.filter(r -> routeName.equals(r.getMetadata().getName()))
.map(r -> r.getSpec().getHost())
.filter(Objects::nonNull)
.findAny()
.orElse(propertyValue);
}
m.appendReplacement(newval, Matcher.quoteReplacement(propertyValue));
}
m.appendTail(newval);
parameter.setValue(newval.toString());
}
}
}
开发者ID:fabric8-launcher,项目名称:launchpad-missioncontrol,代码行数:36,代码来源:Fabric8OpenShiftServiceImpl.java
示例8: createCheServer
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
@Test
public void createCheServer() throws Exception {
OpenShiftClient openShiftClient = null;
try {
openShiftClient = client.get(endpoint, username, password);
ProjectRequest projectRequest = createTestProject(openShiftClient);
LOG.info("Number of projects: {}", getNumberOfProjects(openShiftClient));
LOG.info("Test project has been deleted: {}", deleteTestProject(openShiftClient, projectRequest));
LOG.info("Number of projects: {}", getNumberOfProjects(openShiftClient));
// Controller controller = new Controller(client);
// controller.applyJson(template.get());
Template template = loadTemplate(openShiftClient);
List<Parameter> parameters = template.getParameters();
LOG.info("Number of template parameters: {}", parameters.size());
List<ParameterValue> pvs = new ArrayList<>();
for (Parameter parameter : parameters) {
String name = parameter.getName();
String value = parameter.getValue();
LOG.info("Template Parameter Name: {}", name);
LOG.info("Template Parameter Value: {}", value);
if (CHE_OPENSHIFT_ENDPOINT.equals(name) && value.isEmpty()) {
value = endpoint;
}
pvs.add(new ParameterValue(name, value));
}
KubernetesList list = processTemplate(openShiftClient, pvs);
createResources(openShiftClient, list);
Pod pod = openShiftClient.pods().inNamespace(project).withName("che-host").get();
Route route = openShiftClient.routes().inNamespace(project).withName("che-host").get();
LOG.info("Pods: {}", getNumberOfPods(openShiftClient));
} finally {
if (openShiftClient != null) {
openShiftClient.close();
}
}
}
开发者ID:redhat-developer,项目名称:che-starter,代码行数:47,代码来源:OpenShiftTest.java
示例9: processTemplate
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
private KubernetesList processTemplate(OpenShiftClient client, List<ParameterValue> parameterValues)
throws IOException {
ClientTemplateResource<Template, KubernetesList, DoneableTemplate> templateHandle = client.templates()
.load(cheServerTemplate.getInputStream());
return templateHandle.process(parameterValues.toArray(new ParameterValue[parameterValues.size()]));
}
开发者ID:redhat-developer,项目名称:che-starter,代码行数:7,代码来源:OpenShiftTest.java
示例10: loadTemplate
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
private Template loadTemplate(OpenShiftClient client) throws IOException {
return client.templates().load(cheServerTemplate.getInputStream()).get();
}
开发者ID:redhat-developer,项目名称:che-starter,代码行数:4,代码来源:OpenShiftTest.java
示例11: deploy
import io.fabric8.openshift.api.model.Template; //导入依赖的package包/类
public static void deploy() {
OpenShiftUtils.getInstance().cleanProject();
// get & create restricted SA
ServiceAccount serviceAccount1 = OpenShiftUtils.getInstance().withDefaultUser(client -> client.serviceAccounts().createOrReplace(getSupportSA()));
// get token from SA `oc secrets get-token` && wait until created to prevent 404
TestUtils.waitForEvent(Optional::isPresent,
() -> OpenShiftUtils.getInstance().getSecrets().stream().filter(s -> s.getMetadata().getName().startsWith("syndesis-oauth-client-token")).findFirst(),
TimeUnit.MINUTES,
2,
TimeUnit.SECONDS,
5);
Secret secret = OpenShiftUtils.getInstance().getSecrets().stream().filter(s -> s.getMetadata().getName().startsWith("syndesis-oauth-client-token")).findFirst().get();
// token is Base64 encoded by default
String oauthTokenEncoded = secret.getData().get("token");
byte[] oauthTokenBytes = Base64.decodeBase64(oauthTokenEncoded);
String oauthToken = new String(oauthTokenBytes);
// get the template
Template template = getTemplate();
// set params
Map<String, String> templateParams = new HashMap<>();
templateParams.put("ROUTE_HOSTNAME", TestConfiguration.openShiftNamespace() + "." + TestConfiguration.syndesisUrlSuffix());
templateParams.put("OPENSHIFT_MASTER", TestConfiguration.openShiftUrl());
templateParams.put("OPENSHIFT_PROJECT", TestConfiguration.openShiftNamespace());
templateParams.put("OPENSHIFT_OAUTH_CLIENT_SECRET", oauthToken);
templateParams.put("TEST_SUPPORT_ENABLED", "true");
// process & create
KubernetesList processedTemplate = OpenShiftUtils.getInstance().processTemplate(template, templateParams);
OpenShiftUtils.getInstance().createResources(processedTemplate);
OpenShiftUtils.getInstance().createRestRoute();
//TODO: there's a bug in openshift-client, we need to initialize manually
OpenShiftUtils.getInstance().withDefaultUser(client -> client.roleBindings().createOrReplaceWithNew()
.withNewMetadata()
.withName("syndesis:editors")
.endMetadata()
.withNewRoleRef().withName("edit").endRoleRef()
.addNewSubject().withKind("ServiceAccount").withName("syndesis-rest").withNamespace(TestConfiguration.openShiftNamespace()).endSubject()
.addToUserNames(String.format("system:serviceaccount:%s:syndesis-rest", TestConfiguration.openShiftNamespace()))
.done()
);
}
开发者ID:syndesisio,项目名称:syndesis-qe,代码行数:45,代码来源:SyndesisTemplate.java
注:本文中的io.fabric8.openshift.api.model.Template类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论