Skip to content

Commit

Permalink
Merge branch 'main' into feat/better-error-log-for-identity-role-mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop authored Oct 25, 2024
2 parents bca890d + 26d307d commit 311c819
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/playbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func parsePlaybookArgs(ctx context.Context, args []string) (*models.Playbook, *p
}

if f, err := os.Open(paramFile); err == nil {
if err := yamlutil.NewYAMLOrJSONDecoder(f, 1024).Decode(&params); err != nil {
if err := yamlutil.NewYAMLOrJSONDecoder(f, 1024).Decode(&params.Params); err != nil {
return nil, nil, err
}
}
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ require (
github.com/containrrr/shoutrrr v0.8.0
github.com/fergusstrange/embedded-postgres v1.25.0 // indirect
github.com/flanksource/commons v1.31.2
github.com/flanksource/duty v1.0.724
github.com/flanksource/gomplate/v3 v3.24.38
github.com/flanksource/duty v1.0.731
github.com/flanksource/gomplate/v3 v3.24.39
github.com/flanksource/kopper v1.0.10
github.com/gomarkdown/markdown v0.0.0-20240419095408-642f0ee99ae2
github.com/google/cel-go v0.21.0
Expand Down Expand Up @@ -129,7 +129,7 @@ require (
github.com/exaring/otelpgx v0.6.2 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/flanksource/is-healthy v1.0.34 // indirect
github.com/flanksource/is-healthy v1.0.35 // indirect
github.com/flanksource/kommons v0.31.4 // indirect
github.com/flanksource/kubectl-neat v1.0.4 // indirect
github.com/fluxcd/gitkit v0.6.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -877,14 +877,14 @@ github.com/flanksource/artifacts v1.0.14 h1:Vv70bccsae0MwGaf/uSPp34J5V1/PyKfct9z
github.com/flanksource/artifacts v1.0.14/go.mod h1:qHVCnQu5k50aWNJ5UhpcAKEl7pAzqUrFFKGSm147G70=
github.com/flanksource/commons v1.31.2 h1:VBhmhmvk6PjhJYuaK8LL+7700E3zPCY03VV/K1BxH64=
github.com/flanksource/commons v1.31.2/go.mod h1:X2txnbNGY6fKQuKLmc7x92FMYjB2MuaqNJOR6vEWDMs=
github.com/flanksource/duty v1.0.724 h1:vHD2n/y5zh8kmOtOx0HDgnVqAN1KehH528Rjfs3/NSQ=
github.com/flanksource/duty v1.0.724/go.mod h1:kIfncz/CfAYbiTaSOy8U2OLikTOb5vIjZu3YPzMJpwQ=
github.com/flanksource/duty v1.0.731 h1:aV3BicPMi2uK/Q7ZKBTakNKIv2uC+9EWQ/F1WOcazr4=
github.com/flanksource/duty v1.0.731/go.mod h1:sZY2NytdenrkqXoMD6Gn2C8xH6dm5HsqOeE0p74Z2VE=
github.com/flanksource/gomplate/v3 v3.20.4/go.mod h1:27BNWhzzSjDed1z8YShO6W+z6G9oZXuxfNFGd/iGSdc=
github.com/flanksource/gomplate/v3 v3.24.38 h1:Fe1RhKfRi2N6pFvSl5VhH5DOLBxKYus+TVWB4uma87Q=
github.com/flanksource/gomplate/v3 v3.24.38/go.mod h1:u5g/jNouGVdJgJbACkzMxgdcCMk19uolcW5TDclvFC0=
github.com/flanksource/gomplate/v3 v3.24.39 h1:O763lnNIcTELSMYeIO0dNDfcb3LoZvzU1fr62I4Yxqg=
github.com/flanksource/gomplate/v3 v3.24.39/go.mod h1:0wY/+UPvd7CxmiTBNmzZdWIEOUZAsRkpGY1j5R711O8=
github.com/flanksource/is-healthy v0.0.0-20230705092916-3b4cf510c5fc/go.mod h1:4pQhmF+TnVqJroQKY8wSnSp+T18oLson6YQ2M0qPHfQ=
github.com/flanksource/is-healthy v1.0.34 h1:7jMnhqNlZIpzA4PzgeZ2mabk5slraTq5ksjItf7QmPs=
github.com/flanksource/is-healthy v1.0.34/go.mod h1:eRPXZShZqaz3Mz+QeoCNbL3857lt9BgCt67jOUQXLOU=
github.com/flanksource/is-healthy v1.0.35 h1:hP6pVrc/lzDbTlms0aTIh0TcriCdQb9r+mivn45Bh30=
github.com/flanksource/is-healthy v1.0.35/go.mod h1:eRPXZShZqaz3Mz+QeoCNbL3857lt9BgCt67jOUQXLOU=
github.com/flanksource/kommons v0.31.4 h1:zksAgYjZuwPgS8XTejDIWEYB0nPSU1i3Jxcavm/vovI=
github.com/flanksource/kommons v0.31.4/go.mod h1:70BPMzjTvejsqRyVyAm/ZCeZ176toCvauaZjU03svnE=
github.com/flanksource/kopper v1.0.10 h1:we6rnFj6sT7T9PH6+V0m7vJ6ywPqiq8Bx7iFofB78v4=
Expand Down
19 changes: 16 additions & 3 deletions playbook/playbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"strings"

"github.com/flanksource/commons/collections"
"github.com/flanksource/commons/logger"
Expand Down Expand Up @@ -67,9 +68,21 @@ func CreateOrSaveFromFile(ctx context.Context, file string) (*models.Playbook, e
return nil, err
}

err = yamlutil.Unmarshal(manifest, &spec)
if err != nil {
return nil, err
// We can get multiple yamls, we choose first non empty, else throw an error
allManifests := strings.Split(string(manifest), "---")
for _, m := range allManifests {
err = yamlutil.Unmarshal([]byte(m), &spec)
if err != nil {
return nil, err
}

if spec.Name == "" {
logger.Infof("[Skipping] Got empty name for spec %s", m)
continue
}
}
if spec.Name == "" {
return nil, fmt.Errorf("Error no name in spec %v", spec)
}

return db.SavePlaybook(ctx, &spec)
Expand Down

0 comments on commit 311c819

Please sign in to comment.