use of io.fabric8.agent.model.Dependency in project fabric8-maven-plugin by fabric8io.
the class OpenShiftDependencyResources method convertKubernetesItemToOpenShift.
/**
* Returns the OpenShift dependency for the given resource if there is one
*/
public HasMetadata convertKubernetesItemToOpenShift(HasMetadata item) {
KindAndName key = new KindAndName(item);
HasMetadata answer = openshiftDependencyResources.get(key);
if (answer == null && item instanceof Deployment) {
key = new KindAndName("DeploymentConfig", getName(item));
answer = openshiftDependencyResources.get(key);
}
return answer;
}
use of io.fabric8.agent.model.Dependency in project fabric8 by fabric8io.
the class SessionListener method loadDependency.
public void loadDependency(Logger log, List<KubernetesList> kubeConfigs, String dependency, Controller controller, Configuration configuration, String namespace) throws Exception {
// lets test if the dependency is a local string
String baseDir = System.getProperty("basedir", ".");
String path = baseDir + "/" + dependency;
File file = new File(path);
if (file.exists()) {
loadDependency(log, kubeConfigs, file, controller, configuration, log, namespace);
} else {
String text = readAsString(createURL(dependency));
Object resources;
if (text.trim().startsWith("---") || dependency.endsWith(".yml") || dependency.endsWith(".yaml")) {
resources = loadYaml(text);
} else {
resources = loadJson(text);
}
addConfig(kubeConfigs, resources, controller, configuration, log, namespace, dependency);
}
}
use of io.fabric8.agent.model.Dependency in project fabric8 by jboss-fuse.
the class Subsystem method downloadBundles.
@SuppressWarnings("InfiniteLoopStatement")
public void downloadBundles(DownloadManager manager, MetadataBuilder builder, Set<String> overrides, String featureResolutionRange) throws Exception {
for (Subsystem child : children) {
child.downloadBundles(manager, builder, overrides, featureResolutionRange);
}
final Map<String, ResourceImpl> bundles = new ConcurrentHashMap<>();
final Downloader downloader = manager.createDownloader();
final Map<BundleInfo, Conditional> infos = new HashMap<>();
if (feature != null) {
for (Conditional cond : feature.getConditional()) {
for (final BundleInfo bi : cond.getBundles()) {
infos.put(bi, cond);
}
}
for (BundleInfo bi : feature.getBundles()) {
infos.put(bi, null);
}
}
ResourceBuilderCallback callback = new ResourceBuilderCallback(bundles, builder);
for (Map.Entry<BundleInfo, Conditional> entry : infos.entrySet()) {
final BundleInfo bi = entry.getKey();
final String loc = bi.getLocation();
downloader.download(loc, callback);
}
for (Clause bundle : Parser.parseClauses(this.bundles.toArray(new String[this.bundles.size()]))) {
final String loc = bundle.getName();
downloader.download(loc, callback);
}
for (final FabricBundle fabricBundle : fabricBundles) {
final String loc = fabricBundle.getLocation();
downloader.download(loc, callback);
}
for (String override : overrides) {
final String loc = Overrides.extractUrl(override);
downloader.download(loc, callback);
}
downloader.await();
Overrides.override(bundles, overrides);
if (feature != null) {
// Add conditionals
Map<Conditional, Resource> resConds = new HashMap<>();
for (Conditional cond : feature.getConditional()) {
FeatureResource resCond = FeatureResource.build(feature, cond, featureResolutionRange, bundles);
addIdentityRequirement(this, resCond, false);
addIdentityRequirement(resCond, this, true);
installable.add(resCond);
resConds.put(cond, resCond);
}
// Add features
FeatureResource resFeature = FeatureResource.build(feature, featureResolutionRange, bundles);
addIdentityRequirement(resFeature, this);
installable.add(resFeature);
// Add dependencies
for (Map.Entry<BundleInfo, Conditional> entry : infos.entrySet()) {
final BundleInfo bi = entry.getKey();
final String loc = bi.getLocation();
final Conditional cond = entry.getValue();
ResourceImpl res = bundles.get(loc);
int sl = bi.getStartLevel() <= 0 ? feature.getStartLevel() : bi.getStartLevel();
if (bi.isDependency()) {
addDependency(res, false, bi.isStart(), sl);
} else {
doAddDependency(res, cond == null, bi.isStart(), sl);
}
if (cond != null) {
addIdentityRequirement(res, resConds.get(cond), true);
}
}
}
for (Clause bundle : Parser.parseClauses(this.bundles.toArray(new String[this.bundles.size()]))) {
final String loc = bundle.getName();
boolean dependency = Boolean.parseBoolean(bundle.getAttribute("dependency"));
boolean start = bundle.getAttribute("start") == null || Boolean.parseBoolean(bundle.getAttribute("start"));
int startLevel = 0;
try {
startLevel = Integer.parseInt(bundle.getAttribute("start-level"));
} catch (NumberFormatException e) {
// Ignore
}
if (dependency) {
addDependency(bundles.get(loc), false, start, startLevel);
} else {
doAddDependency(bundles.get(loc), true, start, startLevel);
addIdentityRequirement(this, bundles.get(loc));
}
}
for (final FabricBundle fabricBundle : fabricBundles) {
final String loc = fabricBundle.getLocation();
boolean dependency = Boolean.parseBoolean(fabricBundle.getProperty("dependency"));
boolean start = fabricBundle.getProperty("start") == null || Boolean.parseBoolean(fabricBundle.getProperty("start"));
int startLevel = 0;
try {
startLevel = Integer.parseInt(fabricBundle.getProperty("start-level"));
} catch (NumberFormatException e) {
// Ignore
}
if (dependency) {
addDependency(bundles.get(loc), false, start, startLevel);
} else {
doAddDependency(bundles.get(loc), true, start, startLevel);
addIdentityRequirement(this, bundles.get(loc));
}
}
// Compute dependencies
for (DependencyInfo info : dependencies.values()) {
installable.add(info.resource);
addIdentityRequirement(info.resource, this, info.mandatory);
}
}
use of io.fabric8.agent.model.Dependency in project fabric8 by jboss-fuse.
the class CamelXjcTest method setUp.
public void setUp() throws Exception {
// this would typically be done by dependency injection...
dataFormat.setCompiler(new DefaultDynamicCompiler(XjcTest.getSchemaURL("xsds/report.xsd")));
super.setUp();
}
use of io.fabric8.agent.model.Dependency in project fabric8 by jboss-fuse.
the class AgentUtils method expandFeature.
public static Set<Feature> expandFeature(Feature feature, Map<String, Repository> repositories) {
Set<Feature> features = new HashSet<>();
for (Dependency f : feature.getDependencies()) {
Feature loaded = FeatureUtils.search(f.getName(), repositories.values());
features.addAll(expandFeature(loaded, repositories));
}
features.add(feature);
return features;
}
Aggregations