Skip to content

Commit

Permalink
concord-agent: allow skipping repository state (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
brig authored Feb 26, 2025
1 parent 5244577 commit a6c2df2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.walmartlabs.concord.repository.*;
import com.walmartlabs.concord.sdk.Secret;
import com.walmartlabs.concord.dependencymanager.DependencyManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import java.io.IOException;
Expand All @@ -37,6 +39,8 @@

public class RepositoryManager {

private static final Logger log = LoggerFactory.getLogger(RepositoryManager.class);

private final SecretClient secretClient;
private final RepositoryProviders providers;
private final RepositoryCache repositoryCache;
Expand Down Expand Up @@ -74,6 +78,11 @@ public RepositoryManager(SecretClient secretClient,
}

public void export(String repoUrl, String branch, String commitId, String repoPath, Path dest, SecretDefinition secretDefinition, List<String> ignorePatterns) throws ExecutionException {
if (gitCfg.isSkip()) {
log.info("Skipping git export, using local state");
return;
}

Secret secret = getSecret(secretDefinition);

Path cacheDir = repositoryCache.getPath(repoUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed 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.
Expand All @@ -38,6 +38,7 @@ public class GitConfiguration {
private final Duration httpLowSpeedTime;
private final Duration sshTimeout;
private final int sshTimeoutRetryCount;
private final boolean skip;

@Inject
public GitConfiguration(Config cfg) {
Expand All @@ -50,6 +51,7 @@ public GitConfiguration(Config cfg) {
this.httpLowSpeedTime = cfg.getDuration("git.httpLowSpeedTime");
this.sshTimeout = cfg.getDuration("git.sshTimeout");
this.sshTimeoutRetryCount = cfg.getInt("git.sshTimeoutRetryCount");
this.skip = cfg.getBoolean("git.skip");
}

public String getToken() {
Expand Down Expand Up @@ -87,4 +89,8 @@ public Duration getSshTimeout() {
public int getSshTimeoutRetryCount() {
return sshTimeoutRetryCount;
}

public boolean isSkip() {
return skip;
}
}
5 changes: 4 additions & 1 deletion agent/src/main/resources/concord-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ concord-agent {
docker {
host = "tcp://127.0.0.1:2375"
host = ${?DOCKER_HOST}

orphanSweeperEnabled = false
orphanSweeperPeriod = "15 minutes"

Expand Down Expand Up @@ -185,6 +185,9 @@ concord-agent {

# git clone config
git {
# if true, skip Git fetch, use workspace state only
skip = false

# GitHub auth token to use when cloning repositories without explicitly configured authentication
# oauth = "..."

Expand Down

0 comments on commit a6c2df2

Please sign in to comment.