Skip to content

Commit

Permalink
Merge pull request #233 from 3scale-ops/feat/add-bugsnag-release-stage
Browse files Browse the repository at this point in the history
Feat/Add System/Zync optional bugsnag releaseStage
  • Loading branch information
3scale-robot authored Nov 29, 2022
2 parents 6098e04 + 931767f commit d6d08f3
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 0.17.1-alpha.11
VERSION ?= 0.17.1-alpha.12

# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
Expand Down Expand Up @@ -295,7 +295,7 @@ GOBINDATA ?= $(LOCALBIN)/go-bindata

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.9.2
CONTROLLER_TOOLS_VERSION ?= v0.10.0
GINKGO_VERSION ?= v2.1.4
CRD_REFDOCS_VERSION ?= v0.0.8
KIND_VERSION ?= v0.16.0
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ func InitializeExternalSecretSecretStoreReferenceSpec(spec *ExternalSecretSecret

// BugsnagSpec has configuration for Bugsnag integration
type BugsnagSpec struct {
// Release Stage to identify environment
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +optional
ReleaseStage *string `json:"releaseStage,omitempty"`
// API key
// +operator-sdk:csv:customresourcedefinitions:type=spec
APIKey SecretReference `json:"apiKey"`
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

18 changes: 13 additions & 5 deletions bundle/manifests/saas-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ metadata:
"key": "BUGSNAG_API_KEY",
"path": "secret/data/path/system-app"
}
}
},
"releaseStage": "staging"
},
"configFiles": {
"files": [
Expand Down Expand Up @@ -530,7 +531,8 @@ metadata:
"key": "BUGSNAG_API_KEY",
"path": "secret/data/path/zync"
}
}
},
"releaseStage": "development"
},
"databaseDSN": {
"fromVault": {
Expand Down Expand Up @@ -574,7 +576,7 @@ metadata:
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/3scale/saas-operator
support: Red Hat
name: saas-operator.v0.17.1-alpha.11
name: saas-operator.v0.17.1-alpha.12
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -2830,6 +2832,9 @@ spec:
- description: Override allows to directly specify a string value.
displayName: Override
path: config.bugsnag.apiKey.override
- description: Release Stage to identify environment
displayName: Release Stage
path: config.bugsnag.releaseStage
- description: Secret containging system configuration files to be mounted in
the pods
displayName: Config Files Secret
Expand Down Expand Up @@ -4131,6 +4136,9 @@ spec:
- description: Override allows to directly specify a string value.
displayName: Override
path: config.bugsnag.apiKey.override
- description: Release Stage to identify environment
displayName: Release Stage
path: config.bugsnag.releaseStage
- description: A reference to the secret holding the database DSN
displayName: Database DSN
path: config.databaseDSN
Expand Down Expand Up @@ -4393,7 +4401,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.annotations['olm.targetNamespaces']
image: quay.io/3scale/saas-operator:v0.17.1-alpha.11
image: quay.io/3scale/saas-operator:v0.17.1-alpha.12
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -4895,4 +4903,4 @@ spec:
provider:
name: Red Hat
url: https://www.3scale.net/
version: 0.17.1-alpha.11
version: 0.17.1-alpha.12
3 changes: 3 additions & 0 deletions bundle/manifests/saas.3scale.net_systems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ spec:
value.
type: string
type: object
releaseStage:
description: Release Stage to identify environment
type: string
required:
- apiKey
type: object
Expand Down
3 changes: 3 additions & 0 deletions bundle/manifests/saas.3scale.net_zyncs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ spec:
value.
type: string
type: object
releaseStage:
description: Release Stage to identify environment
type: string
required:
- apiKey
type: object
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/saas.3scale.net_systems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,9 @@ spec:
value.
type: string
type: object
releaseStage:
description: Release Stage to identify environment
type: string
required:
- apiKey
type: object
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/saas.3scale.net_zyncs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ spec:
value.
type: string
type: object
releaseStage:
description: Release Stage to identify environment
type: string
required:
- apiKey
type: object
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ kind: Kustomization
images:
- name: controller
newName: quay.io/3scale/saas-operator
newTag: v0.17.1-alpha.11
newTag: v0.17.1-alpha.12
Original file line number Diff line number Diff line change
Expand Up @@ -2403,6 +2403,9 @@ spec:
- description: Override allows to directly specify a string value.
displayName: Override
path: config.bugsnag.apiKey.override
- description: Release Stage to identify environment
displayName: Release Stage
path: config.bugsnag.releaseStage
- description: Secret containging system configuration files to be mounted in
the pods
displayName: Config Files Secret
Expand Down Expand Up @@ -3704,6 +3707,9 @@ spec:
- description: Override allows to directly specify a string value.
displayName: Override
path: config.bugsnag.apiKey.override
- description: Release Stage to identify environment
displayName: Release Stage
path: config.bugsnag.releaseStage
- description: A reference to the secret holding the database DSN
displayName: Database DSN
path: config.databaseDSN
Expand Down
1 change: 1 addition & 0 deletions config/samples/saas_v1alpha1_system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ spec:
key: RH_CUSTOMER_PORTAL_CLIENT_SECRET
realm: "sso.example.net"
bugsnag:
releaseStage: staging
apiKey:
fromVault:
path: secret/data/path/system-app
Expand Down
1 change: 1 addition & 0 deletions config/samples/saas_v1alpha1_zync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ spec:
path: secret/data/path/zync
key: SECRET_KEY_BASE
bugsnag:
releaseStage: development
apiKey:
fromVault:
path: secret/data/path/zync
Expand Down
3 changes: 2 additions & 1 deletion controllers/system_controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ var _ = Describe("System controller", func() {
Realm: pointer.StringPtr("sso.example.net"),
},
Bugsnag: &saasv1alpha1.BugsnagSpec{
APIKey: saasv1alpha1.SecretReference{Override: pointer.StringPtr("override")},
ReleaseStage: pointer.StringPtr("staging"),
APIKey: saasv1alpha1.SecretReference{Override: pointer.StringPtr("override")},
},
DatabaseSecret: saasv1alpha1.SecretReference{Override: pointer.StringPtr("override")},
MemcachedServers: "value",
Expand Down
1 change: 1 addition & 0 deletions controllers/zync_controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var _ = Describe("Zync controller", func() {
},
},
Bugsnag: &saasv1alpha1.BugsnagSpec{
ReleaseStage: pointer.StringPtr("staging"),
APIKey: saasv1alpha1.SecretReference{
FromVault: &saasv1alpha1.VaultSecretReference{
Path: "some-path-bugsnag",
Expand Down
1 change: 1 addition & 0 deletions docs/api-reference/reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ BugsnagSpec has configuration for Bugsnag integration
[cols="25a,75a", options="header"]
|===
| Field | Description
| *`releaseStage`* __string__ | Release Stage to identify environment
| *`apiKey`* __xref:{anchor_prefix}-github-com-3scale-saas-operator-api-v1alpha1-secretreference[$$SecretReference$$]__ | API key
|===

Expand Down
6 changes: 6 additions & 0 deletions pkg/generators/system/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type Options struct {
RedHatCustomerPortalClientSecret pod.EnvVarValue `env:"RH_CUSTOMER_PORTAL_CLIENT_SECRET" secret:"system-app"`
RedHatCustomerPortalRealm pod.EnvVarValue `env:"RH_CUSTOMER_PORTAL_REALM"`
BugsnagAPIKey pod.EnvVarValue `env:"BUGSNAG_API_KEY" secret:"system-app"`
BugsnagReleaseStage pod.EnvVarValue `env:"BUGSNAG_RELEASE_STAGE"`
DatabaseSecret pod.EnvVarValue `env:"DB_SECRET" secret:"system-app"`
}

Expand Down Expand Up @@ -146,6 +147,11 @@ func NewOptions(spec saasv1alpha1.SystemSpec) Options {

if spec.Config.Bugsnag.Enabled() {
opts.BugsnagAPIKey = &pod.SecretValue{Value: spec.Config.Bugsnag.APIKey}

if spec.Config.Bugsnag.ReleaseStage != nil {
opts.BugsnagReleaseStage = &pod.ClearTextValue{Value: *spec.Config.Bugsnag.ReleaseStage}
}

} else {
opts.BugsnagAPIKey = &pod.SecretValue{Value: saasv1alpha1.SecretReference{Override: pointer.StringPtr("")}}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/generators/zync/config/api_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type APIOptions struct {
SecretKeyBase pod.EnvVarValue `env:"SECRET_KEY_BASE" secret:"zync"`
ZyncAuthenticationToken pod.EnvVarValue `env:"ZYNC_AUTHENTICATION_TOKEN" secret:"zync"`
BugsnagAPIKey pod.EnvVarValue `env:"BUGSNAG_API_KEY" secret:"zync"`
BugsnagReleaseStage pod.EnvVarValue `env:"BUGSNAG_RELEASE_STAGE"`
}

// NewAPIOptions returns an Options struct for the given saasv1alpha1.ZyncSpec
Expand All @@ -35,6 +36,11 @@ func NewAPIOptions(spec saasv1alpha1.ZyncSpec) APIOptions {

if spec.Config.Bugsnag.Enabled() {
opts.BugsnagAPIKey = &pod.SecretValue{Value: spec.Config.Bugsnag.APIKey}

if spec.Config.Bugsnag.ReleaseStage != nil {
opts.BugsnagReleaseStage = &pod.ClearTextValue{Value: *spec.Config.Bugsnag.ReleaseStage}
}

} else {
opts.BugsnagAPIKey = &pod.SecretValue{Value: saasv1alpha1.SecretReference{Override: pointer.StringPtr("")}}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/generators/zync/config/que_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type QueOptions struct {
SecretKeyBase pod.EnvVarValue `env:"SECRET_KEY_BASE" secret:"zync"`
ZyncAuthenticationToken pod.EnvVarValue `env:"ZYNC_AUTHENTICATION_TOKEN" secret:"zync"`
BugsnagAPIKey pod.EnvVarValue `env:"BUGSNAG_API_KEY" secret:"zync"`
BugsnagReleaseStage pod.EnvVarValue `env:"BUGSNAG_RELEASE_STAGE"`
}

// NewQueOptions returns an Options struct for the given saasv1alpha1.ZyncSpec
Expand All @@ -31,6 +32,11 @@ func NewQueOptions(spec saasv1alpha1.ZyncSpec) QueOptions {

if spec.Config.Bugsnag.Enabled() {
opts.BugsnagAPIKey = &pod.SecretValue{Value: spec.Config.Bugsnag.APIKey}

if spec.Config.Bugsnag.ReleaseStage != nil {
opts.BugsnagReleaseStage = &pod.ClearTextValue{Value: *spec.Config.Bugsnag.ReleaseStage}
}

} else {
opts.BugsnagAPIKey = &pod.SecretValue{Value: saasv1alpha1.SecretReference{Override: pointer.StringPtr("")}}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package version

const (
version string = "v0.17.1-alpha.11"
version string = "v0.17.1-alpha.12"
)

// Current returns the current marin3r operator version
Expand Down

0 comments on commit d6d08f3

Please sign in to comment.