{"ScriptPreparationCode":"const getName = (value) =\u003E\r\n _.get(value, \u0027metadata.name\u0027);","TestCases":[{"Name":"obusage","Code":"var obj2 ={\r\n kind: \u0027StorageClassList\u0027,\r\n apiVersion: \u0027storage.k8s.io/v1\u0027,\r\n metadata: {\r\n selfLink: \u0027/apis/storage.k8s.io/v1/storageclasses\u0027,\r\n resourceVersion: \u002796731\u0027\r\n },\r\n items: [\r\n {\r\n metadata: {\r\n name: \u0027example-storagecluster-ceph-rbd\u0027,\r\n selfLink: \u0027/apis/storage.k8s.io/v1/storageclasses/example-storagecluster-ceph-rbd\u0027,\r\n uid: \u002796797a5d-8608-40fd-a6ac-4a4fdf474dae\u0027,\r\n resourceVersion: \u002732796\u0027,\r\n creationTimestamp: \u00272019-11-08T08:38:15Z\u0027,\r\n ownerReferences: [\r\n {\r\n apiVersion: \u0027ocs.openshift.io/v1\u0027,\r\n kind: \u0027StorageCluster\u0027,\r\n name: \u0027example-storagecluster\u0027,\r\n uid: \u002717c2b0e9-e1a2-4f1c-b2eb-14e885dc3e92\u0027,\r\n controller: true,\r\n blockOwnerDeletion: true\r\n }\r\n ]\r\n },\r\n provisioner: \u0027openshift-storage.rbd.csi.ceph.com\u0027,\r\n parameters: {\r\n clusterID: \u0027openshift-storage\u0027,\r\n \u0027csi.storage.k8s.io/fstype\u0027: \u0027ext4\u0027,\r\n \u0027csi.storage.k8s.io/node-stage-secret-name\u0027: \u0027rook-csi-rbd-node\u0027,\r\n \u0027csi.storage.k8s.io/node-stage-secret-namespace\u0027: \u0027openshift-storage\u0027,\r\n \u0027csi.storage.k8s.io/provisioner-secret-name\u0027: \u0027rook-csi-rbd-provisioner\u0027,\r\n \u0027csi.storage.k8s.io/provisioner-secret-namespace\u0027: \u0027openshift-storage\u0027,\r\n imageFeatures: \u0027layering\u0027,\r\n imageFormat: \u00272\u0027,\r\n pool: \u0027example-storagecluster-cephblockpool\u0027\r\n },\r\n reclaimPolicy: \u0027Delete\u0027,\r\n volumeBindingMode: \u0027Immediate\u0027\r\n },\r\n {\r\n metadata: {\r\n name: \u0027example-storagecluster-cephfs\u0027,\r\n selfLink: \u0027/apis/storage.k8s.io/v1/storageclasses/example-storagecluster-cephfs\u0027,\r\n uid: \u0027fff93495-dd17-4335-a19e-aa5bdf31a78b\u0027,\r\n resourceVersion: \u002732795\u0027,\r\n creationTimestamp: \u00272019-11-08T08:38:15Z\u0027,\r\n ownerReferences: [\r\n {\r\n apiVersion: \u0027ocs.openshift.io/v1\u0027,\r\n kind: \u0027StorageCluster\u0027,\r\n name: \u0027example-storagecluster\u0027,\r\n uid: \u002717c2b0e9-e1a2-4f1c-b2eb-14e885dc3e92\u0027,\r\n controller: true,\r\n blockOwnerDeletion: true\r\n }\r\n ]\r\n },\r\n provisioner: \u0027openshift-storage.cephfs.csi.ceph.com\u0027,\r\n parameters: {\r\n clusterID: \u0027openshift-storage\u0027,\r\n \u0027csi.storage.k8s.io/node-stage-secret-name\u0027: \u0027rook-csi-cephfs-node\u0027,\r\n \u0027csi.storage.k8s.io/node-stage-secret-namespace\u0027: \u0027openshift-storage\u0027,\r\n \u0027csi.storage.k8s.io/provisioner-secret-name\u0027: \u0027rook-csi-cephfs-provisioner\u0027,\r\n \u0027csi.storage.k8s.io/provisioner-secret-namespace\u0027: \u0027openshift-storage\u0027,\r\n fsName: \u0027example-storagecluster-cephfilesystem\u0027\r\n },\r\n reclaimPolicy: \u0027Delete\u0027,\r\n volumeBindingMode: \u0027Immediate\u0027\r\n },\r\n {\r\n metadata: {\r\n name: \u0027gp2\u0027,\r\n selfLink: \u0027/apis/storage.k8s.io/v1/storageclasses/gp2\u0027,\r\n uid: \u0027a1140b0a-173e-4096-a398-5f4d5179bd66\u0027,\r\n resourceVersion: \u002716548\u0027,\r\n creationTimestamp: \u00272019-11-08T08:01:17Z\u0027,\r\n annotations: {\r\n \u0027storageclass.kubernetes.io/is-default-class\u0027: \u0027true\u0027\r\n },\r\n ownerReferences: [\r\n {\r\n apiVersion: \u0027v1\u0027,\r\n kind: \u0027clusteroperator\u0027,\r\n name: \u0027storage\u0027,\r\n uid: \u0027d7dd2e85-6533-48e9-b797-4682c66f313a\u0027\r\n }\r\n ]\r\n },\r\n provisioner: \u0027kubernetes.io/aws-ebs\u0027,\r\n parameters: {\r\n encrypted: \u0027true\u0027,\r\n type: \u0027gp2\u0027\r\n },\r\n reclaimPolicy: \u0027Delete\u0027,\r\n allowVolumeExpansion: true,\r\n volumeBindingMode: \u0027WaitForFirstConsumer\u0027\r\n },\r\n {\r\n metadata: {\r\n name: \u0027openshift-storage.noobaa.io\u0027,\r\n selfLink: \u0027/apis/storage.k8s.io/v1/storageclasses/openshift-storage.noobaa.io\u0027,\r\n uid: \u0027729e8642-7947-40d6-b3c0-2bfd8cd8b2c4\u0027,\r\n resourceVersion: \u002736813\u0027,\r\n creationTimestamp: \u00272019-11-08T08:43:41Z\u0027,\r\n ownerReferences: [\r\n {\r\n apiVersion: \u0027noobaa.io/v1alpha1\u0027,\r\n kind: \u0027NooBaa\u0027,\r\n name: \u0027noobaa\u0027,\r\n uid: \u00270eef6770-525b-43ed-a74f-30df335951f8\u0027,\r\n controller: true\r\n }\r\n ]\r\n },\r\n provisioner: \u0027openshift-storage.noobaa.io/obc\u0027,\r\n parameters: {\r\n bucketclass: \u0027noobaa-default-bucket-class\u0027\r\n },\r\n reclaimPolicy: \u0027Delete\u0027,\r\n volumeBindingMode: \u0027Immediate\u0027\r\n }\r\n ]\r\n};\r\n\r\nvar obj = {\r\n apiVersion: \u0027v1\u0027,\r\n items: [\r\n {\r\n apiVersion: \u0027objectbucket.io/v1alpha1\u0027,\r\n kind: \u0027ObjectBucketClaim\u0027,\r\n metadata: {\r\n creationTimestamp: \u00272019-11-08T10:13:28Z\u0027,\r\n finalizers: [\r\n \u0027objectbucket.io/finalizer\u0027\r\n ],\r\n generation: 2,\r\n labels: {\r\n app: \u0027noobaa\u0027,\r\n \u0027bucket-provisioner\u0027: \u0027openshift-storage.noobaa.io-obc\u0027,\r\n \u0027noobaa-domain\u0027: \u0027openshift-storage.noobaa.io\u0027\r\n },\r\n name: \u0027obc-1\u0027,\r\n namespace: \u0027openshift-storage\u0027,\r\n resourceVersion: \u002773383\u0027,\r\n selfLink: \u0027/apis/objectbucket.io/v1alpha1/namespaces/openshift-storage/objectbucketclaims/obc-1\u0027,\r\n uid: \u00275d5e9ef9-e9d2-44c4-bc97-28309185fda1\u0027\r\n },\r\n spec: {\r\n ObjectBucketName: \u0027obc-openshift-storage-obc-1\u0027,\r\n bucketName: \u0027obc-1-adcfc5d2-81fe-4550-a43c-d089236532ad\u0027,\r\n generateBucketName: \u0027obc-1\u0027,\r\n storageClassName: \u0027openshift-storage.noobaa.io\u0027\r\n },\r\n status: {\r\n phase: \u0027Bound\u0027\r\n }\r\n },\r\n {\r\n apiVersion: \u0027objectbucket.io/v1alpha1\u0027,\r\n kind: \u0027ObjectBucketClaim\u0027,\r\n metadata: {\r\n creationTimestamp: \u00272019-11-08T10:13:44Z\u0027,\r\n finalizers: [\r\n \u0027objectbucket.io/finalizer\u0027\r\n ],\r\n generation: 2,\r\n labels: {\r\n app: \u0027noobaa\u0027,\r\n \u0027bucket-provisioner\u0027: \u0027openshift-storage.noobaa.io-obc\u0027,\r\n \u0027noobaa-domain\u0027: \u0027openshift-storage.noobaa.io\u0027\r\n },\r\n name: \u0027obc-2\u0027,\r\n namespace: \u0027openshift-storage\u0027,\r\n resourceVersion: \u002773494\u0027,\r\n selfLink: \u0027/apis/objectbucket.io/v1alpha1/namespaces/openshift-storage/objectbucketclaims/obc-2\u0027,\r\n uid: \u002788145d72-e580-4481-add5-92f505e13207\u0027\r\n },\r\n spec: {\r\n ObjectBucketName: \u0027obc-openshift-storage-obc-2\u0027,\r\n bucketName: \u0027obc-2-d521f540-4a59-4b8e-8fe5-3a2f50bb5a44\u0027,\r\n generateBucketName: \u0027obc-2\u0027,\r\n storageClassName: \u0027openshift-storage.noobaa.io\u0027\r\n },\r\n status: {\r\n phase: \u0027Bound\u0027\r\n }\r\n }\r\n ],\r\n kind: \u0027List\u0027,\r\n metadata: {\r\n resourceVersion: \u0027\u0027,\r\n selfLink: \u0027\u0027\r\n }\r\n};\r\nconst getName = (value) =\u003E\r\n _.get(value, \u0027metadata.name\u0027);\r\nconst getNoobaaStorageClass = (storageClassesList) =\u003E {\r\n const obj = {};\r\n storageClassesList.forEach((sc) =\u003E {\r\n if (_.endsWith(_.get(sc, \u0027provisioner\u0027), \u0027noobaa.io/obc\u0027)) {\r\n obj[getName(sc)] = getName(sc);\r\n }\r\n });\r\n return obj;\r\n};\r\n\r\nconst getNoobaaObcs = (obcList, storageClassesList) =\u003E {\r\n const noobaaStorageClasses = getNoobaaStorageClass(storageClassesList);\r\n const result = obcList.filter((o) =\u003E {\r\n const storageClassName = _.get(o, \u0027spec.storageClassName\u0027);\r\n return !!noobaaStorageClasses[storageClassName];\r\n });\r\n return result.length;\r\n};\r\n\r\ngetNoobaaObcs(obj.items, obj2.items);","IsDeferred":false},{"Name":"mapusage","Code":"var obj2 ={\r\n kind: \u0027StorageClassList\u0027,\r\n apiVersion: \u0027storage.k8s.io/v1\u0027,\r\n metadata: {\r\n selfLink: \u0027/apis/storage.k8s.io/v1/storageclasses\u0027,\r\n resourceVersion: \u002796731\u0027\r\n },\r\n items: [\r\n {\r\n metadata: {\r\n name: \u0027example-storagecluster-ceph-rbd\u0027,\r\n selfLink: \u0027/apis/storage.k8s.io/v1/storageclasses/example-storagecluster-ceph-rbd\u0027,\r\n uid: \u002796797a5d-8608-40fd-a6ac-4a4fdf474dae\u0027,\r\n resourceVersion: \u002732796\u0027,\r\n creationTimestamp: \u00272019-11-08T08:38:15Z\u0027,\r\n ownerReferences: [\r\n {\r\n apiVersion: \u0027ocs.openshift.io/v1\u0027,\r\n kind: \u0027StorageCluster\u0027,\r\n name: \u0027example-storagecluster\u0027,\r\n uid: \u002717c2b0e9-e1a2-4f1c-b2eb-14e885dc3e92\u0027,\r\n controller: true,\r\n blockOwnerDeletion: true\r\n }\r\n ]\r\n },\r\n provisioner: \u0027openshift-storage.rbd.csi.ceph.com\u0027,\r\n parameters: {\r\n clusterID: \u0027openshift-storage\u0027,\r\n \u0027csi.storage.k8s.io/fstype\u0027: \u0027ext4\u0027,\r\n \u0027csi.storage.k8s.io/node-stage-secret-name\u0027: \u0027rook-csi-rbd-node\u0027,\r\n \u0027csi.storage.k8s.io/node-stage-secret-namespace\u0027: \u0027openshift-storage\u0027,\r\n \u0027csi.storage.k8s.io/provisioner-secret-name\u0027: \u0027rook-csi-rbd-provisioner\u0027,\r\n \u0027csi.storage.k8s.io/provisioner-secret-namespace\u0027: \u0027openshift-storage\u0027,\r\n imageFeatures: \u0027layering\u0027,\r\n imageFormat: \u00272\u0027,\r\n pool: \u0027example-storagecluster-cephblockpool\u0027\r\n },\r\n reclaimPolicy: \u0027Delete\u0027,\r\n volumeBindingMode: \u0027Immediate\u0027\r\n },\r\n {\r\n metadata: {\r\n name: \u0027example-storagecluster-cephfs\u0027,\r\n selfLink: \u0027/apis/storage.k8s.io/v1/storageclasses/example-storagecluster-cephfs\u0027,\r\n uid: \u0027fff93495-dd17-4335-a19e-aa5bdf31a78b\u0027,\r\n resourceVersion: \u002732795\u0027,\r\n creationTimestamp: \u00272019-11-08T08:38:15Z\u0027,\r\n ownerReferences: [\r\n {\r\n apiVersion: \u0027ocs.openshift.io/v1\u0027,\r\n kind: \u0027StorageCluster\u0027,\r\n name: \u0027example-storagecluster\u0027,\r\n uid: \u002717c2b0e9-e1a2-4f1c-b2eb-14e885dc3e92\u0027,\r\n controller: true,\r\n blockOwnerDeletion: true\r\n }\r\n ]\r\n },\r\n provisioner: \u0027openshift-storage.cephfs.csi.ceph.com\u0027,\r\n parameters: {\r\n clusterID: \u0027openshift-storage\u0027,\r\n \u0027csi.storage.k8s.io/node-stage-secret-name\u0027: \u0027rook-csi-cephfs-node\u0027,\r\n \u0027csi.storage.k8s.io/node-stage-secret-namespace\u0027: \u0027openshift-storage\u0027,\r\n \u0027csi.storage.k8s.io/provisioner-secret-name\u0027: \u0027rook-csi-cephfs-provisioner\u0027,\r\n \u0027csi.storage.k8s.io/provisioner-secret-namespace\u0027: \u0027openshift-storage\u0027,\r\n fsName: \u0027example-storagecluster-cephfilesystem\u0027\r\n },\r\n reclaimPolicy: \u0027Delete\u0027,\r\n volumeBindingMode: \u0027Immediate\u0027\r\n },\r\n {\r\n metadata: {\r\n name: \u0027gp2\u0027,\r\n selfLink: \u0027/apis/storage.k8s.io/v1/storageclasses/gp2\u0027,\r\n uid: \u0027a1140b0a-173e-4096-a398-5f4d5179bd66\u0027,\r\n resourceVersion: \u002716548\u0027,\r\n creationTimestamp: \u00272019-11-08T08:01:17Z\u0027,\r\n annotations: {\r\n \u0027storageclass.kubernetes.io/is-default-class\u0027: \u0027true\u0027\r\n },\r\n ownerReferences: [\r\n {\r\n apiVersion: \u0027v1\u0027,\r\n kind: \u0027clusteroperator\u0027,\r\n name: \u0027storage\u0027,\r\n uid: \u0027d7dd2e85-6533-48e9-b797-4682c66f313a\u0027\r\n }\r\n ]\r\n },\r\n provisioner: \u0027kubernetes.io/aws-ebs\u0027,\r\n parameters: {\r\n encrypted: \u0027true\u0027,\r\n type: \u0027gp2\u0027\r\n },\r\n reclaimPolicy: \u0027Delete\u0027,\r\n allowVolumeExpansion: true,\r\n volumeBindingMode: \u0027WaitForFirstConsumer\u0027\r\n },\r\n {\r\n metadata: {\r\n name: \u0027openshift-storage.noobaa.io\u0027,\r\n selfLink: \u0027/apis/storage.k8s.io/v1/storageclasses/openshift-storage.noobaa.io\u0027,\r\n uid: \u0027729e8642-7947-40d6-b3c0-2bfd8cd8b2c4\u0027,\r\n resourceVersion: \u002736813\u0027,\r\n creationTimestamp: \u00272019-11-08T08:43:41Z\u0027,\r\n ownerReferences: [\r\n {\r\n apiVersion: \u0027noobaa.io/v1alpha1\u0027,\r\n kind: \u0027NooBaa\u0027,\r\n name: \u0027noobaa\u0027,\r\n uid: \u00270eef6770-525b-43ed-a74f-30df335951f8\u0027,\r\n controller: true\r\n }\r\n ]\r\n },\r\n provisioner: \u0027openshift-storage.noobaa.io/obc\u0027,\r\n parameters: {\r\n bucketclass: \u0027noobaa-default-bucket-class\u0027\r\n },\r\n reclaimPolicy: \u0027Delete\u0027,\r\n volumeBindingMode: \u0027Immediate\u0027\r\n }\r\n ]\r\n};\r\n\r\nvar obj = {\r\n apiVersion: \u0027v1\u0027,\r\n items: [\r\n {\r\n apiVersion: \u0027objectbucket.io/v1alpha1\u0027,\r\n kind: \u0027ObjectBucketClaim\u0027,\r\n metadata: {\r\n creationTimestamp: \u00272019-11-08T10:13:28Z\u0027,\r\n finalizers: [\r\n \u0027objectbucket.io/finalizer\u0027\r\n ],\r\n generation: 2,\r\n labels: {\r\n app: \u0027noobaa\u0027,\r\n \u0027bucket-provisioner\u0027: \u0027openshift-storage.noobaa.io-obc\u0027,\r\n \u0027noobaa-domain\u0027: \u0027openshift-storage.noobaa.io\u0027\r\n },\r\n name: \u0027obc-1\u0027,\r\n namespace: \u0027openshift-storage\u0027,\r\n resourceVersion: \u002773383\u0027,\r\n selfLink: \u0027/apis/objectbucket.io/v1alpha1/namespaces/openshift-storage/objectbucketclaims/obc-1\u0027,\r\n uid: \u00275d5e9ef9-e9d2-44c4-bc97-28309185fda1\u0027\r\n },\r\n spec: {\r\n ObjectBucketName: \u0027obc-openshift-storage-obc-1\u0027,\r\n bucketName: \u0027obc-1-adcfc5d2-81fe-4550-a43c-d089236532ad\u0027,\r\n generateBucketName: \u0027obc-1\u0027,\r\n storageClassName: \u0027openshift-storage.noobaa.io\u0027\r\n },\r\n status: {\r\n phase: \u0027Bound\u0027\r\n }\r\n },\r\n {\r\n apiVersion: \u0027objectbucket.io/v1alpha1\u0027,\r\n kind: \u0027ObjectBucketClaim\u0027,\r\n metadata: {\r\n creationTimestamp: \u00272019-11-08T10:13:44Z\u0027,\r\n finalizers: [\r\n \u0027objectbucket.io/finalizer\u0027\r\n ],\r\n generation: 2,\r\n labels: {\r\n app: \u0027noobaa\u0027,\r\n \u0027bucket-provisioner\u0027: \u0027openshift-storage.noobaa.io-obc\u0027,\r\n \u0027noobaa-domain\u0027: \u0027openshift-storage.noobaa.io\u0027\r\n },\r\n name: \u0027obc-2\u0027,\r\n namespace: \u0027openshift-storage\u0027,\r\n resourceVersion: \u002773494\u0027,\r\n selfLink: \u0027/apis/objectbucket.io/v1alpha1/namespaces/openshift-storage/objectbucketclaims/obc-2\u0027,\r\n uid: \u002788145d72-e580-4481-add5-92f505e13207\u0027\r\n },\r\n spec: {\r\n ObjectBucketName: \u0027obc-openshift-storage-obc-2\u0027,\r\n bucketName: \u0027obc-2-d521f540-4a59-4b8e-8fe5-3a2f50bb5a44\u0027,\r\n generateBucketName: \u0027obc-2\u0027,\r\n storageClassName: \u0027openshift-storage.noobaa.io\u0027\r\n },\r\n status: {\r\n phase: \u0027Bound\u0027\r\n }\r\n }\r\n ],\r\n kind: \u0027List\u0027,\r\n metadata: {\r\n resourceVersion: \u0027\u0027,\r\n selfLink: \u0027\u0027\r\n }\r\n};\r\n\r\nconst getName = (value) =\u003E\r\n _.get(value, \u0027metadata.name\u0027);\r\n\r\nconst getNoobaaStorageClass = (storageClassesList) =\u003E {\r\n const storageClasMap = new Map(null);\r\n storageClassesList.forEach((sc) =\u003E {\r\n if (_.endsWith(_.get(sc, \u0027provisioner\u0027), \u0027noobaa.io/obc\u0027)) {\r\n const name = getName(sc);\r\n storageClasMap.set(name, name);\r\n }\r\n });\r\n return storageClasMap;\r\n};\r\n\r\nconst getNoobaaObcs = (obcList, storageClassesList) =\u003E {\r\n const noobaaStorageClasses = getNoobaaStorageClass(storageClassesList);\r\n const result = obcList.filter((o) =\u003E {\r\n const storageClassName = _.get(o, \u0027spec.storageClassName\u0027);\r\n return noobaaStorageClasses.has(storageClassName);\r\n });\r\n return result.length;\r\n};\r\n\r\ngetNoobaaObcs(obj.items, obj2.items);","IsDeferred":false}]}