Skip to content

Commit

Permalink
Remove plaintext secret option (#73)
Browse files Browse the repository at this point in the history
* changes from upstream

* admin user pass will be random string

* code-dev

* update CRD and CSV

* remove from MongoDBSPec
  • Loading branch information
kgcarr authored Mar 26, 2020
1 parent ec4df92 commit b5c7deb
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 32 deletions.
7 changes: 0 additions & 7 deletions deploy/crds/operator.ibm.com_mongodbs_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,10 @@ spec:
tag:
type: string
type: object
mongoDBPass:
type: string
mongoDBUser:
type: string
replicas:
type: integer
storageClass:
type: string
required:
- mongoDBPass
- mongoDBUser
type: object
status:
description: MongoDBStatus defines the observed state of MongoDB
Expand Down
2 changes: 0 additions & 2 deletions deploy/crds/operator.ibm.com_v1alpha1_mongodb_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ spec:
tag: 4.0.12-build.3
metricsImage:
tag: 3.4.0
mongoDBUser: ChangeMeAdmin
mongoDBPass: ChangeMePass
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ metadata:
"metricsImage": {
"tag": "3.4.0"
},
"mongoDBPass": "ChangeMePass",
"mongoDBUser": "ChangeMeAdmin",
"replicas": 3
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,10 @@ spec:
tag:
type: string
type: object
mongoDBPass:
type: string
mongoDBUser:
type: string
replicas:
type: integer
storageClass:
type: string
required:
- mongoDBPass
- mongoDBUser
type: object
status:
description: MongoDBStatus defines the observed state of MongoDB
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/operator/v1alpha1/mongodb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ type MongoDBSpec struct {
ImageRegistry string `json:"imageRegistry,omitempty"`
Replicas int `json:"replicas,omitempty"`
StorageClass string `json:"storageClass,omitempty"`
MongoDBUser string `json:"mongoDBUser"`
MongoDBPass string `json:"mongoDBPass"`
InitImage Image `json:"initImage,omitempty"`
BootstrapImage Image `json:"bootstrapImage,omitempty"`
MetricsImage Image `json:"metricsImage,omitempty"`
Expand Down
16 changes: 4 additions & 12 deletions pkg/controller/mongodb/mongodb_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,11 @@ func (r *ReconcileMongoDB) Reconcile(request reconcile.Request) (reconcile.Resul
return reconcile.Result{}, err
}

// Create admin user and password as random string
// TODO: allow user to give a Secret
var pass, user string
if instance.Spec.MongoDBPass == "" {
pass = createRandomAlphaNumeric(13)
} else {
pass = instance.Spec.MongoDBPass
}

if instance.Spec.MongoDBUser == "" {
user = createRandomAlphaNumeric(8)
} else {
user = instance.Spec.MongoDBUser
}

user = createRandomAlphaNumeric(8)
pass = createRandomAlphaNumeric(13)
mongodbAdmin := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down

0 comments on commit b5c7deb

Please sign in to comment.