From dc0b1f042a99b5a4abc04e69e850f483ca139557 Mon Sep 17 00:00:00 2001 From: Lucas TESSON Date: Sat, 1 Jun 2024 14:56:35 +0200 Subject: [PATCH] fix: improve error messages and file operations --- action.yaml | 2 +- cmd/ctfd-setup/main.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yaml b/action.yaml index 59e7e59..41d44cc 100644 --- a/action.yaml +++ b/action.yaml @@ -145,7 +145,7 @@ inputs: runs: using: 'docker' - image: 'docker://ctferio/ctfd-setup:v1.1.7' + image: 'docker://ctferio/ctfd-setup:v1.1.8' env: FILE: ${{ inputs.file }} URL: ${{ inputs.url }} diff --git a/cmd/ctfd-setup/main.go b/cmd/ctfd-setup/main.go index 05cb26b..5924bcc 100644 --- a/cmd/ctfd-setup/main.go +++ b/cmd/ctfd-setup/main.go @@ -578,7 +578,7 @@ func run(ctx *cli.Context) error { fd, err := os.Open(f) if err != nil { - return errors.Wrapf(err, "opening file %s", f) + return errors.Wrapf(err, "opening configuration file %s", f) } defer fd.Close() @@ -610,13 +610,13 @@ func intPtr(ctx *cli.Context, key string) *int { } func filePtr(ctx *cli.Context, key string) (*ctfdsetup.File, error) { - if !ctx.IsSet(key) { + fp := ctx.String(key) + if fp == "" { return &ctfdsetup.File{}, nil } - fp := ctx.String(key) content, err := os.ReadFile(fp) if err != nil { - return nil, err + return nil, errors.Wrapf(err, "failed to open file %s", fp) } return &ctfdsetup.File{ Name: filepath.Base(fp),