use of io.fabric8.support.api.Resource in project fabric8 by jboss-fuse.
the class PatchApplyTest method deployment.
@Deployment
@StartLevelAware(autostart = true)
public static Archive<?> deployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "patch-apply-test.jar");
archive.addPackage(CommandSupport.class.getPackage());
archive.addPackage(IOHelpers.class.getPackage());
archive.setManifest(new Asset() {
@Override
public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleManifestVersion(2);
builder.addBundleSymbolicName(archive.getName());
builder.addBundleVersion("1.0.0");
builder.addImportPackages(ServiceLocator.class, FabricService.class);
builder.addImportPackages("io.fabric8.git");
builder.addImportPackages(AbstractCommand.class, Action.class);
builder.addImportPackage("org.apache.felix.service.command;status=provisional");
builder.addImportPackages(ConfigurationAdmin.class, ServiceTracker.class, Logger.class);
return builder.openStream();
}
});
// add the original 'patchable' bundle version and the patch file to the test bundle as an extra resource
archive.add(createPatchableBundle(ORIGINAL_VERSION), "/bundles", ZipExporter.class);
archive.add(createPatchZip(), "/patches", ZipExporter.class);
return archive;
}
use of io.fabric8.support.api.Resource in project halyard by spinnaker.
the class LocalDebianServiceProvider method getInstallCommand.
@Override
public String getInstallCommand(DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, Map<String, String> installCommands) {
Map<String, Object> bindings = new HashMap<>();
List<SpinnakerService.Type> serviceTypes = new ArrayList<>(installCommands.keySet()).stream().map(SpinnakerService.Type::fromCanonicalName).collect(Collectors.toList());
List<String> upstartNames = getLocalServices(serviceTypes).stream().filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled()).map(i -> ((LocalDebianService) i).getUpstartServiceName()).filter(Objects::nonNull).collect(Collectors.toList());
List<String> systemdServiceConfigs = upstartNames.stream().map(n -> n + ".service").collect(Collectors.toList());
List<String> serviceInstalls = serviceTypes.stream().map(t -> installCommands.get(t.getCanonicalName())).collect(Collectors.toList());
TemplatedResource resource = new StringReplaceJarResource("/debian/init.sh");
bindings.put("services", Strings.join(upstartNames, " "));
bindings.put("systemd-service-configs", Strings.join(systemdServiceConfigs, " "));
String upstartInit = resource.setBindings(bindings).toString();
BillOfMaterials.ArtifactSources artifactSources = artifactService.getArtifactSources(deploymentDetails.getDeploymentName());
resource = new StringReplaceJarResource("/debian/install.sh");
bindings = new HashMap<>();
bindings.put("prepare-environment", "true");
bindings.put("install-redis", "true");
bindings.put("debian-repository", artifactSourcesConfig.mergeWithBomSources(artifactSources).getDebianRepository());
bindings.put("install-commands", String.join("\n", serviceInstalls));
bindings.put("service-action", "restart");
bindings.put("upstart-init", upstartInit);
return resource.setBindings(bindings).toString();
}
use of io.fabric8.support.api.Resource in project fabric8-maven-plugin by fabric8io.
the class DefaultControllerEnricherTest method enrichAndAssert.
protected void enrichAndAssert(int sizeOfObjects, int replicaCount) throws com.fasterxml.jackson.core.JsonProcessingException {
// Setup a sample docker build configuration
final BuildImageConfiguration buildConfig = new BuildImageConfiguration.Builder().ports(Arrays.asList("8080")).build();
final TreeMap controllerConfig = new TreeMap();
controllerConfig.put("replicaCount", String.valueOf(replicaCount));
setupExpectations(buildConfig, controllerConfig);
// Enrich
DefaultControllerEnricher controllerEnricher = new DefaultControllerEnricher(context);
KubernetesListBuilder builder = new KubernetesListBuilder();
controllerEnricher.addMissingResources(builder);
// Validate that the generated resource contains
KubernetesList list = builder.build();
assertEquals(sizeOfObjects, list.getItems().size());
String json = KubernetesResourceUtil.toJson(list.getItems().get(0));
assertThat(json, JsonPathMatchers.isJson());
assertThat(json, JsonPathMatchers.hasJsonPath("$.spec.replicas", Matchers.equalTo(replicaCount)));
}
use of io.fabric8.support.api.Resource in project fabric8-maven-plugin by fabric8io.
the class ImageEnricher method mergeEnvVariables.
private void mergeEnvVariables(Container container) {
List<EnvVar> env = container.getEnv();
if (env == null) {
env = new LinkedList<>();
container.setEnv(env);
}
ResourceConfig resource = getContext().getResources();
Map<String, String> userEnv = resource != null ? resource.getEnv() : null;
if (userEnv != null) {
for (Map.Entry<String, String> entry : userEnv.entrySet()) {
EnvVar existingVariable = KubernetesResourceUtil.setEnvVarNoOverride(env, entry.getKey(), entry.getValue());
if (existingVariable != null) {
String actualValue = existingVariable.getValue();
if (actualValue == null) {
actualValue = "retrieved using the downward API";
}
log.warn("Environment variable %s will not be overridden: trying to set the value %s, but its actual value will be %s", entry.getKey(), entry.getValue(), actualValue);
}
}
}
}
use of io.fabric8.support.api.Resource in project fabric8-maven-plugin by fabric8io.
the class NameEnricher method getOrCreateMetadata.
private ObjectMeta getOrCreateMetadata(HasMetadata resource) {
ObjectMeta metadata = resource.getMetadata();
if (metadata == null) {
metadata = new ObjectMeta();
resource.setMetadata(metadata);
}
return metadata;
}
Aggregations