Skip to content

Commit a2d98fe

Browse files
committed
feat: support pluginconfig crd resources to use plugins
1 parent c50c5c4 commit a2d98fe

File tree

19 files changed

+325
-318
lines changed

19 files changed

+325
-318
lines changed

api/v1alpha1/groupversion_info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
// Package v1alpha1 contains API Schema definitions for the gateway.apisix.io v1alpha1 API group
1818
// +kubebuilder:object:generate=true
19-
// +groupName=gateway.apisix.io.github.com
19+
// +groupName=gateway.apisix.io
2020
package v1alpha1
2121

2222
import (
@@ -26,7 +26,7 @@ import (
2626

2727
var (
2828
// GroupVersion is group version used to register these objects
29-
GroupVersion = schema.GroupVersion{Group: "gateway.apisix.io.github.com", Version: "v1alpha1"}
29+
GroupVersion = schema.GroupVersion{Group: "gateway.apisix.io", Version: "v1alpha1"}
3030

3131
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
3232
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

api/v1alpha1/guestbook_types.go

Lines changed: 0 additions & 64 deletions
This file was deleted.

api/v1alpha1/pluginconfig_types.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package v1alpha1
2+
3+
import (
4+
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
)
7+
8+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
9+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
10+
11+
// PluginConfigSpec defines the desired state of PluginConfig
12+
type PluginConfigSpec struct {
13+
Plugins []Plugin `json:"plugins"`
14+
}
15+
16+
// +kubebuilder:object:root=true
17+
18+
// PluginConfig is the Schema for the PluginConfigs API
19+
type PluginConfig struct {
20+
metav1.TypeMeta `json:",inline"`
21+
metav1.ObjectMeta `json:"metadata,omitempty"`
22+
23+
Spec PluginConfigSpec `json:"spec,omitempty"`
24+
}
25+
26+
// +kubebuilder:object:root=true
27+
28+
// PluginConfigList contains a list of PluginConfig
29+
type PluginConfigList struct {
30+
metav1.TypeMeta `json:",inline"`
31+
metav1.ListMeta `json:"metadata,omitempty"`
32+
Items []PluginConfig `json:"items"`
33+
}
34+
35+
type Plugin struct {
36+
// The plugin name.
37+
Name string `json:"name" yaml:"name"`
38+
// Plugin configuration.
39+
Config apiextensionsv1.JSON `json:"config" yaml:"config"`
40+
}
41+
42+
func init() {
43+
SchemeBuilder.Register(&PluginConfig{}, &PluginConfigList{})
44+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 38 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/gateway.apisix.io.github.com_guestbooks.yaml renamed to config/crd/bases/gateway.apisix.io_pluginconfigs.yaml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ kind: CustomResourceDefinition
44
metadata:
55
annotations:
66
controller-gen.kubebuilder.io/version: v0.15.0
7-
name: guestbooks.gateway.apisix.io.github.com
7+
name: pluginconfigs.gateway.apisix.io
88
spec:
9-
group: gateway.apisix.io.github.com
9+
group: gateway.apisix.io
1010
names:
11-
kind: Guestbook
12-
listKind: GuestbookList
13-
plural: guestbooks
14-
singular: guestbook
11+
kind: PluginConfig
12+
listKind: PluginConfigList
13+
plural: pluginconfigs
14+
singular: pluginconfig
1515
scope: Namespaced
1616
versions:
1717
- name: v1alpha1
1818
schema:
1919
openAPIV3Schema:
20-
description: Guestbook is the Schema for the guestbooks API
20+
description: PluginConfig is the Schema for the PluginConfigs API
2121
properties:
2222
apiVersion:
2323
description: |-
@@ -37,18 +37,25 @@ spec:
3737
metadata:
3838
type: object
3939
spec:
40-
description: GuestbookSpec defines the desired state of Guestbook
40+
description: PluginConfigSpec defines the desired state of PluginConfig
4141
properties:
42-
foo:
43-
description: Foo is an example field of Guestbook. Edit guestbook_types.go
44-
to remove/update
45-
type: string
46-
type: object
47-
status:
48-
description: GuestbookStatus defines the observed state of Guestbook
42+
plugins:
43+
items:
44+
properties:
45+
config:
46+
description: Plugin configuration.
47+
x-kubernetes-preserve-unknown-fields: true
48+
name:
49+
description: The plugin name.
50+
type: string
51+
required:
52+
- config
53+
- name
54+
type: object
55+
type: array
56+
required:
57+
- plugins
4958
type: object
5059
type: object
5160
served: true
5261
storage: true
53-
subresources:
54-
status: {}

config/crd/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# since it depends on service name and namespace that are out of this kustomize package.
33
# It should be run by config/default
44
resources:
5-
- bases/gateway.apisix.io.github.com_guestbooks.yaml
5+
- bases/gateway.apisix.io_pluginconfigs.yaml
66
# +kubebuilder:scaffold:crdkustomizeresource
77

88
patches:

config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ kind: Kustomization
55
images:
66
- name: controller
77
newName: api7/api7-ingress-controller
8-
newTag: dev4
8+
newTag: dev

config/rbac/role.yaml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,13 @@ rules:
5656
- list
5757
- watch
5858
- apiGroups:
59-
- gateway.apisix.io.github.com
59+
- gateway.apisix.io
6060
resources:
61-
- guestbooks
61+
- pluginconfigs
6262
verbs:
63-
- create
64-
- delete
6563
- get
6664
- list
67-
- patch
68-
- update
6965
- watch
70-
- apiGroups:
71-
- gateway.apisix.io.github.com
72-
resources:
73-
- guestbooks/finalizers
74-
verbs:
75-
- update
76-
- apiGroups:
77-
- gateway.apisix.io.github.com
78-
resources:
79-
- guestbooks/status
80-
verbs:
81-
- get
82-
- patch
83-
- update
8466
- apiGroups:
8567
- gateway.networking.k8s.io
8668
resources:

0 commit comments

Comments
 (0)