Given these structs:
type InitRequest struct {
ListenAddr string
ForceNewCluster bool
Spec Spec
}
type Spec struct {
Annotations
AcceptancePolicy AcceptancePolicy `json:",omitempty"`
//...
}
type AcceptancePolicy struct {
Policies []Policy `json:",omitempty"`
}
type Policy struct {
Role NodeRole
Autoaccept bool
Secret *string `json:",omitempty"`
}
This code doesn't compile, exiting on that line with missing type in composite literal. Followed Go, Golang : array type inside struct, missing type composite literal , but same error with:
swarm, err := cli.SwarmInit(context.Background(), swarm.InitRequest{
ListenAddr: "0.0.0.0:2377",
ForceNewCluster: true,
Spec: {
AcceptancePolicy: {
Policies: []Policy{
Policy: {
Role: "manager",
Autoaccept: true,
},
},
}, // here
},
})
Any hint will be very helpful, thanks!