Skip to content

Commit

Permalink
🐛 Create intermediate path for resources stored as files. (#94)
Browse files Browse the repository at this point in the history
The java extension CR defines:
```
    resources:
    - fields:
      - key: maven.settings.path
        name: settings
        path: /shared/creds/maven/settings.xml
      selector: identity:kind=maven
```
`/shared` exists but `creds/maven` needs to be created on demand.

Reported by CI as:
```
 "errors": [
      {
        "severity": "Error",
        "description": "open /shared/creds/maven/settings.xml: no such file or directory"
      }
    ],
```

Signed-off-by: Jeff Ortel <jortel@redhat.com>
  • Loading branch information
jortel committed Jun 8, 2024
1 parent b63ff7d commit 7e66056
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import (
"errors"
"fmt"
"os"
pathlib "path"
"regexp"
"strings"

"github.com/konveyor/analyzer-lsp/provider"
"github.com/konveyor/tackle2-hub/api"
"github.com/konveyor/tackle2-hub/nas"
)

var (
Expand Down Expand Up @@ -180,6 +182,10 @@ func (r *ResourceInjector) add(resource *Resource, object any) (err error) {

// write a resource field value to a file.
func (r *ResourceInjector) write(path string, s string) (err error) {
err = nas.MkDir(pathlib.Dir(path), 0755)
if err != nil {
return
}
f, err := os.Create(path)
if err == nil {
_, err = f.Write([]byte(s))
Expand Down

0 comments on commit 7e66056

Please sign in to comment.