use of io.fabric8.annotations.External in project carbon-apimgt by wso2.
the class ServiceDiscovererKubernetesTestCase method testInitWhileExternalTokenFileNameNotGiven.
@Test(description = "Test init method when external service account token file name is NOT given")
public void testInitWhileExternalTokenFileNameNotGiven() throws Exception {
OpenShiftClient openShiftClient = Mockito.mock(OpenShiftClient.class);
ServiceDiscovererKubernetes sdKubernetes = new ServiceDiscovererKubernetes();
sdKubernetes.setClient(openShiftClient);
try {
sdKubernetes.initImpl(createImplParametersMap(""));
} catch (ServiceDiscoveryException e) {
// since pod's token is then searched, this is exception msg we get
Assert.assertEquals(e.getCause().getMessage(), "Error while reading file /var/run/secrets/kubernetes.io/serviceaccount/token");
}
}
use of io.fabric8.annotations.External in project docker-maven-plugin by fabric8io.
the class DockerAccessFactory method getDefaultDockerHostProviders.
/**
* Return a list of providers which could delive connection parameters from
* calling external commands. For this plugin this is docker-machine, but can be overridden
* to add other config options, too.
*
* @return list of providers or <code>null</code> if none are applicable
*/
private List<DockerConnectionDetector.DockerHostProvider> getDefaultDockerHostProviders(DockerAccessContext dockerAccessContext, Logger log) {
DockerMachineConfiguration config = dockerAccessContext.getMachine();
if (dockerAccessContext.isSkipMachine()) {
config = null;
} else if (config == null) {
Properties projectProps = dockerAccessContext.getProjectProperties();
if (projectProps.containsKey(DockerMachineConfiguration.DOCKER_MACHINE_NAME_PROP)) {
config = new DockerMachineConfiguration(projectProps.getProperty(DockerMachineConfiguration.DOCKER_MACHINE_NAME_PROP), projectProps.getProperty(DockerMachineConfiguration.DOCKER_MACHINE_AUTO_CREATE_PROP));
}
}
List<DockerConnectionDetector.DockerHostProvider> ret = new ArrayList<>();
ret.add(new DockerMachine(log, config));
return ret;
}
use of io.fabric8.annotations.External in project fabric8 by jboss-fuse.
the class DummyBatchingProgressMonitor method gitOperation.
@Override
public <T> T gitOperation(GitContext context, GitOperation<T> gitop, PersonIdent personIdent) {
IllegalArgumentAssertion.assertNotNull(gitop, "gitop");
IllegalArgumentAssertion.assertNotNull(context, "context");
LockHandle writeLock = aquireWriteLock();
try {
assertValid();
LOGGER.debug("External call to execute a git operation: " + gitop);
return executeInternal(context, personIdent, gitop);
} finally {
writeLock.unlock();
}
}
use of io.fabric8.annotations.External in project fabric8 by jboss-fuse.
the class SubsystemResolveContext method findProviders.
@Override
public List<Capability> findProviders(Requirement requirement) {
List<Capability> caps = new ArrayList<Capability>();
Region requirerRegion = getRegion(requirement.getResource());
if (requirerRegion != null) {
Map<Requirement, Collection<Capability>> resMap = repository.findProviders(Collections.singleton(requirement));
Collection<Capability> res = resMap != null ? resMap.get(requirement) : null;
if (res != null && !res.isEmpty()) {
caps.addAll(res);
} else if (globalRepository != null) {
// Only bring in external resources for non optional requirements
if (!RESOLUTION_OPTIONAL.equals(requirement.getDirectives().get(RESOLUTION_DIRECTIVE))) {
resMap = globalRepository.findProviders(Collections.singleton(requirement));
res = resMap != null ? resMap.get(requirement) : null;
if (res != null && !res.isEmpty()) {
caps.addAll(res);
}
}
}
// Use the digraph to prune non visible capabilities
Visitor visitor = new Visitor(caps);
requirerRegion.visitSubgraph(visitor);
Collection<Capability> allowed = visitor.getAllowed();
caps.retainAll(allowed);
// the parent one
if (caps.size() > 1) {
Map<String, Resource> providers = new HashMap<String, Resource>();
for (Capability cap : caps) {
Resource resource = cap.getResource();
String id = getSymbolicName(resource) + "|" + getVersion(resource);
Resource prev = providers.get(id);
if (prev != null && prev != resource) {
Region r1 = getRegion(prev);
Region r2 = getRegion(resource);
boolean r2canSeeR1 = isResourceVisibleFromRegion(prev, r2);
boolean r1canSeeR2 = isResourceVisibleFromRegion(resource, r1);
if (r1canSeeR2 && r2canSeeR1) {
// r1 and r2 can see each other
int reqDiff = prev.getRequirements(null).size() - resource.getRequirements(null).size();
if (reqDiff == 0) {
String r1Name = getRegion(prev).getName();
String r2Name = getRegion(resource).getName();
int c = r1Name.compareTo(r2Name);
if (c == 0) {
// One of the resource has to be a bundle, use that one
c = (prev instanceof BundleRevision) ? -1 : +1;
}
resource = c < 0 ? prev : resource;
} else {
// one of the resource has less requirements, so use this one
// This can be the case when one resource has conditionals, which adds further
// requirements to the condition feature.
resource = reqDiff < 0 ? prev : resource;
}
} else {
// only one region can see the other, grab the correct
resource = r1canSeeR2 ? prev : resource;
}
}
providers.put(id, resource);
}
for (Iterator<Capability> it = caps.iterator(); it.hasNext(); ) {
Capability cap = it.next();
if (!providers.values().contains(cap.getResource())) {
it.remove();
}
}
}
// Sort caps
Collections.sort(caps, candidateComparator);
}
return caps;
}
use of io.fabric8.annotations.External in project fabric8-maven-plugin by fabric8io.
the class ApplyMojo method shouldCreateExternalURLForService.
/**
* Should we try to create an external URL for the given service?
* <p/>
* By default lets ignore the kubernetes services and any service which does not expose ports 80 and 443
*
* @return true if we should create an OpenShift Route for this service.
*/
private boolean shouldCreateExternalURLForService(Service service, String id) {
if ("kubernetes".equals(id) || "kubernetes-ro".equals(id)) {
return false;
}
Set<Integer> ports = KubernetesHelper.getPorts(service);
log.debug("Service " + id + " has ports: " + ports);
if (ports.size() == 1) {
String type = null;
ServiceSpec spec = service.getSpec();
if (spec != null) {
type = spec.getType();
if (Objects.equals(type, "LoadBalancer")) {
return true;
}
}
log.info("Not generating route for service " + id + " type is not LoadBalancer: " + type);
return false;
} else {
log.info("Not generating route for service " + id + " as only single port services are supported. Has ports: " + ports);
return false;
}
}
Aggregations