@ThreadSafe public class GitDataStore extends io.fabric8.service.AbstractDataStore<GitDataStore>
DataStore which stores the profile configuration
versions in a branch per version and directory per profile.| Modifier and Type | Field and Description |
|---|---|
static String |
AGENT_METADATA_FILE |
static String |
CONFIGS |
static String |
CONFIGS_PROFILES |
static int |
GIT_COMMIT_SHORT_LENGTH |
static String |
GIT_PULL_PERIOD |
static String |
GIT_REMOTE_PASSWORD |
static String |
GIT_REMOTE_URL |
static String |
GIT_REMOTE_USER |
static String[] |
SUPPORTED_CONFIGURATION |
static String |
TYPE |
| Constructor and Description |
|---|
GitDataStore() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
activateInternal() |
void |
bindGitProxyService(GitProxyService service) |
void |
bindGitService(GitService service) |
protected void |
checkoutVersion(org.eclipse.jgit.api.Git git,
String version) |
String |
convertProfileIdToDirectory(String profileId)
Takes a profile ID of the form "foo-bar" and if we are using directory trees for profiles then
converts it to "foo/bar.profile"
|
protected void |
createOrCheckoutVersion(org.eclipse.jgit.api.Git git,
String version) |
void |
createProfile(String version,
String profile) |
void |
createVersion(String version) |
void |
createVersion(String parentVersionId,
String toVersion) |
protected void |
deactivateInternal() |
void |
deleteProfile(String version,
String profile) |
void |
deleteVersion(String version) |
protected void |
doAddFiles(org.eclipse.jgit.api.Git git,
File... files) |
protected String |
doCreateProfile(org.eclipse.jgit.api.Git git,
GitContext context,
String profile,
String version)
Creates the given profile directory in the currently checked out version branch
|
protected String |
doExportProfiles(org.eclipse.jgit.api.Git git,
GitContext context,
File outputFile,
FileFilter filter)
exports one or more profile folders from the given version into the zip
|
protected Map<String,Map<String,String>> |
doGetConfigurations(org.eclipse.jgit.api.Git git,
String profile) |
protected Map<String,byte[]> |
doGetFileConfigurations(org.eclipse.jgit.api.Git git,
String profile) |
protected String |
doImportProfiles(org.eclipse.jgit.api.Git git,
GitContext context,
List<String> profileZipUrls)
Imports one or more profile zips into the given version
|
protected Map<String,String> |
doLoadConfiguration(File file) |
protected byte[] |
doLoadFileConfiguration(File file) |
protected void |
doPull(org.eclipse.jgit.api.Git git,
org.eclipse.jgit.transport.CredentialsProvider credentialsProvider,
boolean doDeleteBranches)
Performs a pull so the git repo is pretty much up to date before we start performing operations on it.
|
Iterable<org.eclipse.jgit.transport.PushResult> |
doPush(org.eclipse.jgit.api.Git git,
GitContext gitContext)
Pushes any changes - assumed to be invoked within a gitOperation method!
|
protected Iterable<org.eclipse.jgit.transport.PushResult> |
doPush(org.eclipse.jgit.api.Git git,
GitContext gitContext,
org.eclipse.jgit.transport.CredentialsProvider credentialsProvider)
Pushes any committed changes to the remote repo
|
protected void |
doRecursiveDeleteAndRemove(org.eclipse.jgit.api.Git git,
File file) |
protected void |
doSetConfiguration(org.eclipse.jgit.api.Git git,
String profile,
String pid,
Map<String,String> configuration) |
protected void |
doSetConfigurations(org.eclipse.jgit.api.Git git,
File profileDirectory,
String profile,
Map<String,Map<String,String>> configurations) |
protected void |
doSetFileConfiguration(org.eclipse.jgit.api.Git git,
String profile,
String fileName,
byte[] configuration) |
protected void |
doSetFileConfigurations(org.eclipse.jgit.api.Git git,
File profileDirectory,
String profile,
Map<String,byte[]> configurations) |
void |
exportProfiles(String version,
String outputFileName,
String wildcard) |
protected List<String> |
forceGetVersions() |
String |
getClusterId() |
Map<String,String> |
getConfiguration(String version,
String profile,
String pid) |
protected org.eclipse.jgit.transport.CredentialsProvider |
getCredentialsProvider() |
String |
getDefaultJvmOptions() |
List<String> |
getEnsembleContainers() |
byte[] |
getFileConfiguration(String version,
String profile,
String fileName) |
Map<String,byte[]> |
getFileConfigurations(String version,
String profile) |
protected String |
getFilePattern(File rootDir,
File file) |
org.eclipse.jgit.api.Git |
getGit() |
String |
getLastModified(String version,
String profile) |
protected File |
getPidFile(File profileDirectory,
String pid) |
protected String |
getPidFromFileName(String relativePath) |
String |
getProfile(String version,
String profile,
boolean create) |
File |
getProfileDirectory(org.eclipse.jgit.api.Git git,
String profile) |
List<String> |
getProfiles(String version) |
protected File |
getProfilesDirectory(org.eclipse.jgit.api.Git git) |
String |
getRemote() |
io.fabric8.api.FabricRequirements |
getRequirements() |
String |
getType() |
Map<String,String> |
getVersionAttributes(String version) |
List<String> |
getVersions() |
<T> T |
gitOperation(GitOperation<T> operation)
Performs a set of operations on the git repository & avoids concurrency issues
|
<T> T |
gitOperation(GitOperation<T> operation,
boolean pullFirst) |
<T> T |
gitOperation(org.eclipse.jgit.lib.PersonIdent personIdent,
GitOperation<T> operation,
boolean pullFirst) |
<T> T |
gitOperation(org.eclipse.jgit.lib.PersonIdent personIdent,
GitOperation<T> operation,
boolean pullFirst,
GitContext context) |
boolean |
hasVersion(String name) |
void |
importFromFileSystem(File from,
String destinationPath,
String version,
boolean isProfileDir) |
void |
importFromFilesystem(String path) |
void |
importFromFileSystem(String from) |
void |
importProfiles(String version,
List<String> profileZipUrls) |
protected boolean |
isProfileDirectory(File profileDir) |
Collection<String> |
listFiles(String version,
Iterable<String> profiles,
String path) |
protected void |
pull() |
protected void |
push() |
protected void |
recursiveAddLegacyProfileDirectoryFiles(org.eclipse.jgit.api.Git git,
File from,
File toDir,
String path)
Recursively copies the profiles in a single flat directory into the new
directory layout; changing "foo-bar" directory into "foo/bar.profile" along the way
|
protected void |
recursiveCopyAndAdd(org.eclipse.jgit.api.Git git,
File from,
File toDir,
String path,
boolean useToDirAsDestination)
Recursively copies the given files from the given directory to the specified directory
adding them to the git repo along the way
|
void |
setConfiguration(String version,
String profile,
String pid,
Map<String,String> configuration) |
void |
setConfigurationFile(String version,
String profile,
String fileName,
byte[] data) |
void |
setConfigurations(String version,
String profile,
Map<String,Map<String,String>> configurations) |
void |
setDefaultJvmOptions(String jvmOptions) |
void |
setFileConfiguration(String version,
String profile,
String fileName,
byte[] configuration) |
void |
setFileConfigurations(String version,
String profile,
Map<String,byte[]> configurations) |
void |
setRemote(String remote)
Sets the name of the remote repository
|
void |
setRequirements(io.fabric8.api.FabricRequirements requirements) |
void |
setVersionAttribute(String version,
String key,
String value) |
bindCurator, bindRegistrationHandler, bindRuntimeProperties, childEvent, clearCaches, createContainerConfig, createContainerConfig, deleteContainer, doRunCallbacks, fireChangeNotifications, getConfigurationFileNames, getConfigurations, getContainerAttribute, getContainerMetadata, getContainerParent, getContainerProfiles, getContainers, getContainerVersion, getCurator, getDataStoreProperties, getDefaultVersion, getProfileAttributes, getRuntimeProperties, getTreeCache, hasContainer, hasProfile, isContainerAlive, protectedActivate, protectedDeactivate, runCallbacks, setContainerAlive, setContainerAttribute, setContainerMetadata, setContainerProfiles, setContainerVersion, setDefaultVersion, setProfileAttribute, trackConfiguration, unbindCurator, unbindRegistrationHandler, unbindRuntimeProperties, untrackConfigurationpublic static final String GIT_PULL_PERIOD
public static final String GIT_REMOTE_URL
public static final String GIT_REMOTE_USER
public static final String GIT_REMOTE_PASSWORD
public static final String[] SUPPORTED_CONFIGURATION
public static final String CONFIGS
public static final String CONFIGS_PROFILES
public static final String AGENT_METADATA_FILE
public static final String TYPE
public static final int GIT_COMMIT_SHORT_LENGTH
protected void activateInternal()
activateInternal in class io.fabric8.service.AbstractDataStore<GitDataStore>protected void deactivateInternal()
deactivateInternal in class io.fabric8.service.AbstractDataStore<GitDataStore>public void importFromFilesystem(String path)
public String getRemote()
public void setRemote(String remote)
public void importFromFileSystem(String from)
importFromFileSystem in interface io.fabric8.api.DataStoreimportFromFileSystem in class io.fabric8.service.AbstractDataStore<GitDataStore>public void importFromFileSystem(File from, String destinationPath, String version, boolean isProfileDir)
public void createVersion(String version)
public void deleteVersion(String version)
public boolean hasVersion(String name)
protected File getProfilesDirectory(org.eclipse.jgit.api.Git git)
public Collection<String> listFiles(String version, Iterable<String> profiles, String path)
public Map<String,byte[]> getFileConfigurations(String version, String profile)
protected Map<String,byte[]> doGetFileConfigurations(org.eclipse.jgit.api.Git git, String profile) throws IOException
IOExceptionprotected Map<String,Map<String,String>> doGetConfigurations(org.eclipse.jgit.api.Git git, String profile) throws IOException
IOExceptionpublic byte[] getFileConfiguration(String version, String profile, String fileName)
public void setFileConfigurations(String version, String profile, Map<String,byte[]> configurations)
protected void doSetFileConfigurations(org.eclipse.jgit.api.Git git,
File profileDirectory,
String profile,
Map<String,byte[]> configurations)
throws IOException,
org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionprotected void doSetConfigurations(org.eclipse.jgit.api.Git git,
File profileDirectory,
String profile,
Map<String,Map<String,String>> configurations)
throws IOException,
org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionpublic void setFileConfiguration(String version, String profile, String fileName, byte[] configuration)
protected void doSetFileConfiguration(org.eclipse.jgit.api.Git git,
String profile,
String fileName,
byte[] configuration)
throws IOException,
org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionprotected void doSetConfiguration(org.eclipse.jgit.api.Git git,
String profile,
String pid,
Map<String,String> configuration)
throws IOException,
org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionprotected String getPidFromFileName(String relativePath) throws IOException
IOExceptionpublic Map<String,String> getConfiguration(String version, String profile, String pid)
public void setConfigurations(String version, String profile, Map<String,Map<String,String>> configurations)
public void setConfiguration(String version, String profile, String pid, Map<String,String> configuration)
public void setConfigurationFile(String version, String profile, String fileName, byte[] data)
public String getDefaultJvmOptions()
public void setDefaultJvmOptions(String jvmOptions)
public io.fabric8.api.FabricRequirements getRequirements()
public void setRequirements(io.fabric8.api.FabricRequirements requirements)
throws IOException
IOExceptionpublic String getClusterId()
public org.eclipse.jgit.api.Git getGit()
throws IOException
IOExceptionpublic <T> T gitOperation(GitOperation<T> operation)
public <T> T gitOperation(GitOperation<T> operation, boolean pullFirst)
public <T> T gitOperation(org.eclipse.jgit.lib.PersonIdent personIdent,
GitOperation<T> operation,
boolean pullFirst)
public <T> T gitOperation(org.eclipse.jgit.lib.PersonIdent personIdent,
GitOperation<T> operation,
boolean pullFirst,
GitContext context)
public Iterable<org.eclipse.jgit.transport.PushResult> doPush(org.eclipse.jgit.api.Git git, GitContext gitContext) throws Exception
Exceptionprotected Iterable<org.eclipse.jgit.transport.PushResult> doPush(org.eclipse.jgit.api.Git git, GitContext gitContext, org.eclipse.jgit.transport.CredentialsProvider credentialsProvider) throws Exception
Exceptionprotected org.eclipse.jgit.transport.CredentialsProvider getCredentialsProvider()
protected void doPull(org.eclipse.jgit.api.Git git,
org.eclipse.jgit.transport.CredentialsProvider credentialsProvider,
boolean doDeleteBranches)
git - The Git instance to use.credentialsProvider - The CredentialsProvider to use.doDeleteBranches - Flag that determines if local branches that don't exist in remote should get deleted.protected String doCreateProfile(org.eclipse.jgit.api.Git git, GitContext context, String profile, String version) throws IOException, org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionprotected String doImportProfiles(org.eclipse.jgit.api.Git git, GitContext context, List<String> profileZipUrls) throws org.eclipse.jgit.api.errors.GitAPIException, IOException
org.eclipse.jgit.api.errors.GitAPIExceptionIOExceptionprotected String doExportProfiles(org.eclipse.jgit.api.Git git, GitContext context, File outputFile, FileFilter filter) throws IOException
IOExceptionprotected void recursiveCopyAndAdd(org.eclipse.jgit.api.Git git,
File from,
File toDir,
String path,
boolean useToDirAsDestination)
throws org.eclipse.jgit.api.errors.GitAPIException,
IOException
org.eclipse.jgit.api.errors.GitAPIExceptionIOExceptionprotected void recursiveAddLegacyProfileDirectoryFiles(org.eclipse.jgit.api.Git git,
File from,
File toDir,
String path)
throws org.eclipse.jgit.api.errors.GitAPIException,
IOException
org.eclipse.jgit.api.errors.GitAPIExceptionIOExceptionprotected boolean isProfileDirectory(File profileDir)
public String convertProfileIdToDirectory(String profileId)
protected void pull()
protected void push()
protected void createOrCheckoutVersion(org.eclipse.jgit.api.Git git,
String version)
throws org.eclipse.jgit.api.errors.GitAPIException
org.eclipse.jgit.api.errors.GitAPIExceptionprotected void checkoutVersion(org.eclipse.jgit.api.Git git,
String version)
throws org.eclipse.jgit.api.errors.GitAPIException
org.eclipse.jgit.api.errors.GitAPIExceptionprotected void doAddFiles(org.eclipse.jgit.api.Git git,
File... files)
throws org.eclipse.jgit.api.errors.GitAPIException,
IOException
org.eclipse.jgit.api.errors.GitAPIExceptionIOExceptionprotected void doRecursiveDeleteAndRemove(org.eclipse.jgit.api.Git git,
File file)
throws IOException,
org.eclipse.jgit.api.errors.GitAPIException
IOExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionprotected byte[] doLoadFileConfiguration(File file) throws IOException
IOExceptionprotected Map<String,String> doLoadConfiguration(File file) throws IOException
IOExceptionprotected String getFilePattern(File rootDir, File file) throws IOException
IOExceptionpublic String getType()
public void bindGitService(GitService service)
public void bindGitProxyService(GitProxyService service)
Copyright © 2011–2014 Red Hat. All rights reserved.