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

Don't create OCI Vault secrets with empty datasource name #6870

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
"CreatingSecret=Creating secret {0}",
"UpdatingSecret=Updating secret {0}",
"UpdatingVault=Updating {0} Vault",
"ReadingSecrets=Reading existing Secrets"
"ReadingSecrets=Reading existing Secrets",
"DatasourceEmpty=Datasource name cannot be empty"
})
public class AddDbConnectionToVault implements ActionListener {

Expand Down Expand Up @@ -437,6 +438,9 @@ class OverwriteStep implements Step<Result, Result> {
@Override
public Step<Result, Result> prepare(Result result) {
this.result = result;
if (result.datasourceName == null || result.datasourceName.isEmpty()) {
return this;
}
List<SecretItem> secrets = SecretNode.getSecrets().apply(result.vault);
this.dsNames = secrets.stream()
.map(s -> extractDatasourceName(s.getName()))
Expand All @@ -447,6 +451,9 @@ public Step<Result, Result> prepare(Result result) {

@Override
public NotifyDescriptor createInput() {
if (result.datasourceName == null || result.datasourceName.isEmpty()) {
return new NotifyDescriptor.QuickPick("", Bundle.DatasourceEmpty(), Collections.emptyList(), false);
}
List<Item> yesNo = new ArrayList();
yesNo.add(new Item(Bundle.AddVersion(), ""));
yesNo.add(new Item(Bundle.Cancel(), ""));
Expand Down Expand Up @@ -474,7 +481,7 @@ public Result getValue() {

@Override
public boolean onlyOneChoice() {
return !dsNames.contains(result.datasourceName);
return dsNames != null && !dsNames.contains(result.datasourceName);
}

}
Expand Down Expand Up @@ -664,10 +671,16 @@ Object getResult() {
public void actionPerformed(ActionEvent e) {
Multistep multistep = new Multistep(new TenancyStep());

NotifyDescriptor.ComposedInput ci = new NotifyDescriptor.ComposedInput(Bundle.AddADB(), 3, multistep.createInput());
NotifyDescriptor.ComposedInput ci = new NotifyDescriptor.ComposedInput(Bundle.AddADBToVault(), 3, multistep.createInput());
if (DialogDescriptor.OK_OPTION == DialogDisplayer.getDefault().notify(ci)) {
if (multistep.getResult() != null) {
addDbConnectionToVault((Result) multistep.getResult());
Result result = (Result) multistep.getResult();
if (result.datasourceName == null || result.datasourceName.isEmpty()) {
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(Bundle.DatasourceEmpty());
DialogDisplayer.getDefault().notify(msg);
return;
}
addDbConnectionToVault(result);
}
}

Expand Down