Skip to content

Commit

Permalink
Send event once for each component
Browse files Browse the repository at this point in the history
Signed-off-by: Anand Kumar Singh <[email protected]>
  • Loading branch information
anandrkskd committed Oct 28, 2024
1 parent c1091a5 commit 3f167f4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions controllers/argocd/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,26 @@ func shortenHostname(hostname string) (string, error) {
// a Kubernetes TLS secret if provided via the ExternalCertificate field.
func (r *ReconcileArgoCD) overrideRouteTLS(tls *routev1.TLSConfig, route *routev1.Route, cr *argoproj.ArgoCD) error {
route.Spec.TLS = tls.DeepCopy()

// Send an event when deprecated field key and certificate is used
if tls.Key != "" || tls.Certificate != "" {
// Send an event when deprecated field key and certificate is used
argoutil.CreateEvent(r.Client, "Warning", "Insecure field Used", "Using key and certificate fields are not recommended", "InsecureFields", cr.ObjectMeta, cr.TypeMeta)
// Emit event for each instance providing users with deprecation notice for `.spec.SSO` subfields if not emitted already
if currentInstanceEventEmissionStatus, ok := DeprecationEventEmissionTracker[cr.Namespace]; !ok || !currentInstanceEventEmissionStatus.TLSInsecureWarningEmitted {

Check failure on line 481 in controllers/argocd/route.go

View workflow job for this annotation

GitHub Actions / build-operator

currentInstanceEventEmissionStatus.TLSInsecureWarningEmitted undefined (type DeprecationEventEmissionStatus has no field or method TLSInsecureWarningEmitted)

Check failure on line 481 in controllers/argocd/route.go

View workflow job for this annotation

GitHub Actions / build

currentInstanceEventEmissionStatus.TLSInsecureWarningEmitted undefined (type DeprecationEventEmissionStatus has no field or method TLSInsecureWarningEmitted)

Check failure on line 481 in controllers/argocd/route.go

View workflow job for this annotation

GitHub Actions / Run end-to-end tests (v1.27.1)

currentInstanceEventEmissionStatus.TLSInsecureWarningEmitted undefined (type DeprecationEventEmissionStatus has no field or method TLSInsecureWarningEmitted)
err := argoutil.CreateEvent(r.Client, "Warning", "Insecure field Used", "WARNING: .tls.key and .tls.certificate are insecure in ArgoCD CR and not recommended. Use .tls.externalCertificate to reference a TLS secret instead.", "InsecureFields", cr.ObjectMeta, cr.TypeMeta)
if err != nil {
return err
}

if !ok {
currentInstanceEventEmissionStatus = DeprecationEventEmissionStatus{TLSInsecureWarningEmitted: true}

Check failure on line 488 in controllers/argocd/route.go

View workflow job for this annotation

GitHub Actions / build-operator

unknown field TLSInsecureWarningEmitted in struct literal of type DeprecationEventEmissionStatus

Check failure on line 488 in controllers/argocd/route.go

View workflow job for this annotation

GitHub Actions / build

unknown field TLSInsecureWarningEmitted in struct literal of type DeprecationEventEmissionStatus

Check failure on line 488 in controllers/argocd/route.go

View workflow job for this annotation

GitHub Actions / Run end-to-end tests (v1.27.1)

unknown field TLSInsecureWarningEmitted in struct literal of type DeprecationEventEmissionStatus
} else {
currentInstanceEventEmissionStatus.TLSInsecureWarningEmitted = true

Check failure on line 490 in controllers/argocd/route.go

View workflow job for this annotation

GitHub Actions / build-operator

currentInstanceEventEmissionStatus.TLSInsecureWarningEmitted undefined (type DeprecationEventEmissionStatus has no field or method TLSInsecureWarningEmitted)

Check failure on line 490 in controllers/argocd/route.go

View workflow job for this annotation

GitHub Actions / build

currentInstanceEventEmissionStatus.TLSInsecureWarningEmitted undefined (type DeprecationEventEmissionStatus has no field or method TLSInsecureWarningEmitted)

Check failure on line 490 in controllers/argocd/route.go

View workflow job for this annotation

GitHub Actions / Run end-to-end tests (v1.27.1)

currentInstanceEventEmissionStatus.TLSInsecureWarningEmitted undefined (type DeprecationEventEmissionStatus has no field or method TLSInsecureWarningEmitted)
}
DeprecationEventEmissionTracker[cr.Namespace] = currentInstanceEventEmissionStatus
}

// These fields are deprecated in favor of using `.tls.externalCertificate` to reference a Kubernetes TLS secret.
log.Info("WARNING: Using `.tls.key` and `.tls.certificate` are insecure fields in ArgoCD CR and is not recommended. Use `.tls.externalCertificate` to reference a TLS secret instead.")
log.Info("WARNING: .tls.key and .tls.certificate are insecure in ArgoCD CR and not recommended. Use .tls.externalCertificate to reference a TLS secret instead.")
}

// Populate the Route's `tls.key` and `tls.certificate` fields with data from the specified Kubernetes TLS secret.
Expand Down

0 comments on commit 3f167f4

Please sign in to comment.