-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add information to header #3992
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
internal/upgradecheck/header_test.go
Outdated
saveEnv(t, "PGO_FEATURE_GATES") | ||
os.Setenv("PGO_FEATURE_GATES", "Tablespace=true") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 It looks like ctx
is wired through from CheckForUpgradesScheduler.Start
. If so,1 this test can use the feature package like so:
saveEnv(t, "PGO_FEATURE_GATES") | |
os.Setenv("PGO_FEATURE_GATES", "Tablespace=true") | |
gate := feature.NewGate() | |
assert.NilError(t, gate.SetFromMap(map[string]bool{ | |
feature.TablespaceVolumes: true, | |
})) | |
ctx = feature.NewContext(ctx, gate) |
Footnotes
-
main.go initializes that base/root context. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
|
||
// saveEnv preserves environment variables so that any modifications needed for | ||
// the tests can be undone once completed. | ||
func saveEnv(t testing.TB, key string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Use T.Setenv instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled that out of all the tests.
(There's no t.Unsetenv
, but someone suggested using t.Setenv
to save the env, and then calling os.Unsetenv
, so I tried that where applicable)
internal/upgradecheck/http_test.go
Outdated
saveEnv(t, "PGO_FEATURE_GATES") | ||
os.Setenv("PGO_FEATURE_GATES", "Tablespace=true") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ I can't tell; is there a ctx
around here? If so, use that instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -86,7 +87,7 @@ func (r *Runner) CheckToken() error { | |||
r.token.Lock() | |||
defer r.token.Unlock() | |||
|
|||
_, errToken := jwt.ParseWithClaims(string(data), &r.token, key, | |||
token, errToken := jwt.ParseWithClaims(string(data), &r.token, key, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌱 Passing &r.token
here doesn't seem right according to the docs, but handling custom claims through an interface... 🤔 🤔
📝 🦆 🤔 IIUC, the other package needs only a plaintext opaque blob of "token."
internal/upgradecheck/header.go
Outdated
BridgeClustersTotal int `json:"bridge_clusters_total"` | ||
DeploymentID string `json:"deployment_id"` | ||
FeatureGatesEnabled string `json:"feature_gates_enabled"` | ||
IsOpenShift bool `json:"is_open_shift"` | ||
KubernetesEnv string `json:"kubernetes_env"` | ||
PGOClustersTotal int `json:"pgo_clusters_total"` | ||
PGOVersion string `json:"pgo_version"` | ||
RegistrationToken string `json:"registration_token"` | ||
PGOInstaller string `json:"pgo_installer"` | ||
PGOInstallerOrigin string `json:"pgo_installer_origin"` | ||
BuildSource string `json:"build_source"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ We should probably alphabetize these struct fields.
internal/upgradecheck/header.go
Outdated
BridgeClustersTotal: getBridgeClusters(ctx, crClient), | ||
FeatureGatesEnabled: feature.ShowGates(ctx), | ||
IsOpenShift: isOpenShift, | ||
DeploymentID: ensureDeploymentID(ctx, crClient), | ||
KubernetesEnv: getServerVersion(ctx, cfg), | ||
PGOClustersTotal: getManagedClusters(ctx, crClient), | ||
PGOVersion: pgoVersion, | ||
RegistrationToken: registrationToken, | ||
PGOInstaller: os.Getenv("PGO_INSTALLER"), | ||
PGOInstallerOrigin: os.Getenv("PGO_INSTALLER_ORIGIN"), | ||
BuildSource: os.Getenv("BUILD_SOURCE"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ We should probably alphabetize these struct fields.
internal/upgradecheck/http.go
Outdated
OpenShift bool | ||
Refresh time.Duration | ||
URL, Version string | ||
RegistrationToken string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ We should probably alphabetize these.
internal/upgradecheck/http.go
Outdated
Client: m.GetClient(), | ||
Config: m.GetConfig(), | ||
OpenShift: openshift, | ||
Refresh: 24 * time.Hour, | ||
URL: url, | ||
Version: version, | ||
RegistrationToken: token, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ We should probably alphabetize these.
@@ -121,3 +121,12 @@ func Enabled(ctx context.Context, f Feature) bool { | |||
func NewContext(ctx context.Context, gate Gate) context.Context { | |||
return context.WithValue(ctx, contextKey{}, gate) | |||
} | |||
|
|||
func ShowGates(ctx context.Context) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ Since this is a public function, I'd like a comment.
* Crunchy Bridge clusters managed * Features gates enabled * Registration token * Build metadata Issues: [PGO-1610, PGO-1616, PGO-1618]
c83f96b
to
049a777
Compare
Checklist:
Type of Changes:
What is the current behavior (link to any open issues here)?
What is the new behavior (if this is a feature change)?
Other Information:
Issues: [PGO-1610, PGO-1616, PGO-1618]