From 1ec558dec5c121a1230be0adea498f9b2de36869 Mon Sep 17 00:00:00 2001 From: brig Date: Mon, 24 Feb 2025 15:17:22 -0500 Subject: [PATCH] agent: allow disable git --- .../walmartlabs/concord/agent/RepositoryManager.java | 9 +++++++++ .../concord/agent/cfg/GitConfiguration.java | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/RepositoryManager.java b/agent/src/main/java/com/walmartlabs/concord/agent/RepositoryManager.java index e500c41d2c..f25b52fe0f 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/RepositoryManager.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/RepositoryManager.java @@ -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; @@ -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; @@ -74,6 +78,11 @@ public RepositoryManager(SecretClient secretClient, } public void export(String repoUrl, String branch, String commitId, String repoPath, Path dest, SecretDefinition secretDefinition, List ignorePatterns) throws ExecutionException { + if (!gitCfg.isEnabled()) { + log.info("Git disabled, using local state"); + return; + } + Secret secret = getSecret(secretDefinition); Path cacheDir = repositoryCache.getPath(repoUrl); diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java index 95b5e21b5b..5a16dadb6a 100644 --- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java +++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java @@ -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. @@ -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) { @@ -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() { @@ -87,4 +89,8 @@ public Duration getSshTimeout() { public int getSshTimeoutRetryCount() { return sshTimeoutRetryCount; } + + public boolean isEnabled() { + return enabled; + } }