feat: recipe generate: load category and features #137

Manually merged
coop-cloud merged 0 commits from catalogue-metadata into main 2021-11-22 18:34:05 +00:00
Owner

This (jankily) loads metadata from recipe README files to populate the category and features sections.

Parsing status is not implemented yet, because I want to clean up how the scores are represented in the READMEs themselves first.

This runs fine on several recipes.

@roxxers any tips on making the code less repetitive and more elegant? I have no real idea what I'm doing here :P

One problem is that I'm having trouble authenticating with Docker Hub to fetch manifests, for recipes that have tags:

DEBU[0007] fetching tag digest from: 'https://index.docker.io/v2/thomseddon/traefik-forward-auth/manifests/2'  caller="/home/user/Projects/Autonomic/CoopCloud/abra/pkg/client/registry.go:82 GetTagDigest"
FATA[0009] unexpected end of JSON input                  caller="/home/user/Projects/Autonomic/CoopCloud/abra/cli/catalogue/generate.go:171 glob..func1" stack="/home/user/Projects/Autonomic/CoopCloud/abra/cli/catalogue/generate.go:171 glob..func1\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:163      (*Command).Run\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:434          (*App).RunAsSubcommand\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:278      (*Command).startApp\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:94       (*Command).Run\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:313          (*App).RunContext\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224          RunApp\n/home/user/Projects/Autonomic/CoopCloud/abra/cli/cli.go:107                RunApp\n/home/user/Projects/Autonomic/CoopCloud/abra/cmd/abra/main.go:23           main\n/usr/lib/golang/src/runtime/proc.go:225                                 main\n/usr/lib/golang/src/runtime/asm_amd64.s:1371                            goexit"
This (jankily) loads metadata from recipe README files to populate the `category` and `features` sections. Parsing `status` is not implemented yet, because I want to clean up how the scores are represented in the READMEs themselves first. This runs fine on several recipes. @roxxers any tips on making the code less repetitive and more elegant? I have no real idea what I'm doing here :P One problem is that I'm having trouble authenticating with Docker Hub to fetch manifests, for recipes that have tags: ``` DEBU[0007] fetching tag digest from: 'https://index.docker.io/v2/thomseddon/traefik-forward-auth/manifests/2' caller="/home/user/Projects/Autonomic/CoopCloud/abra/pkg/client/registry.go:82 GetTagDigest" FATA[0009] unexpected end of JSON input caller="/home/user/Projects/Autonomic/CoopCloud/abra/cli/catalogue/generate.go:171 glob..func1" stack="/home/user/Projects/Autonomic/CoopCloud/abra/cli/catalogue/generate.go:171 glob..func1\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:163 (*Command).Run\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:434 (*App).RunAsSubcommand\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:278 (*Command).startApp\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:94 (*Command).Run\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:313 (*App).RunContext\n/home/user/.go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224 RunApp\n/home/user/Projects/Autonomic/CoopCloud/abra/cli/cli.go:107 RunApp\n/home/user/Projects/Autonomic/CoopCloud/abra/cmd/abra/main.go:23 main\n/usr/lib/golang/src/runtime/proc.go:225 main\n/usr/lib/golang/src/runtime/asm_amd64.s:1371 goexit" ```
3wordchant force-pushed catalogue-metadata from 04c6e4a30a to e0fefd9fc6 2021-11-22 14:20:37 +00:00 Compare
decentral1se reviewed 2021-11-22 15:20:55 +00:00
decentral1se left a comment
Owner

🔥 G R E A T 🔥

🔥 G R E A T 🔥
@ -133,1 +133,4 @@
isClean, err := gitPkg.IsClean(rm.Name)
if err != nil {
return
Owner

logrus.Fatal(err)

`logrus.Fatal(err)`
3wordchant marked this conversation as resolved
@ -162,6 +171,8 @@ A new catalogue copy can be published to the recipes repository by passing the
logrus.Fatal(err)
}
features, category, err := catalogue.GetRecipeFeaturesAndCategory(recipeMeta.Name)
Owner

missing if err != nil ... dance for this err?

missing `if err != nil ...` dance for this `err`?
3wordchant marked this conversation as resolved
@ -374,6 +375,116 @@ func ReadReposMetadata() (RepoCatalogue, error) {
return reposMeta, nil
}
func GetStringInBetween(str string, start string, end string) (result string) {
Owner

can do str, start, end string as they're all type string

also you can make the return (result string, err error) and then if you have success do return str..., nil or if you have a failure do return str/"", fmt.Errorf(...) where it doesn't matter what str is because err != nil on the caller side.

can do `str, start, end string` as they're all type `string` also you can make the return `(result string, err error)` and then if you have success do `return str..., nil` or if you have a failure do `return str/"", fmt.Errorf(...)` where it doesn't matter what `str` is because `err != nil` on the caller side.
3wordchant marked this conversation as resolved
@ -377,0 +399,4 @@
}
if len(imgFields) < 3 {
logrus.Warnf("Image string has incorrect format: %s", imageRowString)
Owner

fyi most logging is all lowercase in the codebase for some reason idk

fyi most logging is all lowercase in the codebase for some reason idk
First-time contributor

This is go formattings work. all logs should start with lowercase. I mean its a style thing and I don't know why it wants that but might as well keep the style going. Plus I personally think it looks nice.

This is go formattings work. all logs should start with lowercase. I mean its a style thing and I don't know why it wants that but might as well keep the style going. Plus I personally think it looks nice.
3wordchant marked this conversation as resolved
Author
Owner

Thanks @decentral1se @roxxers! Made those changes, anything else?

Thanks @decentral1se @roxxers! Made those changes, anything else?
3wordchant changed title from WIP: feat: recipe generate: load category and features to feat: recipe generate: load category and features 2021-11-22 18:31:24 +00:00
3wordchant force-pushed catalogue-metadata from e602c70bea to 711c4e5ee8 2021-11-22 18:34:04 +00:00 Compare
coop-cloud manually merged commit 711c4e5ee8 into main 2021-11-22 18:34:05 +00:00
Sign in to join this conversation.
No description provided.