Skip to content

Commit

Permalink
Merge pull request #294 from NikitaSkrynnik/pods-name-only
Browse files Browse the repository at this point in the history
Generate client ID for pods only
  • Loading branch information
denis-tingaikin authored May 23, 2023
2 parents c77a772 + 2d428a9 commit 13cf707
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ func (s *admissionWebhookServer) Review(ctx context.Context, in *admissionv1.Adm
}

if annotation != "" {
clientID := uuid.NewString()
nsmNameEnv := corev1.EnvVar{Name: "NSM_NAME", Value: "$(POD_NAME)"}
if podMetaPtr.GenerateName == "" {
clientID := uuid.NewString()
nsmNameEnv.Value = fmt.Sprintf("$(POD_NAME)-%v", clientID)
}
envVars := append(s.config.GetOrResolveEnvs(),
corev1.EnvVar{Name: s.config.NSURLEnvName, Value: annotation},
corev1.EnvVar{Name: "NSM_NAME", Value: fmt.Sprintf("$(POD_NAME)-%v", clientID)})
nsmNameEnv)

bytes, err := json.Marshal([]jsonpatch.JsonPatchOperation{
s.createInitContainerPatch(p, annotation, spec.InitContainers, envVars...),
Expand Down

0 comments on commit 13cf707

Please sign in to comment.