Skip to content

Commit

Permalink
Merge pull request #86 from ciaranRoche/csv-fix
Browse files Browse the repository at this point in the history
Fix CSV Formatting & Add Product Name to Util Function
  • Loading branch information
openshift-merge-robot committed Jan 17, 2020
2 parents 31c13db + 95f0fc8 commit 9ebc8a9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ metadata:
annotations:
alm-examples: |-
[
{
"apiVersion": "integreatly.org/v1alpha1",
"kind": "BlobStorage",
"metadata": {
"labels": {
"productName": "ProductName"
},
"name": "example-blobstorage"
},
"spec": {
"secretRef": {
"name": "example-blobstorage-sec"
},
"tier": "development",
"type": "REPLACE_ME"
}
},
{
"apiVersion": "integreatly.org/v1alpha1",
"kind": "Postgres",
Expand Down Expand Up @@ -74,29 +91,12 @@ metadata:
"tier": "development",
"type": "REPLACE_ME"
}
},
{
"apiVersion": "integreatly.org/v1alpha1",
"kind": "BlobStorage",
"metadata": {
"labels": {
"productName": "ProductName"
},
"name": "example-blobstorage"
},
"spec": {
"secretRef": {
"name": "example-blobstorage-sec"
},
"tier": "development",
"type": "REPLACE_ME"
}
}
]
capabilities: Basic Install
categories: Integration & Delivery
certified: "false"
containerImage: quay.io/integreatly/cloud-resource-operator:0.5.0
containerImage: quay.io/integreatly/cloud-resource-operator:v0.6.0
createdAt: "2019-10-07 12:34:56"
description: Operator to provision cloud provider resources in an abstracted manner
support: Integreatly
Expand Down Expand Up @@ -142,9 +142,15 @@ spec:
displayName: Secret Reference
path: secretRef
version: v1alpha1
- kind: PostgresSnapshot
- description: Represents an instance of a Postgres Snapshot
displayName: Postgres Snapshot
kind: PostgresSnapshot
name: postgressnapshots.integreatly.org
version: v1alpha1
specDescriptors:
- description: The type of the resource to snapshot
displayName: ResourceName
path: resourceName
- description: Represents an instance of a Redis cluster in a provider
displayName: Redis
kind: Redis
Expand All @@ -163,9 +169,15 @@ spec:
displayName: Secret Reference
path: secretRef
version: v1alpha1
- kind: RedisSnapshot
- description: Represents an instance of Postgres Snapshot
displayName: Redis Snapshot
kind: RedisSnapshot
name: redissnapshots.integreatly.org
version: v1alpha1
specDescriptors:
- description: The type of the resource to snapshot
displayName: ResourceName
path: resourceName
- description: Represents an instance of SMTP credentials in a provider
displayName: SMTP Credentials
kind: SMTPCredentialSet
Expand Down Expand Up @@ -239,7 +251,7 @@ spec:
value: cloud-resource-operator
- name: TAG_KEY_PREFIX
value: integreatly.org/
image: quay.io/integreatly/cloud-resource-operator:0.6.0
image: quay.io/integreatly/cloud-resource-operator:v0.6.0
imagePullPolicy: Always
name: cloud-resource-operator
resources: {}
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
const (
EnvForceReconcileTimeout = "ENV_FORCE_RECONCILE_TIMEOUT"
DefaultTagKeyPrefix = "integreatly.org/"
ErrorReconcileTime = time.Second * 30
SuccessReconcileTime = time.Second * 60
ErrorReconcileTime = time.Second * 30
SuccessReconcileTime = time.Second * 60
)

// returns envar for reconcile time else returns default time
Expand Down
15 changes: 6 additions & 9 deletions pkg/resources/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
type modifyResourceFunc func(cr metav1.Object) error

// ReconcileBlobStorage creates or updates a blob storage custom resource
func ReconcileBlobStorage(ctx context.Context, client client.Client, deploymentType, tier, name, ns, secretName, secretNs string, modifyFunc modifyResourceFunc) (*v1alpha1.BlobStorage, error) {
func ReconcileBlobStorage(ctx context.Context, client client.Client, productName, deploymentType, tier, name, ns, secretName, secretNs string, modifyFunc modifyResourceFunc) (*v1alpha1.BlobStorage, error) {
bs := &v1alpha1.BlobStorage{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: ns,
Labels: map[string]string{
"productName": name,
"productName": productName,
},
},
}
Expand Down Expand Up @@ -58,9 +58,6 @@ func ReconcileSMTPCredentialSet(ctx context.Context, client client.Client, deplo
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: ns,
Labels: map[string]string{
"productName": name,
},
},
}

Expand Down Expand Up @@ -91,13 +88,13 @@ func ReconcileSMTPCredentialSet(ctx context.Context, client client.Client, deplo
}

// ReconcilePostgres creates or updates a postgres custom resource
func ReconcilePostgres(ctx context.Context, client client.Client, deploymentType, tier, name, ns, secretName, secretNs string, modifyFunc modifyResourceFunc) (*v1alpha1.Postgres, error) {
func ReconcilePostgres(ctx context.Context, client client.Client, productName, deploymentType, tier, name, ns, secretName, secretNs string, modifyFunc modifyResourceFunc) (*v1alpha1.Postgres, error) {
pg := &v1alpha1.Postgres{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: ns,
Labels: map[string]string{
"productName": name,
"productName": productName,
},
},
}
Expand Down Expand Up @@ -129,13 +126,13 @@ func ReconcilePostgres(ctx context.Context, client client.Client, deploymentType
}

// ReconcileRedis creates or updates a redis custom resource
func ReconcileRedis(ctx context.Context, client client.Client, deploymentType, tier, name, ns, secretName, secretNs string, modifyFunc modifyResourceFunc) (*v1alpha1.Redis, error) {
func ReconcileRedis(ctx context.Context, client client.Client, productName, deploymentType, tier, name, ns, secretName, secretNs string, modifyFunc modifyResourceFunc) (*v1alpha1.Redis, error) {
r := &v1alpha1.Redis{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: ns,
Labels: map[string]string{
"productName": name,
"productName": productName,
},
},
}
Expand Down
76 changes: 15 additions & 61 deletions pkg/resources/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestReconcileBlobStorage(t *testing.T) {
type args struct {
ctx context.Context
client client.Client
productName string
deploymentType string
tier string
name string
Expand All @@ -57,6 +58,7 @@ func TestReconcileBlobStorage(t *testing.T) {
client: fake.NewFakeClientWithScheme(scheme),
deploymentType: "managed",
tier: "production",
productName: "test",
name: "test",
ns: "test",
secretName: "test",
Expand Down Expand Up @@ -90,6 +92,7 @@ func TestReconcileBlobStorage(t *testing.T) {
deploymentType: "managed",
tier: "production",
name: "test",
productName: "test",
ns: "test",
secretName: "test",
secretNs: "test",
Expand Down Expand Up @@ -127,6 +130,7 @@ func TestReconcileBlobStorage(t *testing.T) {
deploymentType: "workshop",
tier: "development",
name: "test",
productName: "test",
ns: "test",
secretName: "test",
secretNs: "test",
Expand All @@ -140,7 +144,7 @@ func TestReconcileBlobStorage(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ReconcileBlobStorage(tt.args.ctx, tt.args.client, tt.args.deploymentType, tt.args.tier, tt.args.name, tt.args.ns, tt.args.secretName, tt.args.secretNs, tt.args.modifyFunc)
got, err := ReconcileBlobStorage(tt.args.ctx, tt.args.client, tt.args.productName, tt.args.deploymentType, tt.args.tier, tt.args.name, tt.args.ns, tt.args.secretName, tt.args.secretNs, tt.args.modifyFunc)
if (err != nil) != tt.wantErr {
t.Errorf("ReconcileBlobStorage() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down Expand Up @@ -192,46 +196,6 @@ func TestReconcileSMTPCredentialSet(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Name: "test",
Namespace: "test",
Labels: map[string]string{
"productName": "test",
},
},
Spec: v1alpha1.SMTPCredentialSetSpec{
Type: "managed",
Tier: "production",
SecretRef: &types.SecretRef{
Name: "test",
Namespace: "test",
},
},
},
wantErr: false,
},
{
name: "test modification function",
args: args{
ctx: context.TODO(),
client: fake.NewFakeClientWithScheme(scheme),
deploymentType: "managed",
tier: "production",
name: "test",
ns: "test",
secretName: "test",
secretNs: "test",
modifyFunc: func(cr v1.Object) error {
cr.SetLabels(map[string]string{
"cro": "test",
})
return nil
},
},
want: &v1alpha1.SMTPCredentialSet{
ObjectMeta: v1.ObjectMeta{
Name: "test",
Namespace: "test",
Labels: map[string]string{
"cro": "test",
},
},
Spec: v1alpha1.SMTPCredentialSetSpec{
Type: "managed",
Expand All @@ -244,24 +208,6 @@ func TestReconcileSMTPCredentialSet(t *testing.T) {
},
wantErr: false,
},
{
name: "test modification function error",
args: args{
ctx: context.TODO(),
client: fake.NewFakeClientWithScheme(scheme),
deploymentType: "workshop",
tier: "development",
name: "test",
ns: "test",
secretName: "test",
secretNs: "test",
modifyFunc: func(cr v1.Object) error {
return errors.New("error executing function")
},
},
want: nil,
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -287,6 +233,7 @@ func TestReconcilePostgres(t *testing.T) {
ctx context.Context
client client.Client
deploymentType string
productName string
tier string
name string
ns string
Expand All @@ -307,6 +254,7 @@ func TestReconcilePostgres(t *testing.T) {
client: fake.NewFakeClientWithScheme(scheme),
deploymentType: "managed",
tier: "production",
productName: "test",
name: "test",
ns: "test",
secretName: "test",
Expand Down Expand Up @@ -338,6 +286,7 @@ func TestReconcilePostgres(t *testing.T) {
ctx: context.TODO(),
client: fake.NewFakeClientWithScheme(scheme),
deploymentType: "managed",
productName: "test",
tier: "production",
name: "test",
ns: "test",
Expand Down Expand Up @@ -376,6 +325,7 @@ func TestReconcilePostgres(t *testing.T) {
client: fake.NewFakeClientWithScheme(scheme),
deploymentType: "workshop",
tier: "development",
productName: "test",
name: "test",
ns: "test",
secretName: "test",
Expand All @@ -390,7 +340,7 @@ func TestReconcilePostgres(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ReconcilePostgres(tt.args.ctx, tt.args.client, tt.args.deploymentType, tt.args.tier, tt.args.name, tt.args.ns, tt.args.secretName, tt.args.secretNs, tt.args.modifyFunc)
got, err := ReconcilePostgres(tt.args.ctx, tt.args.client, tt.args.productName, tt.args.deploymentType, tt.args.tier, tt.args.name, tt.args.ns, tt.args.secretName, tt.args.secretNs, tt.args.modifyFunc)
if (err != nil) != tt.wantErr {
t.Errorf("ReconcilePostgres() error = %v, wantErr %v", err, tt.wantErr)
return
Expand All @@ -412,6 +362,7 @@ func TestReconcileRedis(t *testing.T) {
client client.Client
deploymentType string
tier string
productName string
name string
ns string
secretName string
Expand All @@ -431,6 +382,7 @@ func TestReconcileRedis(t *testing.T) {
client: fake.NewFakeClientWithScheme(scheme),
deploymentType: "managed",
tier: "production",
productName: "test",
name: "test",
ns: "test",
secretName: "test",
Expand Down Expand Up @@ -463,6 +415,7 @@ func TestReconcileRedis(t *testing.T) {
client: fake.NewFakeClientWithScheme(scheme),
deploymentType: "managed",
tier: "production",
productName: "test",
name: "test",
ns: "test",
secretName: "test",
Expand Down Expand Up @@ -500,6 +453,7 @@ func TestReconcileRedis(t *testing.T) {
client: fake.NewFakeClientWithScheme(scheme),
deploymentType: "workshop",
tier: "development",
productName: "test",
name: "test",
ns: "test",
secretName: "test",
Expand All @@ -514,7 +468,7 @@ func TestReconcileRedis(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ReconcileRedis(tt.args.ctx, tt.args.client, tt.args.deploymentType, tt.args.tier, tt.args.name, tt.args.ns, tt.args.secretName, tt.args.secretNs, tt.args.modifyFunc)
got, err := ReconcileRedis(tt.args.ctx, tt.args.client, tt.args.productName, tt.args.deploymentType, tt.args.tier, tt.args.name, tt.args.ns, tt.args.secretName, tt.args.secretNs, tt.args.modifyFunc)
if (err != nil) != tt.wantErr {
t.Errorf("ReconcileRedis() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down

0 comments on commit 9ebc8a9

Please sign in to comment.