Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): python project template (#36)
The command cdk8s init python-app will create a new python cdk8s project. NOTE: this is intentionally not documented yet since we still don’t support cdk8s gen for python, so basically this only allows defining resources by directly instantiating ApiObjects. But this is still functional.
- Loading branch information
Elad Ben-Israel
committed
Mar 3, 2020
1 parent
3587f71
commit 30f3bb7
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { execSync } = require('child_process'); | ||
const { chmodSync } = require('fs'); | ||
|
||
exports.pre = () => { | ||
try { | ||
execSync('which pipenv') | ||
} catch { | ||
console.error(`Unable to find "pipenv". Please install https://pipenv.kennethreitz.org/`) | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
exports.post = () => { | ||
execSync('pipenv install', { stdio: 'inherit' }); | ||
|
||
console.log(); | ||
console.log("=================================================================================="); | ||
console.log(" Your cdk8s Python project was created successfully."); | ||
console.log(); | ||
console.log(" Useful commands:"); | ||
console.log(" - pipenv install: creates a virtual environment and installs deps"); | ||
console.log(" - pipenv run python main.py: synthesizes a k8s manifest in 'dist/' (ready for 'kubectl apply -f')"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
pylint = "*" | ||
|
||
[packages] | ||
aws-cdk-core = "*" | ||
cdk8s = "*" | ||
|
||
[requires] | ||
python_version = "3.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from aws_cdk.core import Construct | ||
from cdk8s import App, Chart | ||
|
||
class MyChart(Chart): | ||
def __init__(self, scope: Construct, ns: str, **kwargs): | ||
super().__init__(scope, ns, **kwargs) | ||
|
||
# define resources here | ||
|
||
app = App() | ||
MyChart(app, "{{ $base }}") | ||
|
||
app.synth() |