paketo-buildpacks / libpak

An opinionated extension to the libcnb Cloud Native Buildpack Library
Apache License 2.0
15 stars 17 forks source link

Add a CopyFile method that takes in source as a string #354

Open dmikusa opened 1 month ago

dmikusa commented 1 month ago

Describe the Enhancement

CopyFile takes in the file as the first argument and the dest as a string. This is nice, but often you have the source as a string too. Then the buildpack has to open the file first and pass that into CopyFile.

We should add a CopyFile method that takes string as the input.

Possible Solution

This will be a little tricky because Go doesn't support argument overloading, so we'll need to give it a different name, like CopyFileFrom.

Motivation

Reduce code in buildpacks, reduce error handling and potential problems from not handling errors correctly.