use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Message in project strimzi by strimzi.
the class ConfigMapWatcher method eventReceived.
public void eventReceived(Action action, ConfigMap configMap) {
ObjectMeta metadata = configMap.getMetadata();
Map<String, String> labels = metadata.getLabels();
if (cmPredicate.test(configMap)) {
String name = metadata.getName();
LOGGER.info("ConfigMap watch received event {} on map {} with labels {}", action, name, labels);
Handler<AsyncResult<Void>> resultHandler = ar -> {
if (ar.succeeded()) {
LOGGER.info("Success processing ConfigMap watch event {} on map {} with labels {}", action, name, labels);
} else {
String message;
if (ar.cause() instanceof InvalidConfigMapException) {
message = "ConfigMap " + name + " has an invalid 'data' section: " + ar.cause().getMessage();
LOGGER.error("{}", message);
} else {
message = "Failure processing ConfigMap watch event " + action + " on map " + name + " with labels " + labels + ": " + ar.cause().getMessage();
LOGGER.error("{}", message, ar.cause());
}
controller.enqueue(controller.new Event(configMap, message, Controller.EventType.WARNING, errorResult -> {
}));
}
};
switch(action) {
case ADDED:
controller.onConfigMapAdded(configMap, resultHandler);
break;
case MODIFIED:
controller.onConfigMapModified(configMap, resultHandler);
break;
case DELETED:
controller.onConfigMapDeleted(configMap, resultHandler);
break;
case ERROR:
LOGGER.error("Watch received action=ERROR for ConfigMap " + name);
}
}
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Message in project fabric8 by fabric8io.
the class KubernetesAssert method deployments.
/**
* Finds all the resources that create pod selections (Deployment, DeploymentConfig, ReplicaSet, ReplicationController)
* and create a {@link HasPodSelectionAssert} to make assertions on their pods that they startup etc.
*
* @return the assertion object for the deployment
*/
public HasPodSelectionAssert deployments() {
List<HasPodSelectionAssert> asserters = new ArrayList<>();
List<HasMetadata> resources = new ArrayList<>();
try {
resources = KubernetesHelper.findKubernetesResourcesOnClasspath(new Controller(client));
} catch (IOException e) {
fail("Failed to load kubernetes resources on the classpath: " + e, e);
}
for (HasMetadata resource : resources) {
HasPodSelectionAssert asserter = createPodSelectionAssert(resource);
if (asserter != null) {
asserters.add(asserter);
}
}
String message = "No pod selection kinds found on the classpath such as Deployment, DeploymentConfig, ReplicaSet, ReplicationController";
// TODO we don't yet support size > 1
assertThat(asserters).describedAs(message).isNotEmpty();
if (asserters.size() == 1) {
return asserters.get(0);
}
return new MultiHasPodSelectionAssert(asserters);
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Message in project fabric8 by fabric8io.
the class KubernetesHelper method summaryText.
/**
* Returns a short summary text message for the given kubernetes resource
*/
public static String summaryText(Template entity) {
StringBuilder buffer = new StringBuilder();
List<Parameter> parameters = entity.getParameters();
if (parameters != null) {
for (Parameter parameter : parameters) {
String name = parameter.getName();
appendText(buffer, name);
}
}
return "parameters: " + buffer;
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Message in project fabric8 by fabric8io.
the class BuildConfigHelper method importNewGitProject.
public static CreateGitProjectResults importNewGitProject(KubernetesClient kubernetesClient, UserDetails userDetails, File basedir, String namespace, String projectName, String origin, String message, boolean apply, boolean useLocalGitAddress) throws GitAPIException, JsonProcessingException {
GitUtils.disableSslCertificateChecks();
InitCommand initCommand = Git.init();
initCommand.setDirectory(basedir);
Git git = initCommand.call();
LOG.info("Initialised an empty git configuration repo at {}", basedir.getAbsolutePath());
PersonIdent personIdent = userDetails.createPersonIdent();
String user = userDetails.getUser();
String address = userDetails.getAddress();
String internalAddress = userDetails.getInternalAddress();
String branch = userDetails.getBranch();
// lets create the repository
GitRepoClient repoClient = userDetails.createRepoClient();
CreateRepositoryDTO createRepository = new CreateRepositoryDTO();
createRepository.setName(projectName);
String fullName = null;
RepositoryDTO repository = repoClient.createRepository(createRepository);
if (repository != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Got repository: " + toJson(repository));
}
fullName = repository.getFullName();
}
if (Strings.isNullOrBlank(fullName)) {
fullName = user + "/" + projectName;
}
String htmlUrl = URLUtils.pathJoin(resolveToRoot(address), user, projectName);
String localCloneUrl = URLUtils.pathJoin(resolveToRoot(internalAddress), user, projectName + ".git");
String cloneUrl = htmlUrl + ".git";
String defaultCloneUrl = cloneUrl;
// lets default to using the local git clone URL
if (useLocalGitAddress && Strings.isNotBlank(internalAddress)) {
defaultCloneUrl = localCloneUrl;
}
// now lets import the code and publish
GitUtils.configureBranch(git, branch, origin, defaultCloneUrl);
GitUtils.addDummyFileToEmptyFolders(basedir);
LOG.info("About to git commit and push to: " + defaultCloneUrl + " and remote name " + origin);
GitUtils.doAddCommitAndPushFiles(git, userDetails, personIdent, branch, origin, message, true);
Map<String, String> annotations = new HashMap<>();
annotations.put(Annotations.Builds.GIT_CLONE_URL, cloneUrl);
annotations.put(Annotations.Builds.LOCAL_GIT_CLONE_URL, localCloneUrl);
BuildConfig buildConfig;
if (apply) {
buildConfig = createAndApplyBuildConfig(kubernetesClient, namespace, projectName, defaultCloneUrl, annotations);
} else {
buildConfig = createBuildConfig(kubernetesClient, namespace, projectName, defaultCloneUrl, annotations);
}
return new CreateGitProjectResults(buildConfig, fullName, htmlUrl, localCloneUrl, cloneUrl);
}
use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Message in project fabric8 by jboss-fuse.
the class ProfileCopyAction method doExecute.
@Override
protected Object doExecute() throws Exception {
// but validate the target name
try {
FabricValidations.validateProfileName(target);
} catch (IllegalArgumentException e) {
// we do not want exception in the server log, so print the error message to the console
System.out.println(e.getMessage());
return 1;
}
Version version = versionParam != null ? profileService.getRequiredVersion(versionParam) : fabricService.getRequiredDefaultVersion();
String versionId = version.getId();
if (!version.hasProfile(source)) {
System.out.println("Source profile " + source + " not found.");
return 1;
} else if (version.hasProfile(target)) {
if (!force) {
System.out.println("Target profile " + target + " already exists. Use --force if you want to overwrite.");
return null;
}
}
Profiles.copyProfile(fabricService, versionId, source, target, force);
return null;
}
Aggregations