Skip to content

Commit

Permalink
Merge pull request #19 from stakater/update-operator-sdk
Browse files Browse the repository at this point in the history
Update operator sdk
  • Loading branch information
ahmedwaleedmalik authored Nov 25, 2020
2 parents 1ef6b4e + d3172b3 commit b21679b
Show file tree
Hide file tree
Showing 8 changed files with 457 additions and 627 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ bin
*.swp
*.swo
*~
.local
7 changes: 3 additions & 4 deletions api/v1alpha1/channel_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v1alpha1

import (
"github.com/operator-framework/operator-sdk/pkg/status"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -51,7 +50,7 @@ type ChannelStatus struct {
ID string `json:"id"`

// Status conditions
Conditions status.Conditions `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down Expand Up @@ -80,11 +79,11 @@ func init() {
}

// GetReconcileStatus - returns conditions, required for making Channel ConditionsStatusAware
func (channel *Channel) GetReconcileStatus() status.Conditions {
func (channel *Channel) GetReconcileStatus() []metav1.Condition {
return channel.Status.Conditions
}

// SetReconcileStatus - sets status, required for making Channel ConditionsStatusAware
func (channel *Channel) SetReconcileStatus(reconcileStatus status.Conditions) {
func (channel *Channel) SetReconcileStatus(reconcileStatus []metav1.Condition) {
channel.Status.Conditions = reconcileStatus
}
4 changes: 2 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

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

70 changes: 50 additions & 20 deletions config/crd/bases/slack.stakater.com_channels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,39 +63,69 @@ spec:
conditions:
description: Status conditions
items:
description: "Condition represents an observation of an object's state.
Conditions are an extension mechanism intended to be used when the
details of an observation are not a priori known or would not apply
to all instances of a given Kind. \n Conditions should be added
to explicitly convey properties that users and components care about
rather than requiring those properties to be inferred from other
observations. Once defined, the meaning of a Condition can not be
changed arbitrarily - it becomes part of the API, and has the same
backwards- and forwards-compatibility concerns of any other part
of the API."
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a foo's
current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type //
+patchStrategy=merge // +listType=map // +listMapKey=type
\ Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
\n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be when
the underlying condition changed. If that is not known, then
using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating details
about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: ConditionReason is intended to be a one-word, CamelCase
representation of the category of cause of the current status.
It is intended to be used in concise output, such as one-line
kubectl get output, and in summarizing occurrences of causes.
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers of
specific condition types may define expected values and meanings
for this field, and whether the values are considered a guaranteed
API. The value should be a CamelCase string. This field may
not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: "ConditionType is the type of the condition and is
typically a CamelCased word or short phrase. \n Condition types
should indicate state in the \"abnormal-true\" polarity. For
example, if the condition indicates when a policy is invalid,
the \"is valid\" case is probably the norm, so the condition
should be called \"Invalid\"."
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
Expand Down
21 changes: 10 additions & 11 deletions controllers/channel_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package controllers
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/operator-framework/operator-sdk/pkg/status"
slackv1alpha1 "github.com/stakater/slack-operator/api/v1alpha1"
"github.com/stakater/slack-operator/pkg/slack/mock"
slackMock "github.com/stakater/slack-operator/pkg/slack/mock"
Expand Down Expand Up @@ -31,15 +30,15 @@ var _ = Describe("ChannelController", func() {

Expect(channel.Status.ID).To(Equal(slackMock.PublicConversationID))
Expect(len(channel.Status.Conditions)).To(Equal(1))
Expect(channel.Status.Conditions[0].Reason).To(Equal(status.ConditionReason("Successful")))
Expect(channel.Status.Conditions[0].Reason).To(Equal("Successful"))
})

It("should set error condition if channel with same name already exists", func() {
_ = util.CreateChannel(mock.NameTakenConversationName, false, "", "", []string{mock.ExistingUserEmail}, ns)
channel := util.GetChannel(mock.NameTakenConversationName, ns)

Expect(len(channel.Status.Conditions)).To(Equal(1))
Expect(channel.Status.Conditions[0].Reason).To(Equal(status.ConditionReason("Failed")))
Expect(channel.Status.Conditions[0].Reason).To(Equal("Failed"))
Expect(channel.Status.Conditions[0].Message).To(Equal("name_taken"))
util.TryDeleteChannel(mock.NameTakenConversationName, ns)
})
Expand All @@ -52,7 +51,7 @@ var _ = Describe("ChannelController", func() {

Expect(channel.Status.ID).To(Equal(slackMock.PrivateConversationID))
Expect(len(channel.Status.Conditions)).To(Equal(1))
Expect(channel.Status.Conditions[0].Reason).To(Equal(status.ConditionReason("Successful")))
Expect(channel.Status.Conditions[0].Reason).To(Equal("Successful"))
})
})

Expand All @@ -65,7 +64,7 @@ var _ = Describe("ChannelController", func() {

Expect(channel.Spec.Description).To(Equal(description))
Expect(len(channel.Status.Conditions)).To(Equal(1))
Expect(channel.Status.Conditions[0].Reason).To(Equal(status.ConditionReason("Successful")))
Expect(channel.Status.Conditions[0].Reason).To(Equal("Successful"))
})
})

Expand All @@ -78,7 +77,7 @@ var _ = Describe("ChannelController", func() {

Expect(channel.Spec.Topic).To(Equal(topic))
Expect(len(channel.Status.Conditions)).To(Equal(1))
Expect(channel.Status.Conditions[0].Reason).To(Equal(status.ConditionReason("Successful")))
Expect(channel.Status.Conditions[0].Reason).To(Equal("Successful"))
})
})

Expand All @@ -89,7 +88,7 @@ var _ = Describe("ChannelController", func() {
channel := util.GetChannel(channelName, ns)

Expect(len(channel.Status.Conditions)).To(Equal(1))
Expect(channel.Status.Conditions[0].Reason).To(Equal(status.ConditionReason("Successful")))
Expect(channel.Status.Conditions[0].Reason).To(Equal("Successful"))
})

It("should set error condition when user does not exists", func() {
Expand All @@ -98,7 +97,7 @@ var _ = Describe("ChannelController", func() {
channel := util.GetChannel(channelName, ns)

Expect(len(channel.Status.Conditions)).To(Equal(1))
Expect(channel.Status.Conditions[0].Reason).To(Equal(status.ConditionReason("Failed")))
Expect(channel.Status.Conditions[0].Reason).To(Equal("Failed"))
Expect(channel.Status.Conditions[0].Message).To(Equal("users_not_found"))
})
})
Expand Down Expand Up @@ -129,7 +128,7 @@ var _ = Describe("ChannelController", func() {
Expect(updatedChannel.Spec.Name).To(Equal(newName))

Expect(len(channel.Status.Conditions)).To(Equal(1))
Expect(channel.Status.Conditions[0].Reason).To(Equal(status.ConditionReason("Successful")))
Expect(channel.Status.Conditions[0].Reason).To(Equal("Successful"))
})
})
})
Expand All @@ -142,7 +141,7 @@ var _ = Describe("ChannelController", func() {

Expect(channel.Status.ID).ToNot(BeEmpty())
Expect(len(channel.Status.Conditions)).To(Equal(1))
Expect(channel.Status.Conditions[0].Reason).To(Equal(status.ConditionReason("Successful")))
Expect(channel.Status.Conditions[0].Reason).To(Equal("Successful"))

util.DeleteChannel(channelName, ns)

Expand All @@ -159,7 +158,7 @@ var _ = Describe("ChannelController", func() {
channel := util.GetChannel(mock.NameTakenConversationName, ns)

Expect(len(channel.Status.Conditions)).To(Equal(1))
Expect(channel.Status.Conditions[0].Reason).To(Equal(status.ConditionReason("Failed")))
Expect(channel.Status.Conditions[0].Reason).To(Equal("Failed"))

util.DeleteChannel(mock.NameTakenConversationName, ns)

Expand Down
34 changes: 26 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,35 @@ module github.com/stakater/slack-operator
go 1.13

require (
github.com/go-logr/logr v0.1.0
cloud.google.com/go v0.72.0 // indirect
github.com/go-logr/logr v0.3.0
github.com/google/go-cmp v0.5.4 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/gnostic v0.5.3 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/onsi/ginkgo v1.14.0
github.com/onsi/gomega v1.10.1
github.com/operator-framework/operator-sdk v0.18.1
github.com/slack-go/slack v0.6.5
github.com/stakater/operator-utils v0.1.2
github.com/stretchr/testify v1.5.1
github.com/prometheus/client_golang v1.8.0 // indirect
github.com/prometheus/common v0.15.0 // indirect
github.com/slack-go/slack v0.7.2
github.com/stakater/operator-utils v0.1.7
github.com/stretchr/testify v1.6.1
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392 // indirect
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58 // indirect
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
gomodules.xyz/jsonpatch/v2 v2.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/yaml.v2 v2.3.0
k8s.io/apimachinery v0.18.8
k8s.io/apiextensions-apiserver v0.19.4 // indirect
k8s.io/apimachinery v0.19.4
k8s.io/client-go v12.0.0+incompatible
sigs.k8s.io/controller-runtime v0.6.2
k8s.io/klog/v2 v2.4.0 // indirect
k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd // indirect
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
sigs.k8s.io/controller-runtime v0.6.4
)

replace k8s.io/client-go => k8s.io/client-go v0.18.8
replace k8s.io/client-go => k8s.io/client-go v0.19.0
Loading

0 comments on commit b21679b

Please sign in to comment.