ddev / ddev-platformsh

Add integration with Platform.sh hosting service
Apache License 2.0
9 stars 10 forks source link

Add-on shouldn't use jq, base64, perl, etc without some notice or requirement #46

Closed flovntp closed 1 year ago

flovntp commented 1 year ago

Hi @rfay i can't get my Symfony project to be configured using ddev addon. This is what i get from the command line :

flovntp@VNTP-Book-2 PlatformSH % platform get 4qqp5j5vtvnom    
Selected environment: Main (main) (type: production) (by default)
Directory (default: sfcon-bigfoot-workshop): sfcon2022-workshop-ddev
Downloading project SFCon - Bigfoot - workshop (4qqp5j5vtvnom)
  Cloning into '/Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev'...
  remote: counting objects: 1710, done.        
Receiving objects: 100% (1710/1710), 3.64 MiB | 6.90 MiB/s, done.
  Resolving deltas: 100% (1014/1014), done.

The project SFCon - Bigfoot - workshop (4qqp5j5vtvnom) was successfully downloaded to: sfcon2022-workshop-ddev

You can build the project with: 
    cd sfcon2022-workshop-ddev
    platform build
flovntp@VNTP-Book-2 PlatformSH % cd sfcon2022-workshop-ddev 
flovntp@VNTP-Book-2 sfcon2022-workshop-ddev % ddev start 
Failed to get project(s): could not find a project in /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev. Have you run 'ddev config'? Please specify a project name or change directories: no .ddev/config.yaml file was found in this directory or any parent
flovntp@VNTP-Book-2 sfcon2022-workshop-ddev % ddev get platformsh/ddev-platformsh
Unable to get project(s) [platformsh/ddev-platformsh]: could not find a project in /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev. Have you run 'ddev config'? Please specify a project name or change directories: no .ddev/config.yaml file was found in this directory or any parent

Let me know if you need me to grant you access to this project, it's the SFCon workshop that we will handle with Sylvain.

note: ddev start is just a fail try, to be sure that ddev can't start as it is.

flovntp commented 1 year ago

Hi @rfay thanks to @lolautruche, i understand what i was missing and maybe i misunderstood the starting point of this addon, which is : "having a project already configure for using ddev (aka. ddev config already executed)" and the addon permit to copy/duplicate the existing PSH provisioning".

So, if i recap :

so, as a suggestion, maybe next steps for this addons should/could be :

My 2 cents

ps: you can close the issue :P

flovntp commented 1 year ago

ok, so now, my Symfony project seems to be configured but with an error at the end, while getting DATABASE infos

flovntp@VNTP-Book-2 sfcon2022-workshop-ddev % ddev get platformsh/ddev-platformsh
Downloading https://api.github.com/repos/platformsh/ddev-platformsh/tarball/v0.4.3 
v0.4.3_3495880585.tar.gz 96.44 KiB / ? [------------------------------------------------=------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 987.51% 0s 
Please enter your platform.sh token:  
XXXXXXXXX-XXXX-XXXX-XXXX-XXXXdbd638
Global configuration:
instrumentation-opt-in=true
omit-containers=[]
web-environment=[BLACKFIRE_CLIENT_ID=XXXX,BLACKFIRE_CLIENT_TOKEN=XXXX,BLACKFIRE_SERVER_ID=XXXX,BLACKFIRE_SERVER_TOKEN=XXXX,PLATFORMSH_CLI_TOKEN=XXXXXXXXX-XXXX-XXXX-XXXX-XXXXdbd638]
mutagen-enabled=false
nfs-mount-enabled=false
router-bind-all-interfaces=false
internet-detection-timeout-ms=3000
disable-http2=false
use-letsencrypt=false
letsencrypt-email=
table-style=default
simple-formatting=false
auto-restart-containers=false
use-hardened-images=false
fail-on-hook-fail=false
required-docker-compose-version=
use-docker-compose-from-path=false
no-bind-mounts=false
project-tld=
PLATFORMSH_CLI_TOKEN set globally

Please enter your platform.sh project ID (like '6k4ypl5iendqd'):  
4qqp5j5vtvnom

platform_project = '4qqp5j5vtvnom'
You are reconfiguring the project at /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev.
The existing configuration will be updated and replaced.
Configuring unrecognized codebase as project type 'php' at /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev/_www
v1.21.3: Pulling from drud/ddev-webserver
e54debc59c92: Pulling fs layer
e54debc59c92: Download complete
e54debc59c92: Pull complete
Digest: sha256:XXXXXXXXX
Status: Downloaded newer image for drud/ddev-webserver:v1.21.3
docker.io/drud/ddev-webserver:v1.21.3
Configuration complete. You may now run 'ddev start'.
PLATFORM_PROJECT set to 4qqp5j5vtvnom

You are reconfiguring the project at /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev.
The existing configuration will be updated and replaced.
Configuring unrecognized codebase as project type 'php' at /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev/_www
Configuration complete. You may now run 'ddev start'.

Please enter your platform.sh project environment (like 'main'):  
You are reconfiguring the project at /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev.
The existing configuration will be updated and replaced.
Configuring unrecognized codebase as project type 'php' at /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev/_www
Configuration complete. You may now run 'ddev start'.

Installed file /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev/.ddev/web-build/Dockerfile.platformsh 
Installed file /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev/.ddev/homeadditions/.bashrc.d/platformsh-environment.sh 
Installed file /Users/flovntp/Sites/Customers/PlatformSH/sfcon2022-workshop-ddev/.ddev/providers/platform.yaml 
Installed file /Users/flovntp/.ddev/commands/web/platform 
could not process post-install action '#ddev-nodisplay
cd ..
unset DDEV_DEBUG
project_type=$(ddev describe -j | jq -r .raw.type)
case $project_type in 
  laravel)
    # TODO: This depends on perl, but we can't start the project unless these are created
    # so can't use ddev exec yet. 
    perl -p -e 's/DB_(HOST|DATABASE|USERNAME|PASSWORD)=(.*)/DB_\1=db/g' .env.example >.env
    perl -pi.bak -e "s#APP_URL=.*#APP_URL=${DDEV_PRIMARY_URL}#g" .env
    ;;
  drupal9)
    mkdir -p .drush
    ;;
esac
': Unable to run action set -eu -o pipefail
#ddev-nodisplay
cd ..
unset DDEV_DEBUG
project_type=$(ddev describe -j | jq -r .raw.type)
case $project_type in 
  laravel)
    # TODO: This depends on perl, but we can't start the project unless these are created
    # so can't use ddev exec yet. 
    perl -p -e 's/DB_(HOST|DATABASE|USERNAME|PASSWORD)=(.*)/DB_\1=db/g' .env.example >.env
    perl -pi.bak -e "s#APP_URL=.*#APP_URL=${DDEV_PRIMARY_URL}#g" .env
    ;;
  drupal9)
    mkdir -p .drush
    ;;
esac
: exit status 127, output=bash: line 4: jq: command not found

So i guess it is the step where you try to find in the environment variable, all info about DATABASE_* ? Let me know, i could help on this part.

lolautruche commented 1 year ago

It's probably because you don't have jq locally. Can you please try to install it? brew install jq

flovntp commented 1 year ago

you're right, now it's fine :

... 
Installed file /Users/flovntp/.ddev/commands/web/platform 
Downloaded add-on platformsh/ddev-platformsh, use `ddev restart` to enable. 
Please read instructions for this addon at the source repo at
https://github.com/platformsh/ddev-platformsh
Please file issues and create pull requests there to improve it. 
lolautruche commented 1 year ago

However, I didn't know that DDEV required jq, and if so, it should be marked as a dependency in the Homebrew formula. Did you install it (DDEV itself) with Homebrew or using another way?

flovntp commented 1 year ago

homebrew

lolautruche commented 1 year ago

Could you please report an issue about this on DDEV Homebrew tap? https://github.com/drud/homebrew-ddev/issues

rfay commented 1 year ago

I didn't think there was anything in the current release of this add-on that required jq, but there is.

There's nothing about ddev that requires jq, it's just that this add-on uses it one place. That's a mistake. So no need to fiddle with homebrew tap

rfay commented 1 year ago

This is important to solve, both because we don't want to depend on user configuration, but also because base64, for example, behaves differently on macOS than on Linux. So we'll need a small docker image or something.