Search in sources :

Example 31 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class MavenUploadProxyServlet method handleDeploy.

private void handleDeploy(HttpServletRequest req, UploadContext result) throws Exception {
    String profile = req.getParameter("profile");
    String version = req.getParameter("version");
    if (profile != null && version != null) {
        ProjectRequirements requirements = toProjectRequirements(result);
        requirements.setProfileId(profile);
        requirements.setVersion(version);
        DeployResults deployResults = addToProfile(requirements);
        LOGGER.info(String.format("Deployed artifact %s to profile: %s", result.toArtifact(), deployResults));
    }
}
Also used : DeployResults(io.fabric8.deployer.dto.DeployResults) ProjectRequirements(io.fabric8.deployer.dto.ProjectRequirements)

Example 32 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class DummyBatchingProgressMonitor method setFileConfigurations.

private void setFileConfigurations(GitContext context, final String versionId, final String profileId, final Map<String, byte[]> fileConfigurations) throws IOException, GitAPIException {
    assertWriteLock();
    // Delete and remove stale file configurations
    File profileDir = GitHelpers.getProfileDirectory(getGit(), profileId);
    final HashSet<File> filesToDelete = new HashSet<File>();
    if (profileDir.exists()) {
        final List<File> filesList = new ArrayList<File>();
        java.nio.file.Files.walkFileTree(profileDir.toPath(), new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException {
                if (!Constants.AGENT_PROPERTIES.equals(path.getFileName().toString())) {
                    filesToDelete.add(path.toFile());
                }
                return super.visitFile(path, attrs);
            }
        });
    }
    for (Map.Entry<String, byte[]> entry : fileConfigurations.entrySet()) {
        String fileName = entry.getKey();
        byte[] newCfg = entry.getValue();
        setFileConfiguration(getGit(), profileId, fileName, newCfg);
        filesToDelete.remove(new File(profileDir, fileName));
    }
    for (File file : filesToDelete) {
        recursiveDeleteAndRemove(getGit(), file);
    }
    if (!fileConfigurations.isEmpty() || !filesToDelete.isEmpty()) {
        context.commitMessage("Update configurations for profile: " + profileId);
    }
}
Also used : Path(java.nio.file.Path) ZkPath(io.fabric8.zookeeper.ZkPath) FileVisitResult(java.nio.file.FileVisitResult) IOException(java.io.IOException) File(java.io.File) LockFile(org.eclipse.jgit.internal.storage.file.LockFile) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Example 33 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class DummyBatchingProgressMonitor method createProfile.

@Override
public String createProfile(GitContext context, final Profile profile) {
    IllegalStateAssertion.assertNotNull(profile, "profile");
    LockHandle writeLock = aquireWriteLock();
    try {
        assertValid();
        GitOperation<String> gitop = new GitOperation<String>() {

            public String call(Git git, GitContext context) throws Exception {
                String versionId = profile.getVersion();
                String profileId = profile.getId();
                Version version = getRequiredVersion(versionId);
                IllegalStateAssertion.assertFalse(version.hasProfile(profileId), "Profile already exists: " + profileId);
                checkoutRequiredProfileBranch(git, context, versionId, profileId);
                return createOrUpdateProfile(context, null, profile, new HashSet<String>());
            }
        };
        return executeInternal(context, null, gitop);
    } finally {
        writeLock.unlock();
    }
}
Also used : LockHandle(io.fabric8.api.LockHandle) Git(org.eclipse.jgit.api.Git) GitContext(io.fabric8.api.GitContext) GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version)

Example 34 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class FabricFeaturesServiceImpl method getAllProfilesOverlay.

/**
 * Creates an aggregation of all available {@link Profile}s.
 */
private Profile getAllProfilesOverlay() {
    Container container = fabricService.get().getCurrentContainer();
    ProfileService profileService = fabricService.get().adapt(ProfileService.class);
    Version version = container.getVersion();
    Profile versionProfile = getVersionProfile(version);
    return Profiles.getEffectiveProfile(fabricService.get(), profileService.getOverlayProfile(versionProfile));
}
Also used : Container(io.fabric8.api.Container) ProfileService(io.fabric8.api.ProfileService) Version(io.fabric8.api.Version) Profile(io.fabric8.api.Profile)

Example 35 with Profile

use of io.fabric8.maven.core.config.Profile in project fabric8 by jboss-fuse.

the class Containers method aliveAndSuccessfulContainers.

/**
 * Returns all the current alive and successful containers for the given profile which have completed provisioning
 */
public static List<ContainerDTO> aliveAndSuccessfulContainers(Iterable<ContainerDTO> allContainers) {
    List<ContainerDTO> answer = new ArrayList<>();
    for (ContainerDTO container : allContainers) {
        boolean alive = container.isAlive();
        boolean provisioningPending = container.isProvisioningPending();
        String provisionResult = container.getProvisionResult();
        boolean aliveAndProvisionSuccess = alive && !provisioningPending && Container.PROVISION_SUCCESS.equals(provisionResult);
        if (aliveAndProvisionSuccess) {
            answer.add(container);
        }
    }
    return answer;
}
Also used : ArrayList(java.util.ArrayList) ContainerDTO(io.fabric8.api.jmx.ContainerDTO)

Aggregations

Profile (io.fabric8.api.Profile)125 Version (io.fabric8.api.Version)50 Container (io.fabric8.api.Container)49 ArrayList (java.util.ArrayList)37 ProfileBuilder (io.fabric8.api.ProfileBuilder)34 Test (org.junit.Test)32 FabricService (io.fabric8.api.FabricService)28 HashMap (java.util.HashMap)25 File (java.io.File)24 ProfileService (io.fabric8.api.ProfileService)23 Map (java.util.Map)22 IOException (java.io.IOException)19 ProfileRequirements (io.fabric8.api.ProfileRequirements)13 HashSet (java.util.HashSet)12 GitVersion (io.fabric8.api.commands.GitVersion)11 FabricRequirements (io.fabric8.api.FabricRequirements)10 LinkedList (java.util.LinkedList)9 TreeMap (java.util.TreeMap)9 LockHandle (io.fabric8.api.LockHandle)8 Parser (io.fabric8.maven.util.Parser)8