-
Notifications
You must be signed in to change notification settings - Fork 356
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 Remote Config Rollback operation #885
Conversation
2234b10
to
1a43947
Compare
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.
Looks great! Just a couple of nits.
src/index.d.ts
Outdated
@@ -1025,6 +1025,18 @@ declare namespace admin.remoteConfig { | |||
*/ | |||
publishTemplate(template: RemoteConfigTemplate, options?: { force: boolean }): Promise<RemoteConfigTemplate>; | |||
|
|||
/** | |||
* Rollbacks a project's published Remote Config template to the one specified by the provided |
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.
"... to the specified version."
return this.httpClient.send(request); | ||
}) | ||
.then((resp) => { | ||
if (!validator.isNonEmptyString(resp.headers['etag'])) { |
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'd assume this logic is used by at least one other method (getTemplate). Extract into a helper method?
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.
Good catch! Moved to a helper method. Thanks!
Hi @egilmorez ! Please review the docstrings in |
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.
Some things to look at Lahiru, thanks!
src/index.d.ts
Outdated
@@ -1025,6 +1025,18 @@ declare namespace admin.remoteConfig { | |||
*/ | |||
publishTemplate(template: RemoteConfigTemplate, options?: { force: boolean }): Promise<RemoteConfigTemplate>; | |||
|
|||
/** | |||
* Rollbacks a project's published Remote Config template to the specified version. |
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.
Despite the noun "rollback" we still would way "Rolls back a project's . . . "
src/index.d.ts
Outdated
/** | ||
* Rollbacks a project's published Remote Config template to the specified version. | ||
* A rollback is equivalent to getting a previously published Remote Config | ||
* template, and re-publishing it using a force update. |
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.
Suggest omitting the comma here.
src/index.d.ts
Outdated
* template, and re-publishing it using a force update. | ||
* | ||
* @param versionNumber The version number of the Remote Config template to rollback to. | ||
* The specified version number must be less than the current version number, and not have |
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.
Suggest "lower than"
Thanks @egilmorez ! Updated. |
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.
One tiny change related to the shared util.
'ETag header is not present in the server response.'); | ||
} | ||
this.validateResponseEtag(resp.headers['etag']); | ||
return { |
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.
This can also go into a util right? Something like:
return this.createRemoteConfigTemplate(resp);
The util can do the validation and then extract the right properties from the response.
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.
Great point! Moved the creation to a new util. Thanks!
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 with a couple of nits to think about.
conditions: resp.data.conditions, | ||
parameters: resp.data.parameters, | ||
parameterGroups: resp.data.parameterGroups, | ||
etag: etag, |
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.
Nit: You can just do etag,
here.
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.
Thanks!
@@ -140,16 +134,11 @@ export class RemoteConfigApiClient { | |||
this.validateRemoteConfigTemplate(template); | |||
return this.sendPutRequest(template, template.etag, true) | |||
.then((resp) => { | |||
// validating a template returns an etag with the suffix -0 means that your update |
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.
Do we ever check for this -0
suffix?
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 don't necessarily check for -0
suffix here. If the response is not an error (200 OK) and contains a valid etag, we can safely assume that the template was successfully validated. All other cases should return an error code. I will add an additional check for the -0
suffix in a separate PR for good measure :)
*/ | ||
private toRemoteConfigTemplate(resp: HttpResponse, customEtag?: string): RemoteConfigTemplate { | ||
const etag = (typeof customEtag == 'undefined') ? resp.headers['etag'] : customEtag; | ||
this.validateResponseEtag(etag); |
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.
Nit: This should be called something like validateEtag()
now.
* Get remote config template by version number (#874) * Get remote config template by version number * Refactor unit tests for Remote Config (#884) * Refactor unit tests * Add Remote Config Rollback operation (#885) * Add Remote Config Rollback operation * Update docs and move etag validation to a helper function * Update docs * Introduce a util to create a template from API response * PR fixes * Remote Config Add list versions operation (#896) * Remote Config: Add list versions operation * Add version Impl and other PR fixes * PR fixes * Imrpoved unit tests and some code clean up * Fix code formatting * Add a separate function to get a Template with version (#902) * Add version meta data to RC templates (#906) * Add version meta data to RC templates * PR fixes * Use assertion to unwrap template.version * Update Remote Config Docstrings in index.d.ts
rollback
operation to the RC APINote: The API proposal is still under review. Getting a head start here.