Skip to content

Commit

Permalink
Change connector access control creation allow empty list
Browse files Browse the repository at this point in the history
Signed-off-by: zane-neo <[email protected]>
  • Loading branch information
zane-neo authored and Zhangxunmt committed Jul 11, 2023
1 parent 6294a76 commit 66750bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable;
import org.opensearch.common.util.CollectionUtils;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
Expand Down Expand Up @@ -184,7 +185,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (actions != null) {
builder.field(CONNECTOR_ACTIONS_FIELD, actions);
}
if (backendRoles != null) {
if (!CollectionUtils.isEmpty(backendRoles)) {
builder.field(BACKEND_ROLES_FIELD, backendRoles);
}
if (addAllBackendRoles != null) {
Expand Down Expand Up @@ -224,7 +225,7 @@ public void writeTo(StreamOutput output) throws IOException {
} else {
output.writeBoolean(false);
}
if (backendRoles != null) {
if (!CollectionUtils.isEmpty(backendRoles)) {
output.writeBoolean(true);
output.writeOptionalStringCollection(backendRoles);
} else {
Expand Down Expand Up @@ -267,4 +268,4 @@ public MLCreateConnectorInput(StreamInput input) throws IOException {
}
dryRun = input.readBoolean();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private void validateRequest4AccessControl(MLCreateConnectorInput input, User us
}

private void validateSecurityDisabledOrConnectorAccessControlDisabled(MLCreateConnectorInput input) {
if (input.getAccess() != null || input.getAddAllBackendRoles() != null || input.getBackendRoles() != null) {
if (input.getAccess() != null || input.getAddAllBackendRoles() != null || !CollectionUtils.isEmpty(input.getBackendRoles())) {
throw new IllegalArgumentException(
"You cannot specify connector access control parameters because the Security plugin or connector access control is disabled on your cluster."
);
Expand Down

0 comments on commit 66750bb

Please sign in to comment.