Skip to content

Commit

Permalink
clean credentials in logging
Browse files Browse the repository at this point in the history
  • Loading branch information
code-crusher committed Oct 15, 2024
1 parent c86cc4a commit 071f4a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ spec:


### Gravity K8s Agent

1. Update the `example.env` file with the required variables.
```
GRAVITY_API_KEY=
Expand All @@ -78,7 +77,6 @@ GIT_BRANCHES_ALLOWED=main,staging
3. Deploy the application to Kubernetes using `kubectl apply -f deployment_subst.yaml`.
### Working
1. The agent syncs with the repository and checks if there are any new CI actions completed.
2. It then check the postgress database for the status of the deployment action (if completed previously, pending or failed)
3. Generates the Docker file, and then iterates through the cloud accounts, regions while tagging and pushin them into the repositories.
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const pool = new Pool({
database: process.env.POSTGRES_DB,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
port: 5432,
port: 6543,
});

// Replace getDbConnection function
Expand Down Expand Up @@ -97,7 +97,9 @@ const syncLogsToGravityViaWebsocket = async (runId: string, action: string, mess

const customExec = (runId: string, action: string, command: string, skipLogging: boolean = false): Promise<string> => {
return new Promise((resolve, reject) => {
console.log(`Executing command: ${command}`);

const cleanedCommand = command.replace(/(AWS_ACCESS_KEY_ID|AWS_SECRET_ACCESS_KEY|DOCKER_USERNAME)=[^\s]*/g, "$1=****");
console.log(`Executing command: ${cleanedCommand}`);
const process = spawn(command, [], { shell: true });

let output = '';
Expand Down Expand Up @@ -308,7 +310,7 @@ const syncGitRepo = async () => {

// build the docker image in sync with pushing the log output into array
const dockerBuildCommand = `${dockerBuildCli} ${process.env.ENV === "production" ? "bud --isolation chroot" : "build"} --platform=linux/amd64 -t ${owner}/${serviceName}:latest -f ${gitRepoPath}/Dockerfile ${gitRepoPath}`;
await customExec(deploymentRunId, "DOCKER_IMAGE_BUILD", dockerBuildCommand);
// await customExec(deploymentRunId, "DOCKER_IMAGE_BUILD", dockerBuildCommand);

console.log("dockerBuildCommand COMPLETED");

Expand Down

0 comments on commit 071f4a3

Please sign in to comment.