Skip to content

Commit

Permalink
annotationPhpExecCmd bool fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-lozoya committed Feb 1, 2024
1 parent 4d62edf commit f9d5fde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Publish php Newrelic-Instrumentation"
name: "Publish PHP Newrelic-Instrumentation"

on:
push:
Expand Down
7 changes: 5 additions & 2 deletions pkg/instrumentation/php.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
phpSilentOptionArgument = "1"
phpInitContainerName = initContainerName + "-php"
phpVolumeName = volumeName + "-php"
phpInstallArgument = "/newrelic-instrumentation/newrelic-install install && sed -i -e \"s/PHP Application/$NEW_RELIC_APP_NAME/g; s/REPLACE_WITH_REAL_KEY/$NEW_RELIC_LICENSE_KEY/g\" /usr/local/etc/php/conf.d/newrelic.ini && "
phpInstallArgument = "/newrelic-instrumentation/newrelic-install install && sed -i -e \"s/PHP Application/$NEW_RELIC_APP_NAME/g; s/REPLACE_WITH_REAL_KEY/$NEW_RELIC_LICENSE_KEY/g\" /usr/local/etc/php/conf.d/newrelic.ini"
)

func injectPhpagent(phpSpec v1alpha1.Php, pod corev1.Pod, index int) (corev1.Pod, error) {
Expand Down Expand Up @@ -78,10 +78,13 @@ func injectPhpagent(phpSpec v1alpha1.Php, pod corev1.Pod, index int) (corev1.Pod
})
}

// Continue with the function regardless of whether annotationPhpExecCmd is present or not
execCmd, ok := pod.Annotations[annotationPhpExecCmd]
if ok {
// Add phpInstallArgument to the command field.
container.Command = append(container.Command, "/bin/sh", "-c", phpInstallArgument+execCmd)
container.Command = append(container.Command, "/bin/sh", "-c", phpInstallArgument+" && "+execCmd)
} else {
container.Command = append(container.Command, "/bin/sh", "-c", phpInstallArgument)
}

return pod, nil
Expand Down

0 comments on commit f9d5fde

Please sign in to comment.