Skip to content

Commit

Permalink
Support SLS applying config to and remove from machine group (#92)
Browse files Browse the repository at this point in the history
* Add test case and example

Signed-off-by: Zheng Xi Zhou <zzxwill@gmail.com>

* update example name and content

Signed-off-by: Zheng Xi Zhou <zzxwill@gmail.com>
  • Loading branch information
zzxwill authored Jul 7, 2021
1 parent 8131deb commit bb9926f
Show file tree
Hide file tree
Showing 12 changed files with 972 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apis/sls/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ var (

// MachineGroupVersionKind is the group, version and kind of MachineGroup
MachineGroupVersionKind = GroupVersion.WithKind(MachineGroupKind)

// MachineGroupBindingKind is the kind of MachineGroupBinding
MachineGroupBindingKind = reflect.TypeOf(MachineGroupBinding{}).Name()

// MachineGroupBindingGroupKind is the group and kind of MachineGroupBinding
MachineGroupBindingGroupKind = schema.GroupKind{Group: GroupVersion.Group, Kind: MachineGroupBindingKind}.String()

// MachineGroupBindingGroupVersionKind is the group, version and kind of MachineGroupBinding
MachineGroupBindingGroupVersionKind = GroupVersion.WithKind(MachineGroupBindingKind)
)

func init() {
Expand All @@ -98,4 +107,5 @@ func init() {
SchemeBuilder.Register(&Logtail{}, &LogtailList{})
SchemeBuilder.Register(&LogstoreIndex{}, &LogstoreIndexList{})
SchemeBuilder.Register(&MachineGroup{}, &MachineGroupList{})
SchemeBuilder.Register(&MachineGroupBinding{}, &MachineGroupBindingList{})
}
79 changes: 79 additions & 0 deletions apis/sls/v1alpha1/machineGroupBinding_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
Copyright 2021 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// MachineGroupBindingSpec defines the desired state of SLS MachineGroupBinding
type MachineGroupBindingSpec struct {
xpv1.ResourceSpec `json:",inline"`

// ForProvider field is where use set parameters for SLS MachineGroupBinding
ForProvider MachineGroupBindingParameters `json:"forProvider"`
}

// MachineGroupBindingObservation is the representation of the current state that is observed.
type MachineGroupBindingObservation struct {
Configs []string `json:"configs"`
}

// MachineGroupBindingStatus defines the observed state of SLS MachineGroupBinding
type MachineGroupBindingStatus struct {
xpv1.ResourceStatus `json:",inline"`
AtProvider MachineGroupBindingObservation `json:"atProvider,omitempty"`
}

// MachineGroupBindingParameters define the desired state of an SLS store.
type MachineGroupBindingParameters struct {
// SLS project name
// +kubebuilder:validation:MinLength:=3
// +kubebuilder:validation:MaxLength:=63
ProjectName *string `json:"projectName"`

GroupName *string `json:"groupName"`

ConfigName *string `json:"configName"`
}

// +kubebuilder:object:root=true

// MachineGroupBinding is the Schema for the SLS MachineGroupBindings API
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,alibaba}
type MachineGroupBinding struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec MachineGroupBindingSpec `json:"spec"`
Status MachineGroupBindingStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// MachineGroupBindingList contains a list of MachineGroupBinding
type MachineGroupBindingList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MachineGroupBinding `json:"items"`
}
143 changes: 143 additions & 0 deletions apis/sls/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions apis/sls/v1alpha1/zz_generated.managed.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions apis/sls/v1alpha1/zz_generated.managedlist.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions examples/sls/machine-group-bingding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: sls.alibaba.crossplane.io/v1alpha1
kind: MachineGroupBinding
metadata:
name: sls-machine-group-binding
namespace: default
spec:
forProvider:
projectName: crossplane-poc
groupName: sls-machinegroup-test
configName: sls-logtail-test
writeConnectionSecretToRef:
name: machine-group-binding
namespace: default
Loading

0 comments on commit bb9926f

Please # to comment.