Skip to content

Commit

Permalink
Merge pull request #57 from BuddhiWathsala/master
Browse files Browse the repository at this point in the history
Enable version controlling for SiddhiProcess CR objects
  • Loading branch information
pcnfernando committed Jul 22, 2019
2 parents 90a01ca + cb5f33d commit a4ebe1a
Show file tree
Hide file tree
Showing 7 changed files with 560 additions and 220 deletions.
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.

0 comments on commit a4ebe1a

Please sign in to comment.