本文整理汇总了Java中io.fabric8.kubernetes.api.model.Namespace类的典型用法代码示例。如果您正苦于以下问题:Java Namespace类的具体用法?Java Namespace怎么用?Java Namespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Namespace类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了Namespace类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onRequest
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
IntentContext<BaseOperation<Namespace, NamespaceList, ?, ?>> ctx = createContext(request.getIntent(), session);
LOGGER.info("Listing all namespaces.");
try {
List<String> namespaces = list(ctx)
.getItems()
.stream()
.map(d -> d.getMetadata().getName()).collect(Collectors.toList());
if (namespaces.isEmpty()) {
return newResponse("No namespaces found.");
} else {
return newResponse("The available namespaces are: " + join(namespaces, ","));
}
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:21,代码来源:GetNamespaces.java
示例2: onRequest
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
IntentContext<BaseOperation<Namespace, NamespaceList, ?, ?>> ctx = createContext(request.getIntent(), session);
String namespace = ctx.getVariable(Variable.Namespace, null);
if (Utils.isNullOrEmpty(namespace)) {
throw new IllegalStateException("Namespace needs to be specified either via intent slots, or via session attributes.");
}
try {
LOGGER.info("Create namespace:" + namespace);
newOperation().create(new NamespaceBuilder()
.withNewMetadata()
.withName(namespace)
.endMetadata()
.build());
return newResponse("Successfully created namespace " + namespace);
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:23,代码来源:CreateNamespace.java
示例3: testExists
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
public void testExists() throws ResourceException {
// Check that the namespace doesn't exist already
Namespace namespace = KubernetesClientUtil.retrieveNamespace(kubernetesClient, namespaceResource);
assertNull(namespace);
// Test exists method
assertFalse(namespaceResource.exists());
// Create namespace
namespaceResource.create();
// Check that the namespace exists
namespace = KubernetesClientUtil.retrieveNamespace(kubernetesClient, namespaceResource);
assertNotNull(namespace);
// Test exists method
assertTrue(namespaceResource.exists());
}
开发者ID:qaware,项目名称:gradle-cloud-deployer,代码行数:20,代码来源:NamespaceResourceIntegrationTest.java
示例4: testDelete
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
public void testDelete() throws ResourceException {
// Create namespace
namespaceResource.create();
// Check that the namespace exists
Namespace namespace = KubernetesClientUtil.retrieveNamespace(kubernetesClient, namespaceResource);
assertNotNull(namespace);
// Delete namespace
namespaceResource.delete();
// Check that namespace doesn't exist anymore
namespace = KubernetesClientUtil.retrieveNamespace(kubernetesClient, namespaceResource);
assertNull(namespace);
}
开发者ID:qaware,项目名称:gradle-cloud-deployer,代码行数:17,代码来源:NamespaceResourceIntegrationTest.java
示例5: testCreate
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
public void testCreate() throws ResourceException {
// Check that the namespace doesn't exist already
Namespace namespace = KubernetesClientUtil.retrieveNamespace(kubernetesClient, namespaceResource);
assertNull(namespace);
// Create namespace
namespaceResource.create();
// Check that the namespace exists
namespace = KubernetesClientUtil.retrieveNamespace(kubernetesClient, namespaceResource);
assertNotNull(namespace);
// Compare namespaces
assertEquals(namespace.getMetadata().getName(), namespaceResource.getId());
assertEquals(namespace.getApiVersion(), namespaceResource.getResourceConfig().getResourceVersion());
assertEquals(namespace.getKind(), namespaceResource.getResourceConfig().getResourceType());
}
开发者ID:qaware,项目名称:gradle-cloud-deployer,代码行数:19,代码来源:NamespaceResourceIntegrationTest.java
示例6: doCreateNamespace
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
protected void doCreateNamespace(Exchange exchange, String operation) {
String namespaceName = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (ObjectHelper.isEmpty(namespaceName)) {
LOG.error("Create a specific namespace require specify a namespace name");
throw new IllegalArgumentException(
"Create a specific namespace require specify a namespace name");
}
Map<String, String> labels = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_LABELS, Map.class);
EditableNamespace ns = new NamespaceBuilder().withNewMetadata()
.withName(namespaceName).withLabels(labels).endMetadata()
.build();
Namespace namespace = getEndpoint().getKubernetesClient().namespaces()
.create(ns);
exchange.getOut().setBody(namespace);
}
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:KubernetesNamespacesProducer.java
示例7: listTest
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Test
public void listTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
List<Namespace> result = template.requestBody("direct:list", "",
List.class);
boolean defaultExists = false;
Iterator<Namespace> it = result.iterator();
while (it.hasNext()) {
Namespace namespace = it.next();
if ("default".equalsIgnoreCase(namespace.getMetadata().getName())) {
defaultExists = true;
}
}
assertTrue(defaultExists);
}
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:KubernetesNamespacesProducerTest.java
示例8: getNamespace
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Test
public void getNamespace() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:getNs", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
"default");
}
});
Namespace ns = ex.getOut().getBody(Namespace.class);
assertEquals(ns.getMetadata().getName(), "default");
}
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:KubernetesNamespacesProducerTest.java
示例9: onRequest
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
IntentContext<BaseOperation<Namespace, NamespaceList, ?, ?>> ctx = createContext(request.getIntent(), session);
//The namespace as Alexa heard it.
String namespace = ctx.getVariable(Variable.Namespace, null);
if (Utils.isNullOrEmpty(namespace)) {
return newFailureNotice("Sorry, didn't understand which namespace you want me to use.");
}
//The namespace as matched in kubernetes
namespace = IntentContext.selectNamespace(getKubernetesClient(), namespace);
LOGGER.info("Switching to namespace:" + ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace()));
try {
Namespace ns = get(ctx);
if (ns == null) {
return newResponse("No namespaces found.");
} else {
namespace = ns.getMetadata().getName();
session.setAttribute(Namespace.name(), namespace);
return newResponse("Now using namespace " + namespace);
}
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:30,代码来源:SwitchToNamespace.java
示例10: exec
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@TaskAction
public void exec() {
ImmutableClusterExtension cluster =
getProject().getExtensions().getByType(ClusterExtension.class);
Namespace namespace =
new NamespaceBuilder()
.withMetadata(new ObjectMetaBuilder().withName(cluster.namespace()).build())
.build();
KubernetesClient client = new DefaultKubernetesClient();
client.resource(namespace).createOrReplace();
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:13,代码来源:CreateClusterNamespaceTask.java
示例11: doListNamespaceByLabel
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
protected void doListNamespaceByLabel(Exchange exchange, String operation) {
Map<String, String> labels = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_LABELS, Map.class);
if (ObjectHelper.isEmpty(labels)) {
LOG.error("Get a specific namespace by labels require specify a labels set");
throw new IllegalArgumentException(
"Get a specific namespace by labels require specify a labels set");
}
ClientNonNamespaceOperation<Namespace, NamespaceList, DoneableNamespace, ClientResource<Namespace, DoneableNamespace>> namespaces = getEndpoint().getKubernetesClient().namespaces();
for (Map.Entry<String, String> entry : labels.entrySet()) {
namespaces.withLabel(entry.getKey(), entry.getValue());
}
NamespaceList namespace = namespaces.list();
exchange.getOut().setBody(namespace.getItems());
}
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:KubernetesNamespacesProducer.java
示例12: doGetNamespace
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
protected void doGetNamespace(Exchange exchange, String operation) {
String namespaceName = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (ObjectHelper.isEmpty(namespaceName)) {
LOG.error("Get a specific namespace require specify a namespace name");
throw new IllegalArgumentException(
"Get a specific namespace require specify a namespace name");
}
Namespace namespace = getEndpoint().getKubernetesClient().namespaces()
.withName(namespaceName).get();
exchange.getOut().setBody(namespace);
}
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:KubernetesNamespacesProducer.java
示例13: getNamespaces
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Override
public NamespaceList getNamespaces() {
// TODO - Hacking in a quick default for now...
NamespaceList answer = new NamespaceList();
answer.setApiVersion(NamespaceList.ApiVersion.V_1);
List<Namespace> items = new ArrayList<Namespace>();
Namespace _default = new Namespace();
_default.setMetadata(new ObjectMeta());
_default.getMetadata().setName("default");
items.add(_default);
answer.setItems(items);
return answer;
}
开发者ID:fabric8io,项目名称:jube,代码行数:14,代码来源:ApiMasterService.java
示例14: newOperation
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Override
public BaseOperation<Namespace, NamespaceList, ?, ?> newOperation() {
return (BaseOperation<Namespace, NamespaceList, ?, ?>) getKubernetesClient().namespaces();
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:5,代码来源:GetNamespaces.java
示例15: NamespaceEvent
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
public NamespaceEvent(Action action, Namespace namespace) {
this.action = action;
this.namespace = namespace;
}
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:NamespaceEvent.java
示例16: getNamespace
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
public Namespace getNamespace() {
return namespace;
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:NamespaceEvent.java
示例17: setNamespace
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
public void setNamespace(Namespace namespace) {
this.namespace = namespace;
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:NamespaceEvent.java
示例18: createNamespace
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Override
public String createNamespace(Namespace namespace) throws Exception {
// TODO
return null;
}
开发者ID:fabric8io,项目名称:jube,代码行数:6,代码来源:ApiMasterService.java
示例19: getNamespace
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Override
public Namespace getNamespace(@NotNull String s) {
// TODO
return null;
}
开发者ID:fabric8io,项目名称:jube,代码行数:6,代码来源:ApiMasterService.java
示例20: updateNamespace
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Override
public String updateNamespace(@NotNull String s, Namespace namespace) throws Exception {
// TODO
return null;
}
开发者ID:fabric8io,项目名称:jube,代码行数:6,代码来源:ApiMasterService.java
注:本文中的io.fabric8.kubernetes.api.model.Namespace类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论