本文整理汇总了Java中io.fabric8.kubernetes.api.model.Namespace类的典型用法代码示例。如果您正苦于以下问题:Java Namespace类的具体用法?Java Namespace怎么用?Java Namespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Namespace类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了Namespace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
示例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());
}
}
示例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());
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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");
}
示例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());
}
}
示例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();
}
示例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());
}
示例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);
}
示例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;
}
示例14: newOperation
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
@Override
public BaseOperation<Namespace, NamespaceList, ?, ?> newOperation() {
return (BaseOperation<Namespace, NamespaceList, ?, ?>) getKubernetesClient().namespaces();
}
示例15: NamespaceEvent
import io.fabric8.kubernetes.api.model.Namespace; //导入依赖的package包/类
public NamespaceEvent(Action action, Namespace namespace) {
this.action = action;
this.namespace = namespace;
}