Skip to content

Commit

Permalink
feat: include kubectl version explicitly in API (#43)
Browse files Browse the repository at this point in the history
Based on feedback from @rix0rrr, explicitly including the version number in the class name. 

This PR also bumps the major version to 2.0 so that it is clear to customers that this library is compatible with AWS CDK 2.0
  • Loading branch information
madeline-k committed Oct 21, 2022
1 parent 87f1c99 commit c23ffc1
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 60 deletions.
1 change: 1 addition & 0 deletions .projen/tasks.json

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

1 change: 1 addition & 0 deletions .projenrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
run: 'sudo chown superchain /var/run/docker.sock',
},
],
majorVersion: 2,
npmAccess: NpmAccess.PUBLIC,
releaseTagPrefix: `kubectl-v${SPEC_VERSION}`,
releaseWorkflowName: releaseWorkflowName,
Expand Down
102 changes: 51 additions & 51 deletions API.md

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

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

---

![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)
![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge)

---

> This library is currently under development. Do not use!
<!--END STABILITY BANNER-->

This module exports a single class called `KubectlLayer` which is a `lambda.LayerVersion` that
This module exports a single class called `KubectlV24Layer` which is a `lambda.LayerVersion` that
bundles the [`kubectl`](https://kubernetes.io/docs/reference/kubectl/kubectl/) and the
[`helm`](https://helm.sh/) command line.

Expand All @@ -23,11 +23,11 @@ Usage:

```ts
// KubectlLayer bundles the 'kubectl' and 'helm' command lines
import { KubectlLayer } from '@aws-cdk/lambda-layer-kubectl-v23';
import { KubectlV24Layer } from '@aws-cdk/lambda-layer-kubectl-v23';
import * as lambda from 'aws-cdk-lib/aws-lambda';

declare const fn: lambda.Function;
const kubectl = new KubectlLayer(this, 'KubectlLayer');
const kubectl = new KubectlV24Layer(this, 'KubectlLayer');
fn.addLayers(kubectl);
```

Expand Down
2 changes: 1 addition & 1 deletion src/kubectl-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { assetHash, ASSET_FILE } from './_asset';
/**
* A CDK Asset construct that contains `kubectl` and `helm`.
*/
export class KubectlLayer extends lambda.LayerVersion {
export class KubectlV24Layer extends lambda.LayerVersion {
constructor(scope: Construct, id: string) {
super(scope, id, {
code: lambda.Code.fromAsset(ASSET_FILE, {
Expand Down
4 changes: 2 additions & 2 deletions test/kubectl-layer.integ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import * as cdk from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as cr from 'aws-cdk-lib/custom-resources';

import { KubectlLayer } from '../lib';
import { KubectlV24Layer } from '../lib';

/**
* Test verifies that kubectl and helm are invoked successfully inside Lambda runtime.
*/

const app = new cdk.App();
const stack = new cdk.Stack(app, 'lambda-layer-kubectl-integ-stack');
const layer = new KubectlLayer(stack, 'KubectlLayer');
const layer = new KubectlV24Layer(stack, 'KubectlLayer');

const runtimes = [
lambda.Runtime.PYTHON_3_7,
Expand Down
4 changes: 2 additions & 2 deletions test/kubectl-layer.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Stack } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import { KubectlLayer } from '../lib';
import { KubectlV24Layer } from '../lib';

test('synthesized to a layer version', () => {
// GIVEN
const stack = new Stack();

// WHEN
new KubectlLayer(stack, 'MyLayer');
new KubectlV24Layer(stack, 'MyLayer');

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::LayerVersion', {
Expand Down

0 comments on commit c23ffc1

Please sign in to comment.