nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: awslabs/cdk8s
Pull request #443 (2020-12-13 02:26:02)

fix: Lazy is not resolved in metadata
Allows annotations to be dynamically rendered.

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*


mergify[bot]: Your pull request will be updated and merged automatically (do not update manually).

Patch:
diff --git a/packages/cdk8s/src/metadata.ts b/packages/cdk8s/src/metadata.ts
index 5263d9244..2fa7f5555 100644
--- a/packages/cdk8s/src/metadata.ts
+++ b/packages/cdk8s/src/metadata.ts
@@ -1,3 +1,4 @@
+import { resolve } from './_resolve';
 import { sanitizeValue } from './_util';
 
 /**
@@ -141,12 +142,12 @@ export class ApiObjectMetadataDefinition {
    */
   public toJson() {
     const sanitize = (x: any) => sanitizeValue(x, { filterEmptyArrays: true, filterEmptyObjects: true });
-    return sanitize({
+    return sanitize(resolve({
       ...this._additionalAttributes,
       name: this.name,
       namespace: this.namespace,
       annotations: this.annotations,
       labels: this.labels,
-    });
+    }));
   }
 }


Test patch:
diff --git a/packages/cdk8s/test/metadata.test.ts b/packages/cdk8s/test/metadata.test.ts
index 78f4cbc45..b5edf9379 100644
--- a/packages/cdk8s/test/metadata.test.ts
+++ b/packages/cdk8s/test/metadata.test.ts
@@ -1,4 +1,4 @@
-import { ApiObjectMetadataDefinition } from '../src';
+import { ApiObjectMetadataDefinition, Lazy } from '../src';
 
 test('Can add a label', () => {
 
@@ -54,6 +54,38 @@ test('Instantiation properties are all respected', () => {
 
 });
 
+test('ensure Lazy properties are resolved', () => {
+
+  const meta = new ApiObjectMetadataDefinition({
+    labels: { key: 'value' },
+    annotations: {
+      key: 'value',
+      lazy: Lazy.any({ produce: () => { return { uiMeta: 'is good' }; } }),
+    },
+    name: 'name',
+    namespace: 'namespace',
+  });
+
+  const actual = meta.toJson();
+
+  const expected = {
+    name: 'name',
+    namespace: 'namespace',
+    annotations: {
+      key: 'value',
+      lazy: {
+        uiMeta: 'is good',
+      },
+    },
+    labels: {
+      key: 'value',
+    },
+  };
+
+  expect(actual).toStrictEqual(expected);
+
+});
+
 test('Can include arbirary key/value options', () => {
   const meta = new ApiObjectMetadataDefinition({
     foo: 123,
Repository: awslabs/cdk8s
Pull request #529 (2021-02-06 21:37:48)

fix(lib): ENOBUFS for large helm charts
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*

With charts such as cert-manager with crds included, the helm import functionality can run into an ENOBUFS error due to insufficient buffer size. This is very similar to issue #363 (except with helm instead of yaml download) and uses a very similar fix to PR #454. Thanks.

mergify[bot]: Your pull request will be updated and merged automatically (do not update manually).

Patch:
diff --git a/packages/cdk8s/src/helm.ts b/packages/cdk8s/src/helm.ts
index f69f62c1f..4fd433fd2 100644
--- a/packages/cdk8s/src/helm.ts
+++ b/packages/cdk8s/src/helm.ts
@@ -7,6 +7,8 @@ import * as yaml from 'yaml';
 import { Include } from './include';
 import { Names } from './names';
 
+const MAX_HELM_BUFFER = 10 * 1024 * 1024;
+
 /**
  * Options for `Helm`.
  */
@@ -98,7 +100,10 @@ export class Helm extends Include {
 }
 
 function renderTemplate(workdir: string, prog: string, args: string[]) {
-  const helm = cp.spawnSync(prog, args);
+  const helm = cp.spawnSync(prog, args, {
+      maxBuffer: MAX_HELM_BUFFER
+  });
+  
   if (helm.error) {
     const err = helm.error.message;
     if (err.includes('ENOENT')) {


Test patch:
diff --git a/packages/cdk8s/test/helm.test.ts b/packages/cdk8s/test/helm.test.ts
index a08c1fee5..b1039245b 100644
--- a/packages/cdk8s/test/helm.test.ts
+++ b/packages/cdk8s/test/helm.test.ts
@@ -128,7 +128,7 @@ test('helmFlags can be used to specify additional helm options', () => {
   ];
 
   expect(spawnMock).toHaveBeenCalledTimes(1);
-  expect(spawnMock).toHaveBeenCalledWith('helm', expectedArgs);
+  expect(spawnMock).toHaveBeenCalledWith('helm', expectedArgs, {"maxBuffer": 10485760});
 });
 
 test('propagates helm failures', () => {
@@ -140,4 +140,4 @@ test('propagates helm failures', () => {
     chart: SAMPLE_CHART_PATH,
     helmFlags: ['--invalid-argument-not-found-boom-boom'],
   })).toThrow(/unknown flag/);
-});
\ No newline at end of file
+});