Skip to content

Commit

Permalink
Merge branch 'main' into repo_mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoox committed Jan 13, 2025
2 parents e2af4e4 + efb85f5 commit 0e9f087
Show file tree
Hide file tree
Showing 135 changed files with 5,208 additions and 981 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -71,14 +70,10 @@ protected void configure(CentralDogmaBuilder builder) {

@Override
protected void configureClient(ArmeriaCentralDogmaBuilder builder) {
try {
final String accessToken = getAccessToken(
WebClient.of("http://127.0.0.1:" + dogma.serverAddress().getPort()),
TestAuthMessageUtil.USERNAME, TestAuthMessageUtil.PASSWORD);
builder.accessToken(accessToken);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
final String accessToken = getAccessToken(
WebClient.of("http://127.0.0.1:" + dogma.serverAddress().getPort()),
TestAuthMessageUtil.USERNAME, TestAuthMessageUtil.PASSWORD);
builder.accessToken(accessToken);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2025 LINE Corporation
*
* LINE Corporation 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:
*
* https://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 com.linecorp.centraldogma.common;

/**
* A {@link MirrorException} raised when failed to access to the remote repository for mirroring.
*/
public final class MirrorAccessException extends MirrorException {
private static final long serialVersionUID = 6673537965128335081L;

/**
* Creates a new instance.
*/
public MirrorAccessException(String message) {
super(message);
}

/**
* Creates a new instance.
*/
public MirrorAccessException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

package com.linecorp.centraldogma.internal.api.v1;

import static com.google.common.base.MoreObjects.firstNonNull;
import static java.util.Objects.requireNonNull;

import java.util.Objects;

import javax.annotation.Nullable;
Expand All @@ -28,28 +25,11 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;

@JsonInclude(Include.NON_NULL)
public final class MirrorDto {
public final class MirrorDto extends MirrorRequest {

private final String id;
private final boolean enabled;
private final String projectName;
@Nullable
private final String schedule;
private final String direction;
private final String localRepo;
private final String localPath;
private final String remoteScheme;
private final String remoteUrl;
private final String remotePath;
private final String remoteBranch;
@Nullable
private final String gitignore;
private final String credentialId;
@Nullable
private final String zone;
private final boolean allow;

@JsonCreator
public MirrorDto(@JsonProperty("id") String id,
Expand All @@ -65,94 +45,16 @@ public MirrorDto(@JsonProperty("id") String id,
@JsonProperty("remoteBranch") String remoteBranch,
@JsonProperty("gitignore") @Nullable String gitignore,
@JsonProperty("credentialId") String credentialId,
@JsonProperty("zone") @Nullable String zone) {
this.id = requireNonNull(id, "id");
this.enabled = firstNonNull(enabled, true);
this.projectName = requireNonNull(projectName, "projectName");
this.schedule = schedule;
this.direction = requireNonNull(direction, "direction");
this.localRepo = requireNonNull(localRepo, "localRepo");
this.localPath = requireNonNull(localPath, "localPath");
this.remoteScheme = requireNonNull(remoteScheme, "remoteScheme");
this.remoteUrl = requireNonNull(remoteUrl, "remoteUrl");
this.remotePath = requireNonNull(remotePath, "remotePath");
this.remoteBranch = requireNonNull(remoteBranch, "remoteBranch");
this.gitignore = gitignore;
this.credentialId = requireNonNull(credentialId, "credentialId");
this.zone = zone;
}

@JsonProperty("id")
public String id() {
return id;
}

@JsonProperty("enabled")
public boolean enabled() {
return enabled;
}

@JsonProperty("projectName")
public String projectName() {
return projectName;
}

@Nullable
@JsonProperty("schedule")
public String schedule() {
return schedule;
}

@JsonProperty("direction")
public String direction() {
return direction;
}

@JsonProperty("localRepo")
public String localRepo() {
return localRepo;
}

@JsonProperty("localPath")
public String localPath() {
return localPath;
}

@JsonProperty("remoteScheme")
public String remoteScheme() {
return remoteScheme;
}

@JsonProperty("remoteUrl")
public String remoteUrl() {
return remoteUrl;
}

@JsonProperty("remotePath")
public String remotePath() {
return remotePath;
}

@JsonProperty("remoteBranch")
public String remoteBranch() {
return remoteBranch;
}

@Nullable
@JsonProperty("gitignore")
public String gitignore() {
return gitignore;
}

@JsonProperty("credentialId")
public String credentialId() {
return credentialId;
@JsonProperty("zone") @Nullable String zone,
@JsonProperty("allow") boolean allow) {
super(id, enabled, projectName, schedule, direction, localRepo, localPath, remoteScheme, remoteUrl,
remotePath, remoteBranch, gitignore, credentialId, zone);
this.allow = allow;
}

@Nullable
@JsonProperty("zone")
public String zone() {
return zone;
@JsonProperty("allow")
public boolean allow() {
return allow;
}

@Override
Expand All @@ -164,45 +66,16 @@ public boolean equals(Object o) {
return false;
}
final MirrorDto mirrorDto = (MirrorDto) o;
return id.equals(mirrorDto.id) &&
enabled == mirrorDto.enabled &&
projectName.equals(mirrorDto.projectName) &&
Objects.equals(schedule, mirrorDto.schedule) &&
direction.equals(mirrorDto.direction) &&
localRepo.equals(mirrorDto.localRepo) &&
localPath.equals(mirrorDto.localPath) &&
remoteScheme.equals(mirrorDto.remoteScheme) &&
remoteUrl.equals(mirrorDto.remoteUrl) &&
remotePath.equals(mirrorDto.remotePath) &&
remoteBranch.equals(mirrorDto.remoteBranch) &&
Objects.equals(gitignore, mirrorDto.gitignore) &&
credentialId.equals(mirrorDto.credentialId) &&
Objects.equals(zone, mirrorDto.zone);
return super.equals(o) && allow == mirrorDto.allow;
}

@Override
public int hashCode() {
return Objects.hash(id, projectName, schedule, direction, localRepo, localPath, remoteScheme,
remoteUrl, remotePath, remoteBranch, gitignore, credentialId, enabled, zone);
return super.hashCode() * 31 + Objects.hash(allow);
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.omitNullValues()
.add("id", id)
.add("enabled", enabled)
.add("projectName", projectName)
.add("schedule", schedule)
.add("direction", direction)
.add("localRepo", localRepo)
.add("localPath", localPath)
.add("remoteScheme", remoteScheme)
.add("remoteUrl", remoteUrl)
.add("remotePath", remotePath)
.add("gitignore", gitignore)
.add("credentialId", credentialId)
.add("zone", zone)
.toString();
return toStringHelper().add("allow", allow).toString();
}
}
Loading

0 comments on commit 0e9f087

Please sign in to comment.