Remove the requirement of setting a ssh key during serviceuser creation You may not want use ssh with your serviceuser and if you do you can always add the ssh key afterwards. Change-Id: Ice70be870dc6811ab80b5f49b878e19ade85b64d
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java index 7e2e18a..a4ced57 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java +++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java
@@ -132,11 +132,7 @@ throw new BadRequestException("username must match URL"); } - if (Strings.isNullOrEmpty(input.sshKey)) { - throw new BadRequestException("sshKey not set"); - } - - if (!SshKeyValidator.validateFormat(input.sshKey)) { + if (input.sshKey != null && !SshKeyValidator.validateFormat(input.sshKey)) { throw new BadRequestException("sshKey invalid."); }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserCommand.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserCommand.java index 3f27975..4ee88ee 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserCommand.java
@@ -40,7 +40,7 @@ @Option( name = "--ssh-key", - required = true, + required = false, metaVar = "-|KEY", usage = "public key for SSH authentication") private String sshKey;
diff --git a/web/gr-serviceuser-create.ts b/web/gr-serviceuser-create.ts index 3ee2a70..eaf864b 100644 --- a/web/gr-serviceuser-create.ts +++ b/web/gr-serviceuser-create.ts
@@ -58,9 +58,6 @@ @query('#serviceUserEmailInput') serviceUserEmailInput!: HTMLInputElement; - @query('#serviceUserKeyInput') - serviceUserKeyInput!: HTMLInputElement; - @property() plugin!: PluginApi; @@ -94,9 +91,6 @@ @property({type: String}) email?: String; - @property({type: String}) - key?: String; - @property({type: Object}) accountId?: AccountId; @@ -141,20 +135,6 @@ </section> ${this.renderEmailInputSection()} </fieldset> - <fieldset> - <section> - <span class="title">Public SSH key</span> - <span class="value"> - <iron-autogrow-textarea - id="serviceUserKeyInput" - .bind-value="${this.key}" - placeholder="New SSH Key" - @bind-value-changed=${this.validateData} - > - </iron-autogrow-textarea> - </span> - </section> - </fieldset> <gr-button id="createButton" @click=${this.handleCreateServiceUser} @@ -253,8 +233,7 @@ private validateData() { this.dataValid = this.validateName(this.serviceUserNameInput.value) && - this.validateEmail(this.serviceUserEmailInput?.value) && - this.validateKey(this.serviceUserKeyInput.value); + this.validateEmail(this.serviceUserEmailInput?.value); } private validateName(username: String | undefined) { @@ -275,19 +254,9 @@ return false; } - private validateKey(key: String | undefined) { - if (!key?.trim()) { - return false; - } - - this.key = key; - return true; - } - private handleCreateServiceUser() { this.isAdding = true; const body: ServiceUserInput = { - ssh_key: this.key ? this.key.trim() : '', email: this.email ? this.email.trim() : '', }; return this.plugin