Skip to content

Commit

Permalink
Read token from status for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
davidor committed Feb 15, 2022
1 parent 71276a4 commit 138a946
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apis/datadoghq/v1alpha1/datadogagent_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ func defaultClusterAgentToken(dda *DatadogAgent, dso *DatadogAgentStatus) {
if tokenAlreadyDefaulted {
dso.DefaultOverride.Credentials.Token = dda.Status.DefaultOverride.Credentials.Token
} else {
dso.DefaultOverride.Credentials.Token = apiutils.GenerateRandomString(32)
// For backwards-compatibility, if the token is already in the status
// use it.
if dso.ClusterAgent != nil && dso.ClusterAgent.GeneratedToken != "" {
dso.DefaultOverride.Credentials.Token = dso.ClusterAgent.GeneratedToken
} else {
dso.DefaultOverride.Credentials.Token = apiutils.GenerateRandomString(32)
}
}
}

Expand Down

0 comments on commit 138a946

Please sign in to comment.