cmccabe commented on code in PR #13114: URL: https://github.com/apache/kafka/pull/13114#discussion_r1120967385
########## metadata/src/main/java/org/apache/kafka/image/ScramImage.java: ########## @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kafka.image; + +import org.apache.kafka.image.writer.ImageWriter; +import org.apache.kafka.image.writer.ImageWriterOptions; +import org.apache.kafka.clients.admin.ScramMechanism; + +// import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +// import java.util.function.Consumer; +import java.util.stream.Collectors; + + +/** + * Represents the SCRAM credentials in the metadata image. + * + * This class is thread-safe. + */ +public final class ScramImage { + public static final ScramImage EMPTY = new ScramImage(Collections.emptyMap()); + + private final Map<ScramMechanism, Map<String, ScramCredentialData>> mechanisms; + + public ScramImage(Map<ScramMechanism, Map<String, ScramCredentialData>> mechanisms) { + this.mechanisms = Collections.unmodifiableMap(mechanisms); + } + + public void write(ImageWriter writer, ImageWriterOptions options) { Review Comment: You need to check the MetadataVersion and invoke `options.handleLoss` if it is too low. See my comment below. This feature will only be supported in `IBP_3_5_IV0` and newer. Also we'll need a test for this (that we throw an exception when required if SCRAM is present). That should be in `./metadata/src/test/java/org/apache/kafka/image/ScramImageTesst.java` (which still needs to be written) :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org