Skip to content

Commit

Permalink
feat: added ability to externalise path
Browse files Browse the repository at this point in the history
  • Loading branch information
JayGhiya committed Mar 25, 2024
1 parent 00dfe65 commit accf3d3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions image-action-gh/base-project/image-scan/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"os"
"path/filepath"

dockerimageprocessing "github.com/unoplat/unoplat-ci-cd-scripts/code/image-scan/dockerimageprocessing"
"github.com/unoplat/unoplat-ci-cd-scripts/code/image-scan/utils"
Expand All @@ -11,8 +12,14 @@ import (
func main() {

valueFileName := os.Getenv("HELM_VALUES_FILE_PATH")

jsonFilePath := os.Getenv("DOCKER_IMAGES_JSON_PATH")
logger, _ := zap.NewProduction()

if jsonFilePath == "" {
logger.Error("DOCKER_IMAGES_JSON_PATH environment variable is not set")
return
}

data, err := utils.ReadFile(valueFileName)
if err != nil {
logger.Error("Error reading YAML file::", zap.Error(err))
Expand All @@ -31,9 +38,10 @@ func main() {
return
}

//
fileName := "docker_images.json"
if err := utils.WriteFile(fileName, jsonData); err != nil {
fullPath := filepath.Join(jsonFilePath, fileName)

if err := utils.WriteFile(fullPath, jsonData); err != nil {
logger.Error("Error writing to json", zap.Error(err))
return
}
Expand Down

0 comments on commit accf3d3

Please sign in to comment.