Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@

import java.net.URI;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.linecorp.centraldogma.server.internal.credential.SshKeyCredential;
import com.linecorp.centraldogma.server.mirror.Mirror;
import com.linecorp.centraldogma.server.mirror.MirrorContext;
import com.linecorp.centraldogma.server.mirror.MirrorProvider;
import com.linecorp.centraldogma.server.mirror.RepositoryUri;

public final class GitMirrorProvider implements MirrorProvider {

private static final Logger logger = LoggerFactory.getLogger(GitMirrorProvider.class);

@Override
public Mirror newMirror(MirrorContext context) {
requireNonNull(context, "context");
Expand All @@ -44,6 +50,10 @@ public Mirror newMirror(MirrorContext context) {

switch (scheme) {
case SCHEME_GIT_SSH: {
if (!(context.credential() instanceof SshKeyCredential)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question) Could we validate the configuration correctness also when a mirror is created.?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

logger.debug("'{}': SSH mirror requires an SSH_KEY credential, " +
"but got: {}", context.id(), context.credential().type());
}
Comment thread
minwoox marked this conversation as resolved.
final RepositoryUri repositoryUri = RepositoryUri.parse(remoteUri, "git");
return new SshGitMirror(context.id(), context.enabled(), context.schedule(),
context.direction(), context.credential(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ final class SshGitMirror extends AbstractGitMirror {
super(id, enabled, schedule, direction, credential, localRepo, localPath,
remoteUri, gitignore, zone);
this.trustedHostKeys = requireNonNull(trustedHostKeys, "trustedHostKeys");
if (!(credential instanceof SshKeyCredential)) {
throw new MirrorException(
"SSH mirror requires an SSH_KEY credential, but got: " + credential.type());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ private CompletableFuture<List<Mirror>> handleAllMirrors(Map<String, Entry<?>> e
} catch (Exception e) {
// Skip a malformed mirror so that a single bad mirror does not
// prevent the rest of the mirrors from being loaded.
logger.debug("Failed to convert a mirror configuration to a mirror. " +
"project: {}, mirror: {}", parent().name(), mirrorConfig,
e);
logger.warn("Failed to convert a mirror configuration to a mirror. " +
"project: {}, mirror: {}", parent().name(), mirrorConfig,
e);
return null;
}
})
Expand Down
Loading