Skip to content

Commit

Permalink
fix: return error missing on open file
Browse files Browse the repository at this point in the history
  • Loading branch information
okysetiawan committed May 14, 2024
1 parent 9654669 commit 1f06ed5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/cmd/job/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ func (*planCommand) appendDirectory(directory string, directoryExists map[string
func (p *planCommand) saveFile(plans plan.Plans) error {
file, err := os.OpenFile(p.output, unix.O_RDWR|unix.O_CREAT, os.ModePerm)
if err != nil {
return err
}
defer file.Close()

Expand Down
4 changes: 1 addition & 3 deletions client/extension/provider/gitlab/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ func (api *API) GetFileContent(ctx context.Context, projectID any, ref, fileName
}

func NewAPI(baseURL, token string) (*API, error) {
var (
opts []gitlab.ClientOptionFunc
)
var opts []gitlab.ClientOptionFunc

if baseURL != "" {
opts = append(opts, gitlab.WithBaseURL(baseURL))
Expand Down
20 changes: 20 additions & 0 deletions validate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /bin/bash

PLAN_FILE_PATH=${1:-job.csv}
CONFIG_FILE=${2:-/Users/oky.setiawan/work/go/g-pilotdata-gl/optimus.yaml}

while IFS="," read -r kind project_name namespace_name kind_name operation executed
do
echo "{Kind: $kind, ProjectName: $project_name, NamespaceName: $namespace_name, KindName: $kind_name, Operation: $operation, Executed: $executed}"

if [ "$kind" != "job" ] || [ "$excuted" ]; then
continue
fi

if [ "$operation" == "delete" ]; then
go run main.go job validate -c="$CONFIG_FILE" -n="$namespace_name" -j="$kind_name" -s -d -v
else
go run main.go job validate -c="$CONFIG_FILE" -n="$namespace_name" -j="$kind_name" -v
fi

done < <(tail -n +2 "$PLAN_FILE_PATH")

0 comments on commit 1f06ed5

Please sign in to comment.