User Tools

Site Tools


fgm

This is an old revision of the document!


  • Tip of the day: using Homebrew to get PHP Pear extensions behind a proxy by Frederic Marand (2023/06/01 12:15)
    Tip of the day: using Homebrew to get PHP Pear extensions behind a proxy Frederic Marand Thu, 2023-06-01 14:15 PHP php pear pecl Homebrew macos Most of the time, installing tools using Homebrew works flawlessly, including PHP these days. However, having to work in a client environment requiring a proxy, the PHP 8.1 post-install failed when updating Pear/Pecl channels, although the usual http_proxy and https_proxy were set and worked normally, including for the other Homebrew tasks. What could be going on ? Turns out, the culprit is pear, which does not use those standard environment variables, but needs its own configuration, which is documented on https://pear.php.net/manual/en/guide.users.commandline.config.php The key is to simply add that config from the Pear CLI: pear config-set http_proxy http://(proxy IP):(proxy port) After that, pear update-channels works.. .. and so do brew install php@8.1, or just brew postinstall php@8.1 if you got tired of waiting for a timeout in brew install php@8.1 and killed it with ^C. That's all it takes!
  • The end of function execution in Go code by Frederic Marand (2023/05/29 19:24)
    The end of function execution in Go code Frederic Marand Mon, 2023-05-29 21:24 Google Go = Golang DevoxxFR Every Go function needs to end at some point, even main and test functions. But the way the end impacts how we can work after they finish. This presentation created for DevoxxFR 2023 describes the available mechanisms.
  • Tip of the day: validating a Jenkinsfile from the CLI with HTTPie by Frederic Marand (2023/05/19 12:56)
    Tip of the day: validating a Jenkinsfile from the CLI with HTTPie Frederic Marand Fri, 2023-05-19 14:56 Computing devops jenkins An easily missed feature in Jenkins is the bundled linter for Jenkinsfiles. While there are many examples about how to use it with cURL, I could not find any using HTTPie, which I find much more convenient in general than cURL. So, after some fumbling due to the little documented expectations of the validator, here is the solution showing how to validate a Jenkinsfile from the CLI: http --form                                         \     -a $USER:$PASS                                 \     -pb                                            \     POST                                           \     $JENKINS_URL/pipeline-model-converter/validate \     jenkinsfile=@$JENKINSFILE Let's see what these arguments mean: --form specifies use of the application/x-www-form-urlencoded MIME type, as expected by the validator -a $USER:$PASS provides basic authentication credentials. If you do not want to include the password, just use $USER: and HTTPie will request the password on the CLI. This assumes these two variables contain your Jenkins username and password -pb asks HTTPie to only print the response body $JENKINS_URL is the absolute URL to the Jenkins root $JENKINSFILE is the path to the Jenkinsfile to validate. May be relative or absolute That's it. Note that, as usual with HTTPie, the ordering is strict: http the command itself The options, like -a and --form The method, in this case POST. HTTPie uses GET by default The target URL The so-called "fields", which translate to the request body. In this case, the jenkinsfile=@$JENKINSFILE requests HTTPie to load the contents of the file designated by $JENKINSFILE and load that content as the value of the jenkinsfile HTML form field Hopefully, you will receive a result looking like this: Jenkinsfile successfully validated. More details in the HTTPie forms documentation.
  • Writing an SMTP service in Go by Frederic Marand (2023/04/14 09:46)
    Writing an SMTP service in Go Frederic Marand Fri, 2023-04-14 11:46 Google Go = Golang smtp DevoxxFR Because sometimes, it's nicer to users to allow them to contact us by email, it occasionally becomes useful to handle incoming mail. Let's see how. In this talk I have at DevoxxFR 2023 on 2023-04-14, we shall see the pros and cons of push (straight SMTP with or without TLS) vs pull (POP3, IMAP4, CDO, MAPI...) strategies to handle incoming mail how to choose between full custom code and the cloud solutions provided by AWS SES and GCP GAE inbound email handling a concrete example of how to write a SMTP server pretty much like one would write a classic HTTP server in Go 1.20
  • Tip of the day: running Flagr Docker image on a M1 mac by Frederic Marand (2022/10/21 15:04)
    Tip of the day: running Flagr Docker image on a M1 mac Frederic Marand Fri, 2022-10-21 17:04 Computing Google Go = Golang macos Docker After almost one year with an Apple Silicon macBook, I eventually got my first actual problem caused by the architecture : trying to deploy the Flagr Open Source feature flags service, the docker deployment failed like with an image error. The fix turned out to be fairly simple: The problem One deploys Flagr initially by pulling an image and running it, to avoid the complexity of having to build it. From their Get Started page: # Start the docker container$ docker pull ghcr.io/openflagr/flagr$ docker run -it -p 18000:18000 ghcr.io/openflagr/flagr# Open the Flagr UI$ open localhost:18000 The pull step went through just fine, but when trying the docker run an issue appeared: $ docker run -it -p 18000:18000 ghcr.io/openflagr/flagrWARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requesteddocker: Error response from daemon: platform linux/arm64/v8 not supported.ERRO[0000] error waiting for container: context canceled$ Diagnostic The error is fairly clear: without specifying an architecture, the download image is the one built for linux/amd64 and our M1 on macOS, needs an image for darwin/arm64. How do we specify this to docker ? Turns out docker has an argument for this: --platform=darwin/amd64, to be used with Docker commands, by passing it before the name of the image: docker pull --platform=darwin/arm64 ghcr.io/openflagr/flagrdocker run -it -p 18000:18000 --platform=darwin/arm64  ghcr.io/openflagr/flagr However, this is not really better, although the error is different: $ docker run -it -p 18000:18000 --platform=darwin/arm64  ghcr.io/openflagr/flagrUnable to find image 'ghcr.io/openflagr/flagr:latest' locally8d68b8be8eac: Existsaa19e9ea6d59: Existsdocker: Error response from daemon: platform darwin/arm64 not supported.See 'docker run --help'.$ After some more checks, it appears flagr:1.1, currently the latest version, is not built for arm64. OK, but then we should be able to run using the Rosetta 2 emulation. How can we can check if Rosetta is running ? Solution is with something like pgrep oahd (but it could be a false positive) or something safer like ps -e | grep oahd. And of course I had never needed it yet :facepalm . The solution So let's install Rosetta 2: $ softwareupdate --install-rosettaI have read and agree to the terms of the software license agreement. A list of Apple SLAs may be found here: http://www.apple.com/legal/sla/Type A and press return to agree: a2022-10-21 17:24:32.524 softwareupdate[38332:520724] Package Authoring Error: 012-40509: Package reference com.apple.pkg.RosettaUpdateAuto is missing installKBytes attributeInstall of Rosetta 2 finished successfully$ At this point we should now be able to run x84-64 (amd64) binaries, including that Flagr image: $ docker pull --platform=linux/amd64 ghcr.io/openflagr/flagrUsing default tag: latestaa19e9ea6d59: Exists8d68b8be8eac: Existsghcr.io/openflagr/flagr:latest$ docker run -it -p 18000:18000 --platform=linux/amd64  ghcr.io/openflagr/flagrINFO[0000] Serving flagr at http://[::]:18000 Problem solved ! We now have a working Flagr server on the M1 macBook.
fgm.1241793781.txt.gz · Last modified: 2020/11/23 17:23 (external edit)