Skip to content

Commit

Permalink
feat(jira): adding jira target
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie committed May 29, 2024
1 parent 461633c commit 6d3358d
Show file tree
Hide file tree
Showing 51 changed files with 4,034 additions and 30 deletions.
11 changes: 11 additions & 0 deletions cmd/jiratarget-adapter/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
pkgadapter "knative.dev/eventing/pkg/adapter/v2"

"github.com/zeiss/typhoon/pkg/targets/adapter/jiratarget"
)

func main() {
pkgadapter.Main("jiratarget", jiratarget.EnvAccessorCtor, jiratarget.NewTarget)
}
11 changes: 11 additions & 0 deletions cmd/servicenowtarget-adapter/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
pkgadapter "knative.dev/eventing/pkg/adapter/v2"

"github.com/zeiss/typhoon/pkg/targets/adapter/servicenowtarget"
)

func main() {
pkgadapter.Main("servicenowtarget", servicenowtarget.EnvAccessorCtor, servicenowtarget.NewTarget)
}
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22.1
require (
github.com/Shopify/sarama v1.30.0
github.com/ZachtimusPrime/Go-Splunk-HTTP/splunk/v2 v2.0.2
github.com/andygrunwald/go-jira v1.16.0
github.com/basgys/goxml2json v1.1.0
github.com/cloudevents/sdk-go/v2 v2.15.2
github.com/fsnotify/fsnotify v1.7.0
Expand Down Expand Up @@ -61,7 +62,6 @@ require (
require (
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
4d63.com/gochecknoglobals v0.2.1 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect
contrib.go.opencensus.io/exporter/zipkin v0.1.2 // indirect
Expand Down Expand Up @@ -120,6 +120,7 @@ require (
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/firefart/nonamedreturns v1.0.5 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
Expand Down Expand Up @@ -163,6 +164,7 @@ require (
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-containerregistry v0.13.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gordonklaus/ineffassign v0.1.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
Expand Down Expand Up @@ -301,6 +303,7 @@ require (
github.com/timonwong/loggercheck v0.9.4 // indirect
github.com/tomarrell/wrapcheck/v2 v2.8.3 // indirect
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
github.com/trivago/tgo v1.0.7 // indirect
github.com/ultraware/funlen v0.1.0 // indirect
github.com/ultraware/whitespace v0.1.1 // indirect
github.com/uudashr/gocognit v1.1.2 // indirect
Expand Down
13 changes: 11 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvf
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc=
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
Expand Down Expand Up @@ -133,6 +131,8 @@ github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQ
github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/andygrunwald/go-jira v1.16.0 h1:PU7C7Fkk5L96JvPc6vDVIrd99vdPnYudHu4ju2c2ikQ=
github.com/andygrunwald/go-jira v1.16.0/go.mod h1:UQH4IBVxIYWbgagc0LF/k9FRs9xjIiQ8hIcC6HfLwFU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210826220005-b48c857c3a0e/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20211221011931-643d94fcab96 h1:2P/dm3KbCLnRHQN/Ma50elhMx1Si9loEZe5hOrsuvuE=
Expand Down Expand Up @@ -308,6 +308,8 @@ github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
Expand Down Expand Up @@ -439,6 +441,7 @@ github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zV
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
Expand Down Expand Up @@ -540,6 +543,8 @@ github.com/google/go-containerregistry v0.13.0 h1:y1C7Z3e149OJbOPDBxLYR8ITPz8dTK
github.com/google/go-containerregistry v0.13.0/go.mod h1:J9FQ+eSS4a1aC2GNZxvNpbWhgp0487v+cgiilB4FqDo=
github.com/google/go-github/v27 v27.0.6/go.mod h1:/0Gr8pJ55COkmv+S/yPKCczSkUPIM/LnFyubufRNIS0=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
Expand Down Expand Up @@ -1173,6 +1178,8 @@ github.com/tomarrell/wrapcheck/v2 v2.8.3 h1:5ov+Cbhlgi7s/a42BprYoxsr73CbdMUTzE3b
github.com/tomarrell/wrapcheck/v2 v2.8.3/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo=
github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw=
github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw=
github.com/trivago/tgo v1.0.7 h1:uaWH/XIy9aWYWpjm2CU3RpcqZXmX2ysQ9/Go+d9gyrM=
github.com/trivago/tgo v1.0.7/go.mod h1:w4dpD+3tzNIIiIfkWWa85w5/B77tlvdZckQ+6PkFnhc=
github.com/tsenart/go-tsz v0.0.0-20180814232043-cdeb9e1e981e/go.mod h1:SWZznP1z5Ki7hDT2ioqiFKEse8K9tU2OUvaRI0NeGQo=
github.com/tsenart/vegeta/v12 v12.8.4/go.mod h1:ZiJtwLn/9M4fTPdMY7bdbIeyNeFVE8/AHbWFqCsUuho=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
Expand Down Expand Up @@ -1545,6 +1552,7 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -1564,6 +1572,7 @@ golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down
10 changes: 6 additions & 4 deletions pkg/apis/sources/v1alpha1/salesforce_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type SalesforceSourceSpec struct {
// Authentication method to interact with the Salesforce API.
Auth SalesforceAuth `json:"auth"`

// InstanceURL of the Salesforce instance.
InstanceURL string `json:"instanceURL"`

// APIVersion at Salesforce.
// +optional
APIVersion *string `json:"apiVersion"`
Expand All @@ -55,10 +58,9 @@ type SalesforceSubscription struct {

// SalesforceAuth contains Salesforce credentials.
type SalesforceAuth struct {
ClientID string `json:"clientID"`
Server string `json:"server"`
User string `json:"user"`
CertKey v1alpha1.ValueFromField `json:"certKey"`
ClientID string `json:"clientID"`
ClientSecret string `json:"clientSecret"`
TokenURL string `json:"tokenURL"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions pkg/apis/targets/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ var (
Group: GroupName,
Resource: "salesforcetargets",
}
// JiraTargetResource respresents an event target for Jira.
JiraTargetResource = schema.GroupResource{
Group: GroupName,
Resource: "jiratargets",
}
)
83 changes: 83 additions & 0 deletions pkg/apis/targets/v1alpha1/jira_lifecycle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package v1alpha1

import (
"context"
"strings"

"k8s.io/apimachinery/pkg/runtime/schema"

"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"

"github.com/zeiss/typhoon/pkg/apis/common/v1alpha1"
)

// Managed event types
const (
EventTypeJiraIssueCreate = "com.zeiss.typhoon.jira.issue.create"
EventTypeJiraIssueGet = "com.zeiss.typhoon.jira.issue.get"
EventTypeJiraCustom = "com.zeiss.typhoon.jira.custom"

EventTypeJiraIssue = "com.zeiss.typhoon.jira.issue"
EventTypeJiraCustomResponse = "com.zeiss.typhoon.jira.custom.response"
)

// GetGroupVersionKind implements kmeta.OwnerRefable.
func (*JiraTarget) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("JiraTarget")
}

// GetConditionSet implements duckv1.KRShaped.
func (*JiraTarget) GetConditionSet() apis.ConditionSet {
return v1alpha1.DefaultConditionSet
}

// GetStatus implements duckv1.KRShaped.
func (t *JiraTarget) GetStatus() *duckv1.Status {
return &t.Status.Status
}

// GetStatusManager implements Reconcilable.
func (t *JiraTarget) GetStatusManager() *v1alpha1.StatusManager {
return &v1alpha1.StatusManager{
ConditionSet: t.GetConditionSet(),
Status: &t.Status,
}
}

// AcceptedEventTypes implements IntegrationTarget.
func (*JiraTarget) AcceptedEventTypes() []string {
return []string{
EventTypeJiraIssueCreate,
EventTypeJiraIssueGet,
EventTypeJiraCustom,
}
}

// GetEventTypes implements EventSource.
func (*JiraTarget) GetEventTypes() []string {
return []string{
EventTypeJiraIssue,
EventTypeJiraCustomResponse,
}
}

// AsEventSource implements EventSource.
func (t *JiraTarget) AsEventSource() string {
kind := strings.ToLower(t.GetGroupVersionKind().Kind)
return "com.zeiss.typhoon." + kind + "." + t.Namespace + "." + t.Name
}

// GetAdapterOverrides implements AdapterConfigurable.
func (t *JiraTarget) GetAdapterOverrides() *v1alpha1.AdapterOverrides {
return t.Spec.AdapterOverrides
}

// SetDefaults implements apis.Defaultable
func (t *JiraTarget) SetDefaults(ctx context.Context) {
}

// Validate implements apis.Validatable
func (t *JiraTarget) Validate(ctx context.Context) *apis.FieldError {
return nil
}
57 changes: 57 additions & 0 deletions pkg/apis/targets/v1alpha1/jira_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/zeiss/typhoon/pkg/apis/common/v1alpha1"
)

// +genclient
// +genreconciler
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// JiraTarget is the Schema for the Jira Target.
type JiraTarget struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec JiraTargetSpec `json:"spec"`
Status v1alpha1.Status `json:"status,omitempty"`
}

// Check the interfaces the event target should be implementing.
var (
_ v1alpha1.Reconcilable = (*JiraTarget)(nil)
_ v1alpha1.AdapterConfigurable = (*JiraTarget)(nil)
_ v1alpha1.EventSource = (*JiraTarget)(nil)
)

// JiraTargetSpec defines the desired state of the event target.
type JiraTargetSpec struct {
// Authentication to interact with the JIRA REST API.
Auth JiraAuth `json:"auth"`

// URL for Jira service.
URL string `json:"url"`

// Adapter spec overrides parameters.
// +optional
AdapterOverrides *v1alpha1.AdapterOverrides `json:"adapterOverrides,omitempty"`
}

// JiraAuth contains Jira credentials.
type JiraAuth struct {
// Jira username to connect to the instance as.
User string `json:"user"`
// Jira API token bound to the user.
Token SecretValueFromSource `json:"token"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// JiraTargetList is a list of event target instances.
type JiraTargetList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []JiraTarget `json:"items"`
}
49 changes: 49 additions & 0 deletions pkg/apis/targets/v1alpha1/snow_lifecycle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package v1alpha1

import (
"context"

"k8s.io/apimachinery/pkg/runtime/schema"

"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"

"github.com/zeiss/typhoon/pkg/apis/common/v1alpha1"
)

// GetGroupVersionKind implements kmeta.OwnerRefable.
func (*ServiceNowTarget) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("ServiceNowTarget")
}

// GetConditionSet implements duckv1.KRShaped.
func (*ServiceNowTarget) GetConditionSet() apis.ConditionSet {
return v1alpha1.DefaultConditionSet
}

// GetStatus implements duckv1.KRShaped.
func (t *ServiceNowTarget) GetStatus() *duckv1.Status {
return &t.Status.Status
}

// GetStatusManager implements Reconcilable.
func (t *ServiceNowTarget) GetStatusManager() *v1alpha1.StatusManager {
return &v1alpha1.StatusManager{
ConditionSet: t.GetConditionSet(),
Status: &t.Status,
}
}

// GetAdapterOverrides implements AdapterConfigurable.
func (t *ServiceNowTarget) GetAdapterOverrides() *v1alpha1.AdapterOverrides {
return t.Spec.AdapterOverrides
}

// SetDefaults implements apis.Defaultable
func (t *ServiceNowTarget) SetDefaults(ctx context.Context) {
}

// Validate implements apis.Validatable
func (t *ServiceNowTarget) Validate(ctx context.Context) *apis.FieldError {
return nil
}
Loading

0 comments on commit 6d3358d

Please sign in to comment.