Skip to content

platform pkg re-org and initial local file plugin - #41

Merged
tannerjfco merged 7 commits into
masterfrom
local-plugin
Mar 8, 2017
Merged

tannerjfco merged 7 commits into
masterfrom
local-plugin

Conversation

@frodopwns

@frodopwns frodopwns commented Mar 2, 2017 •

Copy link
Copy Markdown
Contributor

This PR re-organizes and renames so that we have a platform package representing the current interface and plugins. This also introduces the start of a local file plugin, temporarily relying on newmedia archives present on the user's system.

Related Issues

#27
#12
#26

@frodopwns

Copy link
Copy Markdown
Contributor Author

Need to work out the merge conflicts but i don't plan on adding anything else to this PR...branch is just named wrong t this point.

@tannerjfco

tannerjfco commented Mar 7, 2017 •

Copy link
Copy Markdown
Contributor

With the changes I added I'm able to spin up a site successfully, though its a very unintuitive workflow right now:

  1. ddev add drud-d8 production -p local - this one will fail and its fine
  2. cd to ~/.drud/local and you will see drud-d8-production folder created there with src, data, files directories.
  3. Manually stage assets - clone repo to src, place sql dump as data.sql inside data, place files directory at files
  4. Run ddev add drud-d8 production -p local again and it will succeed.

This would obviously be a fair bit of manual effort every time we add a site, and we don't yet have the working directory-based approach, an init cmd, or anything else to not make this workflow janky in the interim.

proposal

An option we could consider with this PR would be to use the existing UnpackResources() logic from legacy in the local plugin for the short term, and define a location on the system where it would pull the archive from, since it won't be coming from S3.

We would still be dependent on the newmedia archive format temporarily, but I believe this would unblock the removal of the legacy plugin, and allow for the removal of our S3 and Vault go dependencies. This would in turn unblock wrangling of the vendor directory.

I do not believe we are talking about much effort to go this route, and I feel like it would allow for some tasks to move in parallel that otherwise would have been blocked on the full local file implementation, workflow changes, etc.

@tannerjfco

tannerjfco commented Mar 7, 2017 •

Copy link
Copy Markdown
Contributor

With the commit I just pushed, the workflow becomes the following:

  1. ddev add drud-d8 production -p local - this one will fail and its fine
  2. cd to ~/.drud/local, download latest archive here. Rename the archive to remove the timestamp. e.g. archive location: ~/.drud/local/production-drud-d8.tar.gz
  3. Replace ~/.drud/local/[sitename]/src with clone of repo
  4. Run ddev add drud-d8 production -p local again and it will succeed.

@rfay rfay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm putting "approve" here to not be in the way, but the basic issues are as commented: This must be viewed as a model for all future work, so should be viewed as that instead of as just a first cut of what we're trying to accomplish right now. Long term I'd like to see only one-file-per-plugin-type in the platform directory, other things moved out, and clear comments about what's being accomplished in each interface method.

I'd like to be confident that this is working with a few different tarballs before it goes in. It seems like we (might have) lost a little ground with the switch to tarballs.

}

// AddHostsEntry will add the local site URL to the local hostfile.
func (l *LocalApp) AddHostsEntry() error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be in the plugin unless I'm missing something.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. (boring history) I believe this was added before there was an abstraction on platforms, and it made slightly more sense in that context. Probably was the wrong place for it even then, though.

// HostName returns the hostname of a given application.
func (l *LocalApp) HostName() string {
return l.ContainerName()
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually none of this should be in the plugin should it? I assume we have an assumption of how container names map to hostname and such? Or is that not true?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be valid that a URL can be altered by a config file, but even then it probably shouldn't be plugin specific.

if l.AppType == "wp" {
fileDir = "content/uploads"
} else if l.AppType == "drupal" || l.AppType == "drupal8" {
fileDir = "sites/default/files"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind this for today, but this isn't a valid assumption, and should not live as a literal in the code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is addressed with the dcfg work.

} else if l.AppType == "drupal" || l.AppType == "drupal8" {
fileDir = "sites/default/files"
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do add some comments in this file explaining the overall strategy of what is being accomplished.

out, err = system.RunCommand(
"chmod",
[]string{"-R", "+rwx", path.Join(basePath, "files")},
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, please no. If we can't do any better, chmod -R ugo+rw. Total security disasters like making everything 777 can find their way into the future and we don't want that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The good news is it's not cross-platform.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will go when we remove the archive dependency, so chmod -R ugo+rw is good enough for now.

)
}

// SetType determines the app type and sets it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a general comment (and I know this is from old times). Instead of saying something obvious like what you could guess from the function name anyway, say how it determines the app type, what an "app type" is, and things like that. (Does not need to be resolved in this PR)

@tannerjfco tannerjfco changed the title reorganize where the platform plugins live before proceeding with the… platform pkg re-org and initial local file plugin Mar 7, 2017
@beeradb beeradb mentioned this pull request Mar 8, 2017
7 tasks done
@tannerjfco tannerjfco added this to the v0.1 milestone Mar 8, 2017
@tannerjfco tannerjfco self-assigned this Mar 8, 2017

@beeradb beeradb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also approve, with most of the same reservations as Randy. Feels like we need this to move forward, but I do hope we improve it and make it a better example as we go.

@tannerjfco

tannerjfco commented Mar 8, 2017 •

Copy link
Copy Markdown
Contributor

I took a minute to pull out the git and config related functionality to their own files, as we're likely to want to remove them from the platform package, either by deprecating the functionality or moving to a more sensible package.

@tannerjfco
tannerjfco merged commit 57b5cdf into master Mar 8, 2017
@rickmanelius

Copy link
Copy Markdown
Contributor

I know a lot is in flight, so just noting my results from having a machine with no trace of ddev.

  • cd to ~/.drud/local => I assume thist should be created given it wasn't there upon running the initial "ddev add".
  • Clone repo to src was a bit unclear.
  • There appears to be a transpose happening on the files ~/.drud/local/production-drud-d8 and ~/.drud/local/drud-d8-production.
  • At the moment, the master branch still requires you to be in ~/.drud

Anyway, it may be user error or things in flight.

@tannerjfco

Copy link
Copy Markdown
Contributor

On the first bullet, these folders are created the first time you run the start cmd. That's why we do it twice - to create the folders for that site, then manually satisfy the src checkout, and run again.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants