Skip to content

Commit c9d4180

Browse files
fix the track of options in PROJECT file
1 parent ade165e commit c9d4180

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

pkg/plugins/golang/deploy-image/v1alpha1/api.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,19 @@ func (p *createAPISubcommand) Scaffold(fs machinery.Filesystem) error {
211211
if err != nil && !errors.As(err, &config.PluginKeyNotFoundError{}) {
212212
return err
213213
}
214-
cfg.Resources = append(cfg.Resources, p.resource.GVK)
215-
// Track the options informed
216-
cfg.Image = p.image
217-
cfg.ContainerCommand = p.imageContainerCommand
218-
cfg.ContainerPort = p.imageContainerPort
214+
configDataOptions := options{
215+
Image: p.image,
216+
ContainerCommand: p.imageContainerCommand,
217+
ContainerPort: p.imageContainerPort,
218+
}
219+
cfg.Resources = append(cfg.Resources, resourceData{
220+
Group: p.resource.GVK.Group,
221+
Domain: p.resource.GVK.Domain,
222+
Version: p.resource.GVK.Version,
223+
Kind: p.resource.GVK.Kind,
224+
Options: configDataOptions,
225+
},
226+
)
219227
if err := p.config.EncodePluginConfig(pluginKey, cfg); err != nil {
220228
return err
221229
}

pkg/plugins/golang/deploy-image/v1alpha1/plugin.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package v1alpha1
1919
import (
2020
"sigs.k8s.io/kubebuilder/v3/pkg/config"
2121
cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
22-
"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
2322
"sigs.k8s.io/kubebuilder/v3/pkg/model/stage"
2423
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
2524
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
@@ -53,8 +52,18 @@ func (Plugin) SupportedProjectVersions() []config.Version { return supportedProj
5352
func (p Plugin) GetCreateAPISubcommand() plugin.CreateAPISubcommand { return &p.createAPISubcommand }
5453

5554
type pluginConfig struct {
56-
Resources []resource.GVK `json:"resources,omitempty"`
57-
// image indicates the image that will be used to scaffold the deployment
55+
Resources []resourceData `json:"resources,omitempty"`
56+
}
57+
58+
type resourceData struct {
59+
Group string `json:"group,omitempty"`
60+
Domain string `json:"domain,omitempty"`
61+
Version string `json:"version"`
62+
Kind string `json:"kind"`
63+
Options options `json:"options,omitempty"`
64+
}
65+
66+
type options struct {
5867
Image string `json:"image,omitempty"`
5968
ContainerCommand string `json:"containerCommand,omitempty"`
6069
ContainerPort string `json:"containerPort,omitempty"`

testdata/project-v3-with-deploy-image/PROJECT

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ layout:
33
- go.kubebuilder.io/v3
44
plugins:
55
deploy-image.go.kubebuilder.io/v1-alpha:
6-
containerCommand: memcached,-m=64,-o,modern,-v
7-
containerPort: "11211"
8-
image: memcached:1.4.36-alpine
96
resources:
107
- domain: testproject.org
118
group: example.com
129
kind: Memcached
10+
options:
11+
containerCommand: memcached,-m=64,-o,modern,-v
12+
containerPort: "11211"
13+
image: memcached:1.4.36-alpine
1314
version: v1alpha1
1415
projectName: project-v3-with-deploy-image
1516
repo: sigs.k8s.io/kubebuilder/testdata/project-v3-with-deploy-image

0 commit comments

Comments
 (0)