-
Notifications
You must be signed in to change notification settings - Fork 14
Addition of LinkTask to be able linking to data directory #228
Conversation
Could you please provide a description of what problem you are trying to solve? Also see the contributing guidelines. And an example of how to use the task would be helpful. |
I have some legacy projects I want to install and deploy using accompli. These projects have some folders containing user data (variable data) that is ignored for git and should be kept when a new release is deployed. The simplest and most 'safe' (in the way a developer has to modify/check less code) is to create symlinks to outside the projects folder representing the folder containing user data. Every release deployed with accompli it will destroy the symlinks as a deployment is a 'fresh' checkout. This task will create the symlinks again (to the data folder) An example can be: {
"class": "Accompli\\Task\\LinkTask",
"links": {
"var/log": "log",
"var/uploads": "uploaded-files"
}
} This will create 2 symlinks (named |
156e4ca
to
210fe36
Compare
@niels-nijens what is the status of this? |
Is this the only way to create a symlink? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally found the time to review this!
Making the task more generic would improve the reusability and not just for linking path to a path within the data directory.
src/Task/LinkTask.php
Outdated
$fullLink = sprintf('%s/%s', $releasePath, $link); | ||
|
||
if (!$connection->isDirectory($fullTarget)) { | ||
$connection->createDirectory($fullTarget, 0777, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A LinkTask
should not create directories. This can be done with the CreateWorkspaceTask
. Creating world readable directories is not advisable.
src/Task/LinkTask.php
Outdated
public static function getSubscribedEvents() | ||
{ | ||
return array( | ||
AccompliEvents::PREPARE_RELEASE => array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to change this to AccompliEvents::INSTALL_RELEASE
. This ensures that the release is created (pulled from VCS or something) and you're able to link to things added / changed by for example the ComposerInstallTask
.
src/Task/LinkTask.php
Outdated
if ($connection->isLink($fullLink)) { | ||
$connection->delete($fullLink); | ||
} | ||
$result = $result && $connection->link($fullTarget, $fullLink); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should fail as fast as possible as your release will most likely be in an unusable state.
0480382
to
8768b35
Compare
8768b35
to
d4b8846
Compare
Is it better to wait for this PR of should I make custom implementations for each project? |
No description provided.