Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic generator doesn't work with all current services #78

Closed
atighineanu opened this issue Nov 14, 2020 · 2 comments · Fixed by #92
Closed

Basic generator doesn't work with all current services #78

atighineanu opened this issue Nov 14, 2020 · 2 comments · Fixed by #92

Comments

@atighineanu
Copy link
Contributor

atighineanu commented Nov 14, 2020

I was not able to generate a configuration from cli input.
First, -u or --url cannot be passed as a flag (as described in the docs, see #77)
Second, if I use generate -s (even with -p key=value), it prompts me into something difficult to follow.

user@localhost:~/go/src/github.com/atighineanu/shoutrrr> go run cli/main.go generate -s slack
Generating URL for slack using basic generator
Enter the configuration values as prompted

:                                                            <----(*)
: 
BotName: kured-bot
Token: T01EAU1DZ6K                     <-----(**)
panic: reflect: Elem of invalid type slack.Token

goroutine 1 [running]:
reflect.(*rtype).Elem(0x963460, 0x19, 0x199)
        /home/user/go/src/reflect/type.go:918 +0x1a5
github.com/containrrr/shoutrrr/pkg/generators/basic.(*Generator).Generate(0xd43360, 0xa50920, 0xc00000e920, 0xc000095fb0, 0xc00000e8a0, 0x0, 0x2, 0x0, 0x7, 0xc0000975a8, ...)
        /home/user/go/src/github.com/atighineanu/shoutrrr/pkg/generators/basic/basic.go:115 +0xa06
github.com/containrrr/shoutrrr/cli/cmd/generate.Run(0xd08ee0, 0xc00000e8a0, 0x0, 0x2)
        /home/user/go/src/github.com/atighineanu/shoutrrr/cli/cmd/generate/generate.go:106 +0x6d4
github.com/spf13/cobra.(*Command).execute(0xd08ee0, 0xc00000e880, 0x2, 0x2, 0xd08ee0, 0xc00000e880)
        /home/user/go/src/pkg/mod/github.com/spf13/[email protected]/command.go:842 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0xd09180, 0x0, 0x0, 0x0)
        /home/user/go/src/pkg/mod/github.com/spf13/[email protected]/command.go:943 +0x336
github.com/spf13/cobra.(*Command).Execute(...)
        /home/user/go/src/pkg/mod/github.com/spf13/[email protected]/command.go:883
main.main()
        /home/user/go/src/github.com/atighineanu/shoutrrr/cli/main.go:9 +0x31
exit status 2
    • first two fields of the slice fields from here:
      for _, field := range fields {
      are completely empty.
      I would assume they are supposed to be the property key:value couple but I am not entirely sure. More description in docs would be welcome.

** - second, after inputing token from CLI - I always receive the panic error. I've printed the t.Kind() to see what is it in reflect type.go, but it was nil. Tried to put a default and avoid the panic, but ended with (from here

_, _ = fmt.Fprint(color.Output, "Invalid format for field ", color.HiCyanString(field.Name), ": ", err.Error(), "\n\n")
) :

Invalid format for field Token: field format is not supported

And here I was lost because I have no idea of the package reflect. :)

@piksel
Copy link
Member

piksel commented Nov 15, 2020

Yeah, sorry about that. Generate was planned early on, but never actually fully implemented until recently. I figured that the defaults should work for the current services without tags, but I guess not.

I will go through them and "whitelist" the ones that work and/or fix the ones that don't.

I think the problem with slack is that the "basic" generator doesn't know how to handle structs (Token in this case).
The short-term solution for this would be to add a custom generator for slack, or come up with a way to enable services to deserialize structs in their configs.

@piksel piksel changed the title shoutrrr generate -s <service> input issues Basic generator doesn't work with all current services Nov 15, 2020
@piksel
Copy link
Member

piksel commented Dec 5, 2020

I've found the reason for the empty fields, they were the Composition structs that was supposed to be skipped (since setting them through the generator makes no sense). I have fixed the bug that had them show up on some services in a general generator/config TLC branch that I hope to get done soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants