Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions config/crd/bases/atlas.mongodb.com_atlasprojects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ spec:
type: object
channelName:
type: string
enabled:
type: boolean
flowName:
type: string
licenseKeyRef:
Expand All @@ -106,8 +108,26 @@ spec:
required:
- name
type: object
microsoftTeamsWebhookUrl:
type: string
name:
type: string
orgName:
type: string
passwordRef:
description: ResourceRefNamespaced is a reference to a Kubernetes
Resource that allows to configure the namespace
properties:
name:
description: Name is the name of the Kubernetes Resource
type: string
namespace:
description: Namespace is the namespace of the Kubernetes
Resource
type: string
required:
- name
type: object
readTokenRef:
description: ResourceRefNamespaced is a reference to a Kubernetes
Resource that allows to configure the namespace
Expand Down Expand Up @@ -138,7 +158,9 @@ spec:
required:
- name
type: object
secret:
scheme:
type: string
secretRef:
description: ResourceRefNamespaced is a reference to a Kubernetes
Resource that allows to configure the namespace
properties:
Expand All @@ -152,6 +174,8 @@ spec:
required:
- name
type: object
serviceDiscovery:
type: string
serviceKeyRef:
description: ResourceRefNamespaced is a reference to a Kubernetes
Resource that allows to configure the namespace
Expand Down Expand Up @@ -181,9 +205,12 @@ spec:
- FLOWDOCK
- WEBHOOK
- MICROSOFT_TEAMS
- PROMETHEUS
type: string
url:
type: string
username:
type: string
writeTokenRef:
description: ResourceRefNamespaced is a reference to a Kubernetes
Resource that allows to configure the namespace
Expand Down Expand Up @@ -306,7 +333,7 @@ spec:
status:
description: AtlasProjectStatus defines the observed state of AtlasProject
properties:
AuthModes:
authModes:
description: AuthModes contains a list of configured authentication
modes "SCRAM" is default authentication method and requires a password
for each user "X509" signifies that self-managed X.509 authentication
Expand Down Expand Up @@ -432,6 +459,15 @@ spec:
- region
type: object
type: array
prometheus:
description: Prometheus contains the status for Prometheus integration
including the prometheusDiscoveryURL
properties:
prometheusDiscoveryURL:
type: string
scheme:
type: string
type: object
required:
- conditions
type: object
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/pborman/uuid v1.2.1
github.com/sethvargo/go-password v0.2.0
github.com/stretchr/testify v1.7.0
go.mongodb.org/atlas v0.15.0
go.mongodb.org/atlas v0.16.0
go.mongodb.org/mongo-driver v1.8.3
go.uber.org/zap v1.21.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/aws/aws-sdk-go v1.44.15 h1:z02BVeV6k7hZMfWEQmKh3X23s3F9PBHFCcIVfNlut7A=
github.com/aws/aws-sdk-go v1.44.15/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
github.com/aws/aws-sdk-go v1.43.23 h1:/YmZzPMK6Xzi0B/W9O/Pq7nyIXpBv6mTiJdDDFC7u94=
github.com/aws/aws-sdk-go v1.43.23/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down Expand Up @@ -577,8 +579,8 @@ go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lL
go.etcd.io/etcd/pkg/v3 v3.5.0/go.mod h1:UzJGatBQ1lXChBkQF0AuAtkRQMYnHubxAEYIrC3MSsE=
go.etcd.io/etcd/raft/v3 v3.5.0/go.mod h1:UFOHSIvO/nKwd4lhkwabrTD3cqW5yVyYYf/KlD00Szc=
go.etcd.io/etcd/server/v3 v3.5.0/go.mod h1:3Ah5ruV+M+7RZr0+Y/5mNLwC+eQlni+mQmOVdCRJoS4=
go.mongodb.org/atlas v0.15.0 h1:YyOBdBIuI//krRITf4r7PSirJ3YDNNUfNmapxwSyDow=
go.mongodb.org/atlas v0.15.0/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8=
go.mongodb.org/atlas v0.16.0 h1:IqnDuK3XAZUgJ5lPHc4v4z4B8F6mvsS37O4ck7tOYVc=
go.mongodb.org/atlas v0.16.0/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8=
go.mongodb.org/mongo-driver v1.8.3 h1:TDKlTkGDKm9kkJVUOAXDK5/fkqKHJVwYQSpoRfB43R4=
go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down
85 changes: 65 additions & 20 deletions pkg/api/v1/project/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

type Integration struct {
// Third Party Integration type such as Slack, New Relic, etc
// +kubebuilder:validation:Enum=PAGER_DUTY;SLACK;DATADOG;NEW_RELIC;OPS_GENIE;VICTOR_OPS;FLOWDOCK;WEBHOOK;MICROSOFT_TEAMS
// +kubebuilder:validation:Enum=PAGER_DUTY;SLACK;DATADOG;NEW_RELIC;OPS_GENIE;VICTOR_OPS;FLOWDOCK;WEBHOOK;MICROSOFT_TEAMS;PROMETHEUS
// +optional
Type string `json:"type,omitempty"`
// +optional
Expand Down Expand Up @@ -43,29 +43,74 @@ type Integration struct {
URL string `json:"url,omitempty"`
// +optional
SecretRef common.ResourceRefNamespaced `json:"secretRef,omitempty"`
// +optional
Name string `json:"name,omitempty"`
// +optional
MicrosoftTeamsWebhookURL string `json:"microsoftTeamsWebhookUrl,omitempty"`
// +optional
UserName string `json:"username,omitempty"`
// +optional
PasswordRef common.ResourceRefNamespaced `json:"passwordRef,omitempty"`
// +optional
ServiceDiscovery string `json:"serviceDiscovery,omitempty"`
// +optional
Scheme string `json:"scheme,omitempty"`
// +optional
Enabled bool `json:"enabled,omitempty"`
}

func (i Integration) ToAtlas(defaultNS string, c client.Client) *mongodbatlas.ThirdPartyIntegration {
result := mongodbatlas.ThirdPartyIntegration{}
result.Type = i.Type
result.LicenseKey, _ = i.LicenseKeyRef.ReadPassword(c, defaultNS)
result.AccountID = i.AccountID
result.WriteToken, _ = i.WriteTokenRef.ReadPassword(c, defaultNS)
result.ReadToken, _ = i.ReadTokenRef.ReadPassword(c, defaultNS)
result.APIKey, _ = i.APIKeyRef.ReadPassword(c, defaultNS)
result.Region = i.Region
result.ServiceKey, _ = i.ServiceKeyRef.ReadPassword(c, defaultNS)
result.APIToken, _ = i.APITokenRef.ReadPassword(c, defaultNS)
result.TeamName = i.TeamName
result.ChannelName = i.ChannelName
result.RoutingKey, _ = i.RoutingKeyRef.ReadPassword(c, defaultNS)
result.FlowName = i.FlowName
result.OrgName = i.OrgName
result.URL = i.URL
result.Secret, _ = i.SecretRef.ReadPassword(c, defaultNS)
return &result
func (i Integration) ToAtlas(c client.Client, defaultNS string) (result *mongodbatlas.ThirdPartyIntegration, err error) {
result = &mongodbatlas.ThirdPartyIntegration{
Type: i.Type,
AccountID: i.AccountID,
Region: i.Region,
TeamName: i.TeamName,
ChannelName: i.ChannelName,
FlowName: i.FlowName,
OrgName: i.OrgName,
URL: i.URL,
Name: i.Name,
MicrosoftTeamsWebhookURL: i.MicrosoftTeamsWebhookURL,
UserName: i.UserName,
ServiceDiscovery: i.ServiceDiscovery,
Scheme: i.Scheme,
Enabled: i.Enabled,
}

readPassword := func(passwordField common.ResourceRefNamespaced, target *string, errors *[]error) {
if passwordField.Name == "" {
return
}

*target, err = passwordField.ReadPassword(c, defaultNS)
storeError(err, errors)
}

errorList := make([]error, 0)
readPassword(i.LicenseKeyRef, &result.LicenseKey, &errorList)
readPassword(i.WriteTokenRef, &result.WriteToken, &errorList)
readPassword(i.ReadTokenRef, &result.ReadToken, &errorList)
readPassword(i.APIKeyRef, &result.APIKey, &errorList)
readPassword(i.ServiceKeyRef, &result.ServiceKey, &errorList)
readPassword(i.APITokenRef, &result.APIToken, &errorList)
readPassword(i.RoutingKeyRef, &result.RoutingKey, &errorList)
readPassword(i.SecretRef, &result.Secret, &errorList)
readPassword(i.PasswordRef, &result.Password, &errorList)

if len(errorList) != 0 {
firstError := (errorList)[0]
return nil, firstError
}

return result, nil
}

func (i Integration) Identifier() interface{} {
return i.Type
}

func storeError(err error, errors *[]error) {
if err != nil {
*errors = append(*errors, err)
}
}
7 changes: 6 additions & 1 deletion pkg/api/v1/status/atlasproject.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,10 @@ type AtlasProjectStatus struct {
// AuthModes contains a list of configured authentication modes
// "SCRAM" is default authentication method and requires a password for each user
// "X509" signifies that self-managed X.509 authentication is configured
AuthModes authmode.AuthModes `json:"AuthModes,omitempty"`
AuthModes authmode.AuthModes `json:"authModes,omitempty"`

// Prometheus contains the status for Prometheus integration
// including the prometheusDiscoveryURL
// +optional
Prometheus Prometheus `json:"prometheus,omitempty"`
}
8 changes: 8 additions & 0 deletions pkg/api/v1/status/prometheus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package status

type Prometheus struct {
// +optional
Scheme string `json:"scheme,omitempty"`
// +optional
DiscoveryURL string `json:"prometheusDiscoveryURL,omitempty"`
}
17 changes: 16 additions & 1 deletion pkg/api/v1/status/zz_generated.deepcopy.go

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

1 change: 0 additions & 1 deletion pkg/api/v1/zz_generated.deepcopy.go

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

Loading