Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Addition of LinkTask to be able linking to data directory #228

Closed
wants to merge 3 commits into from

Conversation

reyostallenberg
Copy link

No description provided.

@niels-nijens
Copy link
Member

niels-nijens commented Feb 20, 2017

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.

@reyostallenberg
Copy link
Author

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 log and uploads) in the var directory to:
{datadirectory}/{stage}/log and {datadirectory}/{stage}/uploaded-files

@reyostallenberg
Copy link
Author

@niels-nijens what is the status of this?

@nickvanderzwet
Copy link

Is this the only way to create a symlink?

Copy link
Member

@niels-nijens niels-nijens left a 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.

$fullLink = sprintf('%s/%s', $releasePath, $link);

if (!$connection->isDirectory($fullTarget)) {
$connection->createDirectory($fullTarget, 0777, true);
Copy link
Member

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.

public static function getSubscribedEvents()
{
return array(
AccompliEvents::PREPARE_RELEASE => array(
Copy link
Member

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.

if ($connection->isLink($fullLink)) {
$connection->delete($fullLink);
}
$result = $result && $connection->link($fullTarget, $fullLink);
Copy link
Member

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.

@reyostallenberg reyostallenberg force-pushed the link-task branch 4 times, most recently from 0480382 to 8768b35 Compare April 20, 2017 15:33
@nickvanderzwet
Copy link

Is it better to wait for this PR of should I make custom implementations for each project?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

3 participants