Skip to content

Commit

Permalink
🐛 adding entrypoint to copy source from mount to container (#127)
Browse files Browse the repository at this point in the history
Signed-off-by: Shawn Hurley <[email protected]>
  • Loading branch information
shawn-hurley authored Nov 29, 2023
1 parent 888433a commit 61e6001
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ COPY --from=rulesets /rulesets/default/generated /opt/rulesets
COPY --from=rulesets /windup-rulesets/rules/rules-reviewed/openrewrite /opt/openrewrite
COPY --from=static-report /usr/bin/js-bundle-generator /usr/local/bin
COPY --from=static-report /usr/local/static-report /usr/local/static-report
COPY entrypoint.sh /usr/bin/entrypoint.sh

ENTRYPOINT ["kantra"]
21 changes: 13 additions & 8 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io/fs"
"os"
"path"
"runtime"

"path/filepath"
"sort"
Expand Down Expand Up @@ -463,15 +464,19 @@ func (a *analyzeCommand) getConfigVolumes() (map[string]string, error) {
vols := map[string]string{
tempDir: ConfigMountPath,
}

// attempt to create a .m2 directory we can use to speed things a bit
// this will be shared between analyze and dep command containers
m2Dir, err := os.MkdirTemp("", "m2-repo-")
if err != nil {
a.log.V(1).Error(err, "failed to create m2 repo", "dir", m2Dir)
} else {
vols[m2Dir] = M2Dir
a.log.V(1).Info("created directory for maven repo", "dir", m2Dir)
a.tempDirs = append(a.tempDirs, m2Dir)
// TODO: when this is fixed on mac and windows for podman machine volume access remove this check.
if runtime.GOOS == "linux" {
m2Dir, err := os.MkdirTemp("", "m2-repo-")
if err != nil {
a.log.V(1).Error(err, "failed to create m2 repo", "dir", m2Dir)
} else {
vols[m2Dir] = M2Dir
a.log.V(1).Info("created directory for maven repo", "dir", m2Dir)
a.tempDirs = append(a.tempDirs, m2Dir)
}
}

return vols, nil
Expand Down Expand Up @@ -638,7 +643,7 @@ func (a *analyzeCommand) RunAnalysis(ctx context.Context, xmlOutputDir string) e
WithStdout(analysisLog),
WithStderr(analysisLog),
WithEntrypointArgs(args...),
WithEntrypointBin("/usr/bin/konveyor-analyzer"),
WithEntrypointBin("/usr/bin/entrypoint.sh"),
WithCleanup(a.cleanup),
)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -x

cp -r /opt/input/source /tmp/source-code
sed -i 's|/opt/input/source|/tmp/source-code|g' /opt/input/config/settings.json
/usr/bin/konveyor-analyzer "$@"
sed -i 's|/tmp/source-code|/opt/input/source|g' /opt/input/config/settings.json
4 changes: 2 additions & 2 deletions test-data/analysis-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
- konveyor.io/target=cloud-readiness
- discovery
incidents:
- uri: file:///opt/input/source/target/classes/persistence.properties
- uri: file:///tmp/source-code/target/classes/persistence.properties
message: When migrating environments, hard-coded IP addresses may need to be modified or eliminated.
codeSnip: |2
1 jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
Expand All @@ -252,7 +252,7 @@
lineNumber: 2
variables:
matchingText: 169.60.225.216
- uri: file:///opt/input/source/src/main/resources/persistence.properties
- uri: file:///tmp/source-code/src/main/resources/persistence.properties
message: When migrating environments, hard-coded IP addresses may need to be modified or eliminated.
codeSnip: |2
1 jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
Expand Down

0 comments on commit 61e6001

Please sign in to comment.