X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=service-exposure%2Frapps-webhook.go;h=69dcb3f56196d9be8d9dc34ade6aac08f40c5966;hb=refs%2Fchanges%2F88%2F12388%2F5;hp=242d622e82e7ab9a8869ecdebdd0d11495e8640f;hpb=b8ae6c467edee10ef39f1b43097fd1ec426e86b7;p=nonrtric.git diff --git a/service-exposure/rapps-webhook.go b/service-exposure/rapps-webhook.go index 242d622e..69dcb3f5 100644 --- a/service-exposure/rapps-webhook.go +++ b/service-exposure/rapps-webhook.go @@ -1,22 +1,22 @@ // - -// ========================LICENSE_START================================= -// O-RAN-SC -// %% -// Copyright (C) 2022: Nordix Foundation -// %% -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// ========================LICENSE_START================================= +// O-RAN-SC +// %% +// Copyright (C) 2022-2023: Nordix Foundation +// %% +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ========================LICENSE_END=================================== +// http://www.apache.org/licenses/LICENSE-2.0 // +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ========================LICENSE_END=================================== package main import ( @@ -34,10 +34,10 @@ import ( ) type ServerParameters struct { - port string // webhook server port - certFile string // path to the x509 cert - keyFile string // path to the x509 private key - hostPath string // path to the x509 private key + port string // webhook server port + certFile string // path to the x509 cert + keyFile string // path to the x509 private key + secret string } type patchOperation struct { @@ -56,7 +56,7 @@ func main() { flag.StringVar(¶meters.port, "port", "8443", "Webhook server port.") flag.StringVar(¶meters.certFile, "tlsCertFile", "/certs/tls.crt", "File containing the x509 certificate") flag.StringVar(¶meters.keyFile, "tlsKeyFile", "/certs/tls.key", "File containing the x509 private key") - flag.StringVar(¶meters.hostPath, "hostPath", "/var/rapps/certs", "Host Path containing rapp cert files") + flag.StringVar(¶meters.secret, "secret", "cm-keycloak-client-certs", "Secret containing rapp cert files") flag.Parse() http.HandleFunc("/inject-sidecar", HandleSideCarInjection) @@ -137,16 +137,13 @@ func HandleSideCarInjection(w http.ResponseWriter, r *http.Request) { Value: containers, }) - pathType := v1.HostPathDirectoryOrCreate - pathTypePtr := &pathType var volumes []v1.Volume volumes = append(volumes, pod.Spec.Volumes...) volume := v1.Volume{ Name: "certsdir", VolumeSource: v1.VolumeSource{ - HostPath: &v1.HostPathVolumeSource{ - Path: parameters.hostPath, - Type: pathTypePtr, + Secret: &v1.SecretVolumeSource{ + SecretName: parameters.secret, }, }, } @@ -154,9 +151,9 @@ func HandleSideCarInjection(w http.ResponseWriter, r *http.Request) { fmt.Println(volumes) patches = append(patches, patchOperation{ - Op: "add", - Path: "/spec/volumes", - Value: volumes, + Op: "add", + Path: "/spec/volumes", + Value: volumes, }) fmt.Println(patches)