Skip to content
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

One WIF configuration component #29367

Merged
merged 17 commits into from
Jan 24, 2025
Merged

Conversation

Monkeychip
Copy link
Contributor

@Monkeychip Monkeychip commented Jan 17, 2025

Description

GCP is the next WIF engine to allow create/edit configuration. While creating it, I noticed it was a near identical copy/paste of the configure-azure component. Thus, I decided to create a shared create/edit configure component called configure-wif for all WIF configurable engines. Short-term this includes: AWS, Azure and soon GCP. Long-term this may include more 🤷‍♀️.

All of these WIF configurations include shared workflows:

  1. Access Type options
  2. Issuer modal and network requests
  3. Community vs. Enterprise views
  4. Error flow if either the modal.save() fails and/or issuer.save() fails.

Notes

  • Before this change, AWS allowed a user to save the lease config if the root config failed. This is no longer the case. The user must save the root config if they want to save the lease config. Originally, I had this loophole in there in the rare case a user had the ability to save the lease but not the root config. However, accounting for this case in a shared workflow creates more overhead than the benefit of potentially preventing something that is very unlikely.
  • I do not touch SSH. SSH is also one of the 4 configurable engines (AWS, Azure, GCP and SSH). However, it's configuration workflow is significantly different because it's not WIF configurable and it does some odd generate key things.
  • Combines the component tests but not the acceptance configuration tests for these engines.
  • there are no user facing changes. GCP will be added in a subsequent PR.

…the two components and associated files the new component replaces
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jan 17, 2025
Copy link

github-actions bot commented Jan 17, 2025

CI Results:
All Go tests succeeded! ✅

@@ -3,54 +3,14 @@
* SPDX-License-Identifier: BUSL-1.1
*/

import { isPresent } from '@ember/utils';
Copy link
Contributor Author

@Monkeychip Monkeychip Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely forget to remove this after the original aws/ssh configuration work. Double checked and because the save actions are now happening for all configurable secret engines within components, this controller and it's methods were not being hit. However, now I'm using it to add two attributes I want to use in the route template and pass down to the components.

@Monkeychip Monkeychip marked this pull request as ready for review January 21, 2025 18:12
@Monkeychip Monkeychip requested a review from a team as a code owner January 21, 2025 18:12
Copy link

Build Results:
All builds succeeded! ✅

Copy link
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work making this component more flexible. Mostly cleanup suggestions that are non-blocking. The only blocking comment is about the errorMessage as I'm not sure the error handling is working as expected.

Also it'd be great if we can remove assert.ok usage. Let me know if you want me to DM you the team pattern discussion I remembered that from! 😄

ui/app/components/secret-engine/configure-wif.hbs Outdated Show resolved Hide resolved
ui/app/components/secret-engine/configure-wif.hbs Outdated Show resolved Hide resolved
ui/app/components/secret-engine/configure-wif.hbs Outdated Show resolved Hide resolved
ui/app/components/secret-engine/configure-wif.hbs Outdated Show resolved Hide resolved
ui/app/components/secret-engine/configure-wif.hbs Outdated Show resolved Hide resolved
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting.. gh now shows this as a new file instead of changes on configure-azure.ts —that's why the file count jump in this last push.

{{#if @secondModel}}
<h2 class="title is-5 has-bottom-padding-s has-top-margin-l" data-test-second-model-title>
{{! additionalConfigModel fields show regardless of the vault version or what access type is selected }}
{{#if @additionalConfigModel}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rename already makes things much clearer! Thanks for the update.

// create a key that corresponds with the configs model order
// ex: adapterPath = ssh/ca-config, convert to: first-model so that you can pass to component @model={{this.model.first-model}}
const standardizedKey = this.standardizedModelName(type, adapterPath);
for (const modelName of MOUNT_CONFIG_MODEL_NAMES[type] as string[]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rename, this is easier to parse (but also grrr Ember data, I will not miss you when you're gone)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree!

assert.false(
true,
'post request was made to config/lease when no data was changed. test should fail.'
throw new Error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 This is much easier for me to follow what's happening here! Thanks for updating

@@ -196,37 +194,12 @@ module('Acceptance | aws | configuration', function (hooks) {
await runCmd(`delete sys/mounts/${path}`);
});

test('it does not save lease AWS configuration if root configuration errored on save', async function (assert) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the behavior that changed that you mentioned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct!

hellobontempo
hellobontempo previously approved these changes Jan 22, 2025
Copy link
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I think it may be worth checking with design about the error message display, I don't feel qualified to decide that 😂

});

module('Azure specific', function (hooks) {
hooks.beforeEach(function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 👏


assert
.dom(SES.configureNote('azure'))
.doesNotExist('Note specific to AWS does not show for Azure secret engine when configuring.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this assertion!

@@ -144,7 +144,7 @@ module('Integration | Component | SecretEngine::ConfigureWif', function (hooks)
assert.true(this.flashDangerSpy.notCalled, 'No danger flash messages called.');
assert.true(this.flashSuccessSpy.notCalled, 'No success flash messages called.');

assert.ok(
assert.true(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

Copy link
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thanks for addressing all of those cleanup items! ✨

@Monkeychip Monkeychip merged commit 088bb4b into main Jan 24, 2025
32 of 33 checks passed
@Monkeychip Monkeychip deleted the ui/VAULT-33327/one-config-component-2 branch January 24, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed pr/no-changelog ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants