Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable version controlling for SiddhiProcess CR objects #57

Merged
merged 4 commits into from Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 66 additions & 0 deletions pkg/apis/siddhi/v1alpha2/siddhiprocess_functions.go
Expand Up @@ -20,6 +20,9 @@ package v1alpha2

import (
"sort"
"reflect"

corev1 "k8s.io/api/core/v1"
)

// Equals function of PV check the equality of two PV structs
Expand Down Expand Up @@ -57,6 +60,69 @@ func (p *MessagingSystem) Equals(q *MessagingSystem) bool {
return (typeEq && cidEq)
}

// Equals
func (p *SiddhiProcessSpec) Equals(q *SiddhiProcessSpec) bool {
if !EqualApps(p.Apps, q.Apps) {
return false
}
if p.SiddhiConfig != q.SiddhiConfig {
return false
}
if !EqualContainers(&p.Container, &q.Container){
return false
}
if !p.MessagingSystem.Equals(&q.MessagingSystem) {
return false
}
if !p.PV.Equals(&q.PV) {
return false
}
if p.ImagePullSecret != q.ImagePullSecret {
return false
}
return true
}

// EqualApps
func EqualApps(p []Apps, q []Apps) bool {
if len(p) != len(q) {
return false
}
for _, pApp := range p {
contained := false
for _, qApp := range q {
if reflect.DeepEqual(pApp, qApp) {
contained = true
break
}
}
if !contained {
return false
}
}
return true
}

// EqualContainers
func EqualContainers(p *corev1.Container, q *corev1.Container) bool {
if p.Image != q.Image {
return false
}
for _, pEnv := range p.Env {
contained := false
for _, qEnv := range q.Env {
if reflect.DeepEqual(pEnv, qEnv) {
contained = true
break
}
}
if !contained {
return false
}
}
return true
}

// EmptyConfig function of MessagingSystem check the equality of two MessagingSystem structs
func (p *MessagingSystem) EmptyConfig() bool {
if p.Config.ClusterID != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/siddhi/v1alpha2/siddhiprocess_types.go
Expand Up @@ -85,9 +85,9 @@ type SiddhiProcessSpec struct {
// SiddhiProcessStatus defines the observed state of SiddhiProcess
// +k8s:openapi-gen=true
type SiddhiProcessStatus struct {
Nodes []string `json:"nodes"`
Status string `json:"status"`
Ready string `json:"ready"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
7 changes: 1 addition & 6 deletions pkg/apis/siddhi/v1alpha2/zz_generated.deepcopy.go

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