Skip to content

Commit 93dae45

Browse files
authored
feat: support consumer controller (#76)
1 parent 8c4d0c1 commit 93dae45

18 files changed

+502
-130
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ help: ## Display this help.
6565

6666
.PHONY: manifests
6767
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
68-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
68+
$(CONTROLLER_GEN) rbac:roleName=api7-ingress-manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
6969

7070
.PHONY: generate
7171
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.

api/v1alpha1/consumer_types.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
// +kubebuilder:object:root=true
9+
// +kubebuilder:subresource:status
10+
type Consumer struct {
11+
metav1.TypeMeta `json:",inline"`
12+
metav1.ObjectMeta `json:"metadata,omitempty"`
13+
14+
Spec ConsumerSpec `json:"spec,omitempty"`
15+
Status Status `json:"status,omitempty"`
16+
}
17+
18+
type ConsumerSpec struct {
19+
GatewayRef GatewayRef `json:"gatewayRef,omitempty"`
20+
Credentials []CredentialSpec `json:"credentials,omitempty"`
21+
}
22+
23+
type GatewayRef struct {
24+
Name string `json:"name,omitempty"`
25+
Kind string `json:"kind,omitempty"`
26+
Group string `json:"group,omitempty"`
27+
Namespace *string `json:"namespace,omitempty"`
28+
}
29+
30+
// +kubebuilder:validation:XValidation:rule="has(self.config) != has(self.secretRef)"
31+
type CredentialSpec struct {
32+
// +kubebuilder:validation:Enum=jwt-auth;basic-auth;key-auth;hmac-auth;
33+
Type string `json:"type"`
34+
Config apiextensionsv1.JSON `json:"config,omitempty"`
35+
SecretRef *SecretReference `json:"secretRef,omitempty"`
36+
Name string `json:"name,omitempty"`
37+
}
38+
39+
type SecretReference struct {
40+
Name string `json:"name"`
41+
Namespace string `json:"namespace,omitempty"`
42+
}
43+
44+
type Status struct {
45+
Conditions []metav1.Condition `json:"conditions,omitempty"`
46+
}
47+
48+
// +kubebuilder:object:root=true
49+
type ConsumerList struct {
50+
metav1.TypeMeta `json:",inline"`
51+
metav1.ListMeta `json:"metadata,omitempty"`
52+
Items []Consumer `json:"items"`
53+
}
54+
55+
func init() {
56+
SchemeBuilder.Register(&Consumer{}, &ConsumerList{})
57+
}

api/v1alpha1/pluginconfig_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ import (
88
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
99
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
1010

11-
// PluginConfigSpec defines the desired state of PluginConfig
12-
type PluginConfigSpec struct {
13-
Plugins []Plugin `json:"plugins"`
14-
}
15-
1611
// +kubebuilder:object:root=true
1712

1813
// PluginConfig is the Schema for the PluginConfigs API
@@ -23,6 +18,11 @@ type PluginConfig struct {
2318
Spec PluginConfigSpec `json:"spec,omitempty"`
2419
}
2520

21+
// PluginConfigSpec defines the desired state of PluginConfig
22+
type PluginConfigSpec struct {
23+
Plugins []Plugin `json:"plugins"`
24+
}
25+
2626
// +kubebuilder:object:root=true
2727

2828
// PluginConfigList contains a list of PluginConfig

api/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)