Skip to content

Problems on plugin initialization with disabled syncers #11

@gruberro

Description

@gruberro

First of all thank you very much for the plugin SDK. Developing custom syncers is really fun.

I experienced a problem with the SDK when starting the plugin container due to a possible incompatibility of types/config. When the plugin is started, it tries to unmarshal the vcluster options from json. As far as I can see, the json looks like {"controllers":["-services", "-ingresses"],"serverCaCert":"/data/se.... So the controllers data is an array (also if only one syncer is disabled by bypassing something like --sync=-services,-ingresses into the syncer configuration.

Unfortunately this results in

panic: unmarshal vcluster options: json: cannot unmarshal array into Go struct field VirtualClusterOptions.controllers of type string

goroutine 1 [running]:
github.com/loft-sh/vcluster-sdk/plugin.MustInit(...)
	/go/vcluster/vendor/github.com/loft-sh/vcluster-sdk/plugin/plugin.go:55
main.main()
	/go/vcluster/main.go:11 +0x2bd

It looks like this is currently incompatible with the VirtualClusterOptions struct, defining Controllers as string only (Controllers string json:"controllers,omitempty").

For me, the problem does not happen when using devspace to develop a new plugin, but in "prod mode". This might also indicate a wrong configuration on my side 🙈.

/edit I tried to dig into the error a bit deeper: the plugin SDK seems perfectly compatible with loftsh/vcluster:0.6.0-alpha.8. With alpha.9 the types start to differ. This might have to do something with these changes.

At least this is the reason why my development env is still working. I used the example plugin as base. But I recognized too late, that it's using alpha.6 😅.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions