本文整理汇总了Java中io.fabric8.openshift.client.DefaultOpenShiftClient类的典型用法代码示例。如果您正苦于以下问题:Java DefaultOpenShiftClient类的具体用法?Java DefaultOpenShiftClient怎么用?Java DefaultOpenShiftClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultOpenShiftClient类属于io.fabric8.openshift.client包,在下文中一共展示了DefaultOpenShiftClient类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setup
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
@BeforeClass
public static void setup() throws IOException {
OpenShiftClient oc = new DefaultOpenShiftClient();
List<Route> routes = oc.routes().inNamespace(oc.getNamespace()).list().getItems();
String ssoAuthUrl = routes.stream()
.filter(r -> "secure-sso".equals(r.getMetadata().getName()))
.findFirst()
.map(r -> "https://" + r.getSpec().getHost())
.orElseThrow(() -> new IllegalStateException("Couldn't find secure-sso route"));
InputStream configStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("keycloak.json");
if (configStream == null) {
throw new IllegalStateException("Could not find any keycloak.json file in classpath.");
}
System.setProperty("sso.auth.server.url", ssoAuthUrl);
Configuration config = JsonSerialization.readValue(configStream, Configuration.class, true);
authzClient = AuthzClient.create(config);
applicationUrls = routes.stream()
.filter(r -> r.getMetadata().getName().contains("secured"))
.map(r -> "http://" + r.getSpec().getHost())
.collect(toList());
}
开发者ID:obsidian-toaster-quickstarts,项目名称:redhat-sso,代码行数:26,代码来源:SsoIT.java
示例2: isOperationsUser
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
public boolean isOperationsUser(RestRequest request) {
final String user = getUser(request);
final String token = getBearerToken(request);
ConfigBuilder builder = new ConfigBuilder().withOauthToken(token);
boolean allowed = false;
try (NamespacedOpenShiftClient osClient = new DefaultOpenShiftClient(builder.build())) {
LOGGER.debug("Submitting a SAR to see if '{}' is able to retrieve logs across the cluster", user);
SubjectAccessReviewResponse response = osClient.inAnyNamespace().subjectAccessReviews().createNew()
.withVerb("get").withResource("pods/log").done();
allowed = response.getAllowed();
} catch (Exception e) {
LOGGER.error("Exception determining user's '{}' role.", e, user);
} finally {
LOGGER.debug("User '{}' isOperationsUser: {}", user, allowed);
}
return allowed;
}
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:18,代码来源:RequestUtils.java
示例3: get
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
/**
* Gets OpenShift client. When using, you are responsible for closing it.
* @param masterUrl URL of OpenShift master
* @param token authorization token
* @return OpenShift client
*/
public OpenShiftClient get(String masterUrl, String token) {
if (fabric8PlatformDevMode) {
LOG.info("Using default OpenShift Client for 'fabric8-platform' deployment on minishift");
return new DefaultOpenShiftClient();
}
LOG.info("Certificate file: {}", caCertFile);
Config config = (StringUtils.isBlank(caCertFile))
? new ConfigBuilder().withMasterUrl(masterUrl).withOauthToken(token).build()
: new ConfigBuilder().withMasterUrl(masterUrl).withOauthToken(token).withCaCertFile(caCertFile).build();
return new DefaultOpenShiftClient(config);
}
开发者ID:redhat-developer,项目名称:che-starter,代码行数:19,代码来源:OpenShiftClientWrapper.java
示例4: initializeOpenShiftClient
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
/**
* Initializes an {@link OpenShiftClient}
*
* @param serverUrl
* the optional URL of where the OpenShift cluster API server is
* running
*/
public synchronized static void initializeOpenShiftClient(String serverUrl) {
OpenShiftConfigBuilder configBuilder = new OpenShiftConfigBuilder();
if (serverUrl != null && !serverUrl.isEmpty()) {
configBuilder.withMasterUrl(serverUrl);
}
Config config = configBuilder.build();
config.setUserAgent("openshift-sync-plugin-"
+ Jenkins.getInstance().getPluginManager().getPlugin("openshift-sync").getVersion() + "/fabric8-"
+ Version.clientVersion());
openShiftClient = new DefaultOpenShiftClient(config);
}
开发者ID:jenkinsci,项目名称:openshift-sync-plugin,代码行数:19,代码来源:OpenShiftUtils.java
示例5: main
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
public static void main(String[] args) {
Map<String, String> env = System.getenv();
TemplateOptions templateOptions = new TemplateOptions(env);
File templateDir = getEnv(env, "TEMPLATE_DIR")
.map(File::new)
.orElse(null);
String certDir = getEnvOrThrow(env, "CERT_DIR");
Kubernetes kubernetes = new KubernetesHelper(new DefaultOpenShiftClient(), templateDir);
AddressClusterGenerator clusterGenerator = new TemplateAddressClusterGenerator(kubernetes, templateOptions);
EventLogger eventLogger = kubernetes.createEventLogger(Clock.systemUTC(), "standard-controller");
String addressSpace = getEnvOrThrow(env, "ADDRESS_SPACE");
AddressController addressController = new AddressController(
addressSpace,
kubernetes.createAddressApi(),
kubernetes,
clusterGenerator,
certDir,
eventLogger);
log.info("Deploying address space controller for " + addressSpace);
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(addressController, result -> {
if (result.succeeded()) {
log.info("Address space controller for {} deployed", addressSpace);
} else {
log.warn("Unable to deploy address controller for {}", addressSpace);
}
});
vertx.createHttpServer()
.requestHandler(request -> request.response().setStatusCode(200).end()).listen(8889);
}
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:38,代码来源:Main.java
示例6: Main
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
private Main(ControllerOptions options) throws Exception {
this.controllerClient = new DefaultOpenShiftClient(new ConfigBuilder()
.withMasterUrl(options.getMasterUrl())
.withOauthToken(options.getToken())
.withNamespace(options.getNamespace())
.build());
this.options = options;
this.kubernetes = new KubernetesHelper(options.getNamespace(), controllerClient, options.getToken(), options.getEnvironment(), options.getTemplateDir(), options.getAddressControllerSa(), options.getAddressSpaceAdminSa(), options.isEnableRbac());
}
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:10,代码来源:Main.java
示例7: main
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
public static void main(String [] args) throws Exception {
Security.addProvider(new BouncyCastleProvider());
Map<String, String> env = System.getenv();
String openshiftUri = String.format("https://%s:%s", getEnvOrThrow(env, "KUBERNETES_SERVICE_HOST"), getEnvOrThrow(env, "KUBERNETES_SERVICE_PORT"));
Config config = new ConfigBuilder().withMasterUrl(openshiftUri).withOauthToken(getAuthenticationToken()).withNamespace(getNamespace()).build();
OpenShiftClient openShiftClient = new DefaultOpenShiftClient(config);
AddressSpaceApi addressSpaceApi = new ConfigMapAddressSpaceApi(openShiftClient);
KeycloakManager keycloakManager = new KeycloakManager(new Keycloak(KeycloakParams.fromEnv(System.getenv())));
addressSpaceApi.watchAddressSpaces(keycloakManager);
}
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:14,代码来源:Main.java
示例8: openShiftClient
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
@Bean
@ConditionalOnProperty(value = "openshift.enabled", matchIfMissing = true, havingValue = "true")
public NamespacedOpenShiftClient openShiftClient(OpenShiftConfigurationProperties openShiftConfigurationProperties) {
return new DefaultOpenShiftClient(openShiftConfigurationProperties.getOpenShiftClientConfiguration());
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:6,代码来源:OpenShiftConfiguration.java
示例9: OpenShift
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
public OpenShift(Environment environment, String globalNamespace) {
super(environment, new DefaultOpenShiftClient(new ConfigBuilder().withMasterUrl(environment.openShiftUrl())
.withOauthToken(environment.openShiftToken())
.withUsername(environment.openShiftUser()).build()), globalNamespace);
}
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:6,代码来源:OpenShift.java
示例10: create
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
public OpenShiftClient create(Config config) {
return new DefaultOpenShiftClient(config);
}
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:4,代码来源:OpenshiftClientFactory.java
示例11: assertUser
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public String assertUser(RestRequest request) throws Exception {
String username = null;
final String user = getUser(request);
final String token = getBearerToken(request);
ConfigBuilder builder = new ConfigBuilder().withOauthToken(token);
try (DefaultOpenShiftClient osClient = new DefaultOpenShiftClient(builder.build())) {
LOGGER.debug("Verifying user {} matches the given token.", user);
Request okRequest = new Request.Builder()
.addHeader(AUTHORIZATION_HEADER, "Bearer " + token)
.url(osClient.getMasterUrl() + "oapi/v1/users/~")
.build();
Response response = null;
try {
response = osClient.getHttpClient().newCall(okRequest).execute();
final String body = response.body().string();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Response: code '{}' {}", response.code(), body);
}
if(response.code() != RestStatus.OK.getStatus()) {
throw new ElasticsearchSecurityException("Could not authenticate with given token", RestStatus.UNAUTHORIZED);
}
Map<String, Object> userResponse = XContentHelper.convertToMap(new BytesArray(body), false).v2();
if(userResponse.containsKey("metadata") && ((Map)userResponse.get("metadata")).containsKey("name")) {
username = (String) ((Map)userResponse.get("metadata")).get("name");
}
}catch (Exception e) {
LOGGER.debug("Exception trying to assertUser '{}'", e, user);
throw e;
}
if(StringUtils.isNotBlank(username) && StringUtils.isNotBlank(user) && !user.equals(username)) {
String message = String.format("The given username '%s' does not match the username '%s' associated with the token provided with the request.",
user, username);
LOGGER.debug(message);
}
}
if (null == username) {
throw new ElasticsearchSecurityException("Could not determine username from token", RestStatus.UNAUTHORIZED);
}
return username;
}
开发者ID:fabric8io,项目名称:openshift-elasticsearch-plugin,代码行数:42,代码来源:RequestUtils.java
示例12: newOpenShiftClient
import io.fabric8.openshift.client.DefaultOpenShiftClient; //导入依赖的package包/类
@Override
public OpenShiftClient newOpenShiftClient(final ProviderConfig providerConfig) {
checkInstanceOf("providerConfig", providerConfig, OpenShiftProviderConfig.class);
OpenShiftConfig clientConfig = buildOpenShiftConfig((OpenShiftProviderConfig) providerConfig);
return new OpenShiftClient(new DefaultOpenShiftClient(clientConfig));
}
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:7,代码来源:OpenShiftAccessInterfaceImpl.java
注:本文中的io.fabric8.openshift.client.DefaultOpenShiftClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论