Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/go-eb87049800
Browse files Browse the repository at this point in the history
  • Loading branch information
pdabelf5 authored Dec 8, 2023
2 parents ab0070b + e037db0 commit c42c70d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
28 changes: 24 additions & 4 deletions cmd/nginx-ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ import (
var version string

const (
nginxVersionLabel = "app.nginx.org/version"
versionLabel = "app.kubernetes.io/version"
nginxVersionLabel = "app.nginx.org/version"
versionLabel = "app.kubernetes.io/version"
appProtectVersionLabel = "appprotect.f5.com/version"
appProtectVersionPath = "/opt/app_protect/VERSION"
)

func main() {
Expand All @@ -71,7 +73,12 @@ func main() {

nginxVersion := getNginxVersionInfo(nginxManager)

updateSelfWithVersionInfo(kubeClient, version, nginxVersion)
var appProtectVersion string
if *appProtect {
appProtectVersion = getAppProtectVersionInfo()
}

updateSelfWithVersionInfo(kubeClient, version, nginxVersion, appProtectVersion)

templateExecutor, templateExecutorV2 := createTemplateExecutors()

Expand Down Expand Up @@ -402,6 +409,16 @@ func getNginxVersionInfo(nginxManager nginx.Manager) string {
return nginxVersion
}

func getAppProtectVersionInfo() string {
v, err := os.ReadFile(appProtectVersionPath)
if err != nil {
glog.Fatalf("Cannot detect the AppProtect version, %s", err.Error())
}
version := strings.TrimSpace(string(v))
glog.Infof("Using AppProtect Version %s", version)
return version
}

func startApAgentsAndPlugins(nginxManager nginx.Manager) (chan error, chan error) {
var aPPluginDone chan error

Expand Down Expand Up @@ -766,7 +783,7 @@ func processConfigMaps(kubeClient *kubernetes.Clientset, cfgParams *configs.Conf
return cfgParams
}

func updateSelfWithVersionInfo(kubeClient *kubernetes.Clientset, version string, nginxVersion string) {
func updateSelfWithVersionInfo(kubeClient *kubernetes.Clientset, version string, nginxVersion string, appProtectVersion string) {
pod, err := kubeClient.CoreV1().Pods(os.Getenv("POD_NAMESPACE")).Get(context.TODO(), os.Getenv("POD_NAME"), meta_v1.GetOptions{})
if err != nil {
glog.Errorf("Error getting pod: %v", err)
Expand All @@ -783,6 +800,9 @@ func updateSelfWithVersionInfo(kubeClient *kubernetes.Clientset, version string,
replacer := strings.NewReplacer(" ", "-", "(", "", ")", "")
nginxVer = replacer.Replace(nginxVer)
labels[nginxVersionLabel] = nginxVer
if appProtectVersion != "" {
labels[appProtectVersionLabel] = appProtectVersion
}
labels[versionLabel] = strings.TrimPrefix(version, "v")
newPod.ObjectMeta.Labels = labels

Expand Down
12 changes: 6 additions & 6 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ forcediphttpsadapter==1.1.0 \
--hash=sha256:0d224cf6e8e50eb788c9f5994a7afa6d389bac6dbe540b7dfd77a32590ad0153 \
--hash=sha256:5e7662ece61735585332d09b87d94fffe4752469d5c0d3feff48746e5d70744b
# via -r requirements.txt
google-auth==2.23.4 \
--hash=sha256:79905d6b1652187def79d491d6e23d0cbb3a21d3c7ba0dbaa9c8a01906b13ff3 \
--hash=sha256:d4bbc92fe4b8bfd2f3e8d88e5ba7085935da208ee38a134fc280e7ce682a05f2
google-auth==2.24.0 \
--hash=sha256:2ec7b2a506989d7dbfdbe81cb8d0ead8876caaed14f86d29d34483cbe99c57af \
--hash=sha256:9b82d5c8d3479a5391ea0a46d81cca698d328459da31d4a459d4e901a5d927e0
# via
# -r requirements.txt
# kubernetes
Expand Down Expand Up @@ -538,9 +538,9 @@ urllib3==2.1.0 \
# -r requirements.txt
# kubernetes
# requests
websocket-client==1.6.4 \
--hash=sha256:084072e0a7f5f347ef2ac3d8698a5e0b4ffbfcab607628cadabc650fc9a83a24 \
--hash=sha256:b3324019b3c28572086c4a319f91d1dcd44e6e11cd340232978c684a7650d0df
websocket-client==1.7.0 \
--hash=sha256:10e511ea3a8c744631d3bd77e61eb17ed09304c413ad42cf6ddfa4c7787e8fe6 \
--hash=sha256:f4c3d22fec12a2461427a29957ff07d35098ee2d976d3ba244e688b8b4057588
# via
# -r requirements.txt
# kubernetes
Expand Down

0 comments on commit c42c70d

Please sign in to comment.