Skip to content

Commit

Permalink
agent: allow disable git
Browse files Browse the repository at this point in the history
  • Loading branch information
brig committed Feb 24, 2025
1 parent e33c459 commit 1ec558d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 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.isEnabled()) {
log.info("Git disabled, 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 enabled;

@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.enabled = !cfg.hasPath("git.enabled") || cfg.getBoolean("git.enabled");
}

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

public boolean isEnabled() {
return enabled;
}
}

0 comments on commit 1ec558d

Please sign in to comment.