@@ -737,6 +737,16 @@ func newConfigFile(job buildJob, p v1.Platform, base v1.Image, imageLayers []ima
737
737
// the container. This consists of func-provided build metadata envs as well
738
738
// as any environment variables provided on the function itself.
739
739
func newConfigEnvs (job buildJob ) []string {
740
+ // TODO: long-term, the correct architecture is to not read env vars
741
+ // from deep within a package, but rather to expose the setting as a
742
+ // variable and leave interacting with the environment to main.
743
+ // This is a shortcut used by many packages, however, so it will work for
744
+ // now.
745
+ gitbin := os .Getenv ("FUNC_GIT" ) // Use if provided
746
+ if gitbin == "" {
747
+ gitbin = "git" // default to looking on PATH
748
+ }
749
+
740
750
envs := []string {}
741
751
742
752
// FUNC_CREATED
@@ -749,14 +759,14 @@ func newConfigEnvs(job buildJob) []string {
749
759
// environment FUNC_VERSION will be populated. Otherwise it will exist
750
760
// (to indicate this logic was executed) but have an empty value.
751
761
if job .verbose {
752
- fmt .Fprintf (os .Stderr , "cd %v && export FUNC_VERSION=$(git describe --tags)\n " , job .function .Root )
762
+ fmt .Fprintf (os .Stderr , "cd %v && export FUNC_VERSION=$(%v describe --tags)\n " , job .function .Root , gitbin )
753
763
}
754
- cmd := exec .CommandContext (job .ctx , "git" , "describe" , "--tags" )
764
+ cmd := exec .CommandContext (job .ctx , gitbin , "describe" , "--tags" )
755
765
cmd .Dir = job .function .Root
756
766
output , err := cmd .Output ()
757
767
if err != nil {
758
768
if job .verbose {
759
- fmt .Fprintf (os .Stderr , "unable to determine function version. %v\n " , err )
769
+ fmt .Fprintf (os .Stderr , "WARN: unable to determine function version. %v\n " , err )
760
770
}
761
771
envs = append (envs , "FUNC_VERSION=" )
762
772
} else {
0 commit comments