use of io.fabric8.kubernetes.api.model in project fabric8 by jboss-fuse.
the class FabricGitSynchronizeAction method performContainerAction.
@Override
protected void performContainerAction(String queuePath, String containerName) throws Exception {
String command = map(new JMXRequest().withObjectName("io.fabric8:type=Fabric").withMethod("gitSynchronize").withDelay(randomDelay).withParam(Boolean.class, allowPush));
curator.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(queuePath, PublicStringSerializer.serialize(command));
}
use of io.fabric8.kubernetes.api.model in project fabric8 by jboss-fuse.
the class PushPullPolicyIT method remoteUpdateWhenLocalBranchIsAheadButNoPushIsAllowed.
@Test
public void remoteUpdateWhenLocalBranchIsAheadButNoPushIsAllowed() throws GitAPIException, IOException {
editVersion("1.1", 2, true, "fabric/profiles/default.profile/io.fabric8.other.properties");
editVersion("1.1", 2, false);
ObjectId branch1_1local = local.getRepository().getRef("refs/heads/1.1").getObjectId();
ObjectId branch1_1remote = servlet.getRepository().getRef("refs/heads/1.1").getObjectId();
assertThat(branch1_1local, not(equalTo(branch1_1remote)));
local.checkout().setName("1.0").setCreateBranch(false).call();
assertTrue(local.status().call().isClean());
PullPushPolicy.PullPolicyResult result = policy.doPull(new GitContext(), CP, true, false);
assertNull(result.getLastException());
List<String> versions = new ArrayList<>(result.getVersions());
// these are sorted (TreeSet)
assertThat(versions.size(), equalTo(5));
assertThat(versions.get(0), equalTo("1.0"));
assertThat(versions.get(1), equalTo("1.0.1"));
assertThat(versions.get(2), equalTo("1.1"));
assertThat(versions.get(3), equalTo("1.2"));
assertThat(versions.get(4), equalTo("master"));
List<String> localUpdateVersions = new ArrayList<>(result.localUpdateVersions().keySet());
assertThat(localUpdateVersions.size(), equalTo(1));
assertThat(localUpdateVersions.get(0), equalTo("1.1"));
assertFalse(result.remoteUpdateRequired());
assertTrue(local.status().call().isClean());
List<Ref> localBranches = local.branchList().call();
assertThat(localBranches.size(), equalTo(5));
assertNotNull(local.getRepository().getRef("1.1"));
assertThat("Local branch should change (will be reset to remote)", local.getRepository().getRef("refs/heads/1.1").getObjectId(), equalTo(branch1_1remote));
}
use of io.fabric8.kubernetes.api.model in project fabric8 by jboss-fuse.
the class PushPullPolicyIT method remoteUpdateWhenLocalBranchIsAhead.
@Test
public void remoteUpdateWhenLocalBranchIsAhead() throws GitAPIException, IOException {
editVersion("1.1", 2, true, "fabric/profiles/default.profile/io.fabric8.other.properties");
editVersion("1.1", 2, false);
ObjectId branch1_1local = local.getRepository().getRef("refs/heads/1.1").getObjectId();
ObjectId branch1_1remote = servlet.getRepository().getRef("refs/heads/1.1").getObjectId();
assertThat(branch1_1local, not(equalTo(branch1_1remote)));
local.checkout().setName("1.0").setCreateBranch(false).call();
assertTrue(local.status().call().isClean());
PullPushPolicy.PullPolicyResult result = policy.doPull(new GitContext(), CP, true);
assertNull(result.getLastException());
List<String> versions = new ArrayList<>(result.getVersions());
// these are sorted (TreeSet)
assertThat(versions.size(), equalTo(5));
assertThat(versions.get(0), equalTo("1.0"));
assertThat(versions.get(1), equalTo("1.0.1"));
assertThat(versions.get(2), equalTo("1.1"));
assertThat(versions.get(3), equalTo("1.2"));
assertThat(versions.get(4), equalTo("master"));
List<String> localUpdateVersions = new ArrayList<>(result.localUpdateVersions().keySet());
assertThat(localUpdateVersions.size(), equalTo(1));
assertThat(localUpdateVersions.get(0), equalTo("1.1"));
assertTrue(result.remoteUpdateRequired());
assertTrue(local.status().call().isClean());
List<Ref> localBranches = local.branchList().call();
assertThat(localBranches.size(), equalTo(5));
assertNotNull(local.getRepository().getRef("1.1"));
assertThat("Local branch should change by rebase on top of what's in remote", local.getRepository().getRef("refs/heads/1.1").getObjectId(), not(equalTo(branch1_1remote)));
}
use of io.fabric8.kubernetes.api.model in project fabric8 by jboss-fuse.
the class GitDataStoreImplProfilesIT method readVersionAndRefreshProfile.
@Test
public void readVersionAndRefreshProfile() {
gdsi.importFromFileSystem("src/test/resources/distros/distro1/fabric/import");
Version version = profileRegistry.getVersion("1.0");
assertNotNull(version);
Profile defaultProfile = version.getProfile("default");
assertNotNull(defaultProfile);
assertThat(defaultProfile.getBundles().size(), equalTo(1));
assertThat(defaultProfile.getBundles().get(0), equalTo("mvn:io.fabric8/fabric-amazing/${version:fabric}"));
assertThat(defaultProfile.getFeatures().size(), equalTo(1));
assertThat(defaultProfile.getFeatures().get(0), equalTo("extraordinary"));
assertThat(defaultProfile.getConfigurations().size(), equalTo(2));
assertThat(defaultProfile.getConfigurations().get("my.special.pid").get("property2"), equalTo("value2"));
assertThat(defaultProfile.getConfigurations().get("io.fabric8.agent").get("some.other.property"), equalTo("valueX"));
assertThat(defaultProfile.getConfigurations().get("io.fabric8.agent").get("io.fabric8.number.of.sources"), equalTo("42,142,200"));
ProfileBuilder builder = ProfileBuilder.Factory.createFrom(defaultProfile);
Map<String, String> agentConfiguration = builder.getConfiguration(Constants.AGENT_PID);
// refresh
agentConfiguration.put("lastRefresh." + defaultProfile.getId(), String.valueOf(System.currentTimeMillis()));
agentConfiguration.put("io.fabric8.number.of.sources", "100");
builder.addConfiguration(Constants.AGENT_PID, agentConfiguration);
profileRegistry.updateProfile(builder.getProfile());
}
use of io.fabric8.kubernetes.api.model in project fabric8 by jboss-fuse.
the class GitPatchManagementServiceImpl method determineVersion.
/**
* Return version of product (Fuse, Fabric8) used, but probably based on different karafHome
* @param home
* @param product
* @return
*/
private String determineVersion(File home, String product) {
if (env != EnvType.FABRIC_CHILD && env != EnvType.STANDALONE_CHILD) {
File versions = new File(home, "fabric/import/fabric/profiles/default.profile/io.fabric8.version.properties");
if (versions.exists() && versions.isFile()) {
Properties props = new Properties();
FileInputStream fis = null;
try {
fis = new FileInputStream(versions);
props.load(fis);
return props.getProperty(product);
} catch (IOException e) {
Activator.log(LogService.LOG_ERROR, null, e.getMessage(), e, true);
return null;
} finally {
IOUtils.closeQuietly(fis);
}
} else {
Activator.log2(LogService.LOG_ERROR, "Can't find io.fabric8.version.properties file in default profile");
}
} else {
// for child container we have to be more careful and not examine root container's io.fabric8.version.properties!
File startup = new File(home, "etc/startup.properties");
if (startup.exists() && startup.isFile()) {
Properties props = new Properties();
FileInputStream fis = null;
try {
fis = new FileInputStream(startup);
props.load(fis);
for (String key : props.stringPropertyNames()) {
if (key.startsWith("org/apache/karaf/features/org.apache.karaf.features.core")) {
String url = Utils.pathToMvnurl(key);
Artifact artifact = Utils.mvnurlToArtifact(url, true);
if (artifact != null) {
return artifact.getVersion();
}
}
}
} catch (IOException e) {
Activator.log(LogService.LOG_ERROR, null, e.getMessage(), e, true);
return null;
} finally {
IOUtils.closeQuietly(fis);
}
} else {
Activator.log2(LogService.LOG_ERROR, "Can't find etc/startup.properties file in child container");
}
}
return null;
}
Aggregations