@vfarcic/dot-ai 0.103.0 → 0.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/dist/core/ai-provider-factory.d.ts +90 -0
- package/dist/core/ai-provider-factory.d.ts.map +1 -0
- package/dist/core/ai-provider-factory.js +187 -0
- package/dist/core/ai-provider.interface.d.ts +116 -0
- package/dist/core/ai-provider.interface.d.ts.map +1 -0
- package/dist/core/ai-provider.interface.js +14 -0
- package/dist/core/capabilities.d.ts +3 -3
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/capabilities.js +4 -4
- package/dist/core/capability-scan-workflow.d.ts.map +1 -1
- package/dist/core/capability-scan-workflow.js +29 -14
- package/dist/core/doc-testing-session.d.ts +1 -1
- package/dist/core/doc-testing-session.js +1 -1
- package/dist/core/error-handling.js +2 -2
- package/dist/core/index.d.ts +4 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +11 -22
- package/dist/core/nushell-runtime.d.ts +39 -0
- package/dist/core/nushell-runtime.d.ts.map +1 -0
- package/dist/core/nushell-runtime.js +103 -0
- package/dist/core/platform-operations.d.ts +76 -0
- package/dist/core/platform-operations.d.ts.map +1 -0
- package/dist/core/platform-operations.js +317 -0
- package/dist/core/providers/anthropic-provider.d.ts +32 -0
- package/dist/core/providers/anthropic-provider.d.ts.map +1 -0
- package/dist/core/providers/anthropic-provider.js +177 -0
- package/dist/core/providers/vercel-provider.d.ts +34 -0
- package/dist/core/providers/vercel-provider.d.ts.map +1 -0
- package/dist/core/providers/vercel-provider.js +202 -0
- package/dist/core/schema.d.ts +4 -7
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +13 -11
- package/dist/core/unified-creation-session.d.ts.map +1 -1
- package/dist/core/unified-creation-session.js +13 -14
- package/dist/interfaces/mcp.d.ts +1 -1
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +10 -2
- package/dist/interfaces/rest-api.js +1 -1
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +2 -2
- package/dist/tools/answer-question.d.ts.map +1 -1
- package/dist/tools/answer-question.js +8 -10
- package/dist/tools/build-platform.d.ts +25 -0
- package/dist/tools/build-platform.d.ts.map +1 -0
- package/dist/tools/build-platform.js +277 -0
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +7 -8
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -1
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +3 -2
- package/dist/tools/recommend.d.ts.map +1 -1
- package/dist/tools/recommend.js +50 -30
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +23 -39
- package/dist/tools/version.d.ts +10 -2
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +65 -24
- package/package.json +7 -3
- package/prompts/map-intent-to-operation.md +104 -0
- package/prompts/parse-script-operations.md +72 -0
- package/prompts/question-generation.md +31 -3
- package/scripts/ack.nu +195 -0
- package/scripts/anthropic.nu +24 -0
- package/scripts/argo-workflows.nu +47 -0
- package/scripts/argocd.nu +85 -0
- package/scripts/aso.nu +74 -0
- package/scripts/atlas.nu +15 -0
- package/scripts/backstage.nu +349 -0
- package/scripts/cert-manager.nu +13 -0
- package/scripts/cnpg.nu +14 -0
- package/scripts/common.nu +116 -0
- package/scripts/crossplane.nu +718 -0
- package/scripts/dot.nu +32 -0
- package/scripts/external-secrets.nu +110 -0
- package/scripts/gatekeeper.nu +19 -0
- package/scripts/github.nu +42 -0
- package/scripts/image.nu +67 -0
- package/scripts/ingress.nu +149 -0
- package/scripts/kro.nu +11 -0
- package/scripts/kubernetes.nu +609 -0
- package/scripts/kubevela.nu +22 -0
- package/scripts/kyverno.nu +16 -0
- package/scripts/mcp.nu +139 -0
- package/scripts/port.nu +71 -0
- package/scripts/prometheus.nu +21 -0
- package/scripts/registry.nu +55 -0
- package/scripts/storage.nu +210 -0
- package/scripts/tests.nu +12 -0
- package/scripts/toolhive.nu +21 -0
- package/scripts/velero.nu +45 -0
- package/dist/core/claude.d.ts +0 -88
- package/dist/core/claude.d.ts.map +0 -1
- package/dist/core/claude.js +0 -414
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Map User Intent to Platform Operation
|
|
2
|
+
|
|
3
|
+
You are helping map natural language user intent to available Kubernetes platform operations.
|
|
4
|
+
|
|
5
|
+
## User Intent
|
|
6
|
+
```text
|
|
7
|
+
{intent}
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Available Operations
|
|
11
|
+
```json
|
|
12
|
+
{operations}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Your Task
|
|
16
|
+
|
|
17
|
+
Analyze the user intent and find the **single best matching operation** from the available operations list.
|
|
18
|
+
|
|
19
|
+
### Matching Guidelines
|
|
20
|
+
|
|
21
|
+
1. **Keyword Matching**: Look for operation names, tool names, or descriptions that match intent keywords
|
|
22
|
+
2. **Context Understanding**: Consider what the user is trying to accomplish
|
|
23
|
+
3. **Semantic Matching**: Match based on meaning, not just exact words
|
|
24
|
+
- "Install X" → operation with "install", "apply", "setup" in name/description
|
|
25
|
+
- "Create cluster" → operation with "create" and "kubernetes"
|
|
26
|
+
- "Deploy X" → operation with "apply", "install"
|
|
27
|
+
- "Remove X" → operation with "delete", "uninstall"
|
|
28
|
+
|
|
29
|
+
4. **Be Specific**:
|
|
30
|
+
- "Install database" → Match to actual database tool (CNPG for PostgreSQL), not schema migration tools
|
|
31
|
+
- "Install Argo CD" / "Install ArgoCD" → Match to ArgoCD installation
|
|
32
|
+
- Consider the primary purpose of each tool from its description
|
|
33
|
+
|
|
34
|
+
### Response Format
|
|
35
|
+
|
|
36
|
+
Return **ONLY** valid JSON (no markdown, no code blocks, no explanations):
|
|
37
|
+
|
|
38
|
+
**If exact match found:**
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"matched": true,
|
|
42
|
+
"operation": {
|
|
43
|
+
"tool": "ArgoCD",
|
|
44
|
+
"operation": "install",
|
|
45
|
+
"command": ["apply", "argocd"], // COPY THIS EXACTLY from operations data - do NOT modify
|
|
46
|
+
"description": "Installs ArgoCD with optional ingress and applications setup"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**CRITICAL**: The `command` array MUST be copied **character-for-character** from the operations data. Do NOT infer, modify, or construct it based on the user's intent.
|
|
52
|
+
|
|
53
|
+
**If no match found:**
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"matched": false,
|
|
57
|
+
"reason": "No operation matches the intent 'Install FooBarBaz'. Use stage: 'list' to see all available operations."
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Important Rules
|
|
62
|
+
|
|
63
|
+
- Return **only one operation** (the best match)
|
|
64
|
+
- If no reasonable match exists, return `"matched": false` with helpful reason
|
|
65
|
+
- Be confident in your matches - don't be overly conservative
|
|
66
|
+
- Consider synonyms: "install" ≈ "setup" ≈ "deploy" ≈ "apply"
|
|
67
|
+
- **CRITICAL**: Use the **EXACT command array** from the operations data - do NOT modify it
|
|
68
|
+
- User may say "cross plane" but if operation command is ["apply", "crossplane"], use that exactly
|
|
69
|
+
- User may say "external secrets" but if command is ["apply", "externalsecrets"], use that exactly
|
|
70
|
+
- Match by description/meaning, but return the exact command from operations data
|
|
71
|
+
- Extract tool name from the operation name or description
|
|
72
|
+
- Extract operation type from the command or description (e.g., "install" for apply commands)
|
|
73
|
+
|
|
74
|
+
### Examples
|
|
75
|
+
|
|
76
|
+
**Intent**: "Install Crossplane"
|
|
77
|
+
**Operations**:
|
|
78
|
+
```json
|
|
79
|
+
[{
|
|
80
|
+
"name": "Crossplane",
|
|
81
|
+
"description": "Infrastructure management tool",
|
|
82
|
+
"operations": [{"name": "apply", "command": ["apply", "crossplane"]}]
|
|
83
|
+
}]
|
|
84
|
+
```
|
|
85
|
+
→ Match to: `{"matched": true, "operation": {"tool": "Crossplane", "operation": "apply", "command": ["apply", "crossplane"], "description": "Infrastructure management tool"}}`
|
|
86
|
+
|
|
87
|
+
**Intent**: "Create a kind cluster"
|
|
88
|
+
**Operations**:
|
|
89
|
+
```json
|
|
90
|
+
[{
|
|
91
|
+
"name": "Kubernetes",
|
|
92
|
+
"description": "Kubernetes cluster management",
|
|
93
|
+
"operations": [{"name": "create", "command": ["create", "kubernetes", "kind"]}]
|
|
94
|
+
}]
|
|
95
|
+
```
|
|
96
|
+
→ Match to: `{"matched": true, "operation": {"tool": "Kubernetes", "operation": "create", "command": ["create", "kubernetes", "kind"], "description": "Kubernetes cluster management"}}`
|
|
97
|
+
|
|
98
|
+
**Intent**: "Install FooBarBaz"
|
|
99
|
+
**Operations**: `[{...no matching operations...}]`
|
|
100
|
+
→ No match: `{"matched": false, "reason": "No operation matches the intent 'Install FooBarBaz'. Use stage: 'list' to see all available operations."}`
|
|
101
|
+
|
|
102
|
+
**REMEMBER**: Always copy the exact `command` array from the operations data!
|
|
103
|
+
|
|
104
|
+
Now analyze the user intent and return the matching operation in JSON format.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Parse Nu Shell Script Operations
|
|
2
|
+
|
|
3
|
+
You are a specialized parser that extracts available operations from Nushell script help output.
|
|
4
|
+
|
|
5
|
+
## Input
|
|
6
|
+
|
|
7
|
+
Here is the help output from a Nu shell script:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
{helpOutput}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Task
|
|
14
|
+
|
|
15
|
+
Parse this help output and extract all available tools/resources with their operations into a structured JSON array.
|
|
16
|
+
|
|
17
|
+
## Rules
|
|
18
|
+
|
|
19
|
+
1. Group operations by tool/resource (e.g., ArgoCD, Kubernetes cluster, Crossplane)
|
|
20
|
+
2. For each tool/resource, identify available operations (apply, delete, create, destroy, build, configure, etc.)
|
|
21
|
+
3. Extract:
|
|
22
|
+
- `name`: Tool/resource name (e.g., "ArgoCD", "Kubernetes cluster", "Crossplane")
|
|
23
|
+
- `description`: Description of what this tool/resource does
|
|
24
|
+
- `operations`: Array of operation objects, each with:
|
|
25
|
+
- `name`: Operation name extracted from help (e.g., "apply", "delete", "create")
|
|
26
|
+
- `command`: Array of command parts from help output (e.g., ["apply", "argocd"])
|
|
27
|
+
4. **CRITICAL**: Extract command arrays EXACTLY as they appear in help - "dot.nu apply argocd" → `["apply", "argocd"]`
|
|
28
|
+
5. Do NOT include internal utility commands like "get", "print", "packages"
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
From help output like:
|
|
33
|
+
```sh
|
|
34
|
+
dot.nu apply argocd - Installs ArgoCD with optional ingress
|
|
35
|
+
dot.nu delete argocd - Removes ArgoCD
|
|
36
|
+
dot.nu create kubernetes - Creates a Kubernetes cluster
|
|
37
|
+
dot.nu destroy kubernetes - Destroys a Kubernetes cluster
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Extract:
|
|
41
|
+
```json
|
|
42
|
+
[
|
|
43
|
+
{
|
|
44
|
+
"name": "ArgoCD",
|
|
45
|
+
"description": "GitOps continuous delivery tool for Kubernetes",
|
|
46
|
+
"operations": [
|
|
47
|
+
{"name": "apply", "command": ["apply", "argocd"]},
|
|
48
|
+
{"name": "delete", "command": ["delete", "argocd"]}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "Kubernetes cluster",
|
|
53
|
+
"description": "Kubernetes cluster management",
|
|
54
|
+
"operations": [
|
|
55
|
+
{"name": "create", "command": ["create", "kubernetes"]},
|
|
56
|
+
{"name": "destroy", "command": ["destroy", "kubernetes"]}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Output Format
|
|
63
|
+
|
|
64
|
+
Return ONLY a JSON array with no additional text, markdown formatting, or explanation.
|
|
65
|
+
|
|
66
|
+
## Important
|
|
67
|
+
|
|
68
|
+
- Return ONLY the JSON array
|
|
69
|
+
- NO markdown code blocks (no ```json)
|
|
70
|
+
- NO explanations
|
|
71
|
+
- NO additional text
|
|
72
|
+
- Just the raw JSON array starting with [ and ending with ]
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
|
|
18
18
|
## Instructions
|
|
19
19
|
|
|
20
|
+
## ⚠️ CRITICAL: MANDATORY "name" FIELD REQUIREMENT
|
|
21
|
+
|
|
22
|
+
**BEFORE GENERATING ANY QUESTIONS**: The REQUIRED section MUST include a question with `id: "name"`. This is non-negotiable and your response will be rejected if this field is missing or renamed to any variation like "cluster-name", "deployment-name", or "app-name".
|
|
23
|
+
|
|
20
24
|
## 🛡️ POLICY-AWARE QUESTION GENERATION (HIGHEST PRIORITY)
|
|
21
25
|
|
|
22
26
|
**Policy Requirements Integration:**
|
|
@@ -52,9 +56,21 @@ Organize questions into three categories based on their importance and impact:
|
|
|
52
56
|
### REQUIRED Questions
|
|
53
57
|
Essential information needed for basic functionality. These are mandatory fields or critical configuration that makes the difference between working and non-working deployments. Without answers to these questions, the manifests cannot be generated or will fail to deploy.
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
**🚨 CRITICAL MANDATORY REQUIREMENTS - NON-NEGOTIABLE 🚨**
|
|
60
|
+
|
|
61
|
+
You MUST include these EXACT questions with these EXACT IDs in the REQUIRED section. DO NOT rename, replace, or substitute these with similar fields:
|
|
62
|
+
|
|
63
|
+
1. **REQUIRED: `name` question (id: "name")**
|
|
64
|
+
- Question ID MUST be exactly: `"id": "name"`
|
|
65
|
+
- DO NOT use: "cluster-name", "deployment-name", "app-name", or any variation
|
|
66
|
+
- This is used for tracking and metadata - the manifest generator will apply it appropriately to resource-specific name fields
|
|
67
|
+
- Example: `{"id": "name", "question": "What is the name for this deployment?", "type": "text", ...}`
|
|
68
|
+
|
|
69
|
+
2. **REQUIRED: `namespace` question (id: "namespace")**
|
|
70
|
+
- ONLY if any resource in the solution is namespace-scoped - check resource scope information
|
|
71
|
+
- Question ID MUST be exactly: `"id": "namespace"`
|
|
72
|
+
|
|
73
|
+
**VALIDATION**: Your response will fail if the REQUIRED section does not contain a question with `"id": "name"`
|
|
58
74
|
|
|
59
75
|
### BASIC Questions
|
|
60
76
|
Common configuration options most users will want to set. These improve the deployment but aren't strictly required for basic functionality. They represent sensible customizations that enhance the deployment.
|
|
@@ -113,6 +129,17 @@ Return your response as JSON in this exact format:
|
|
|
113
129
|
```json
|
|
114
130
|
{
|
|
115
131
|
"required": [
|
|
132
|
+
{
|
|
133
|
+
"id": "name",
|
|
134
|
+
"question": "What is the name for this deployment?",
|
|
135
|
+
"type": "text",
|
|
136
|
+
"placeholder": "e.g., my-app",
|
|
137
|
+
"validation": {
|
|
138
|
+
"required": true,
|
|
139
|
+
"pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"
|
|
140
|
+
},
|
|
141
|
+
"suggestedAnswer": "example-app"
|
|
142
|
+
},
|
|
116
143
|
{
|
|
117
144
|
"id": "unique-kebab-case-id",
|
|
118
145
|
"question": "User-friendly question text?",
|
|
@@ -143,6 +170,7 @@ Return your response as JSON in this exact format:
|
|
|
143
170
|
|
|
144
171
|
## Important Notes
|
|
145
172
|
|
|
173
|
+
- **CRITICAL VALIDATION REQUIREMENT**: The REQUIRED section MUST contain a question with `"id": "name"` - responses without this will be rejected
|
|
146
174
|
- **CRITICAL**: Only ask questions about properties explicitly defined in the provided resource schemas
|
|
147
175
|
- **REQUIRED**: Each question must include a `suggestedAnswer` field with a valid example value that passes the validation rules
|
|
148
176
|
- **Generate comprehensive questions** covering all meaningful configuration options available in the resource schemas
|
package/scripts/ack.nu
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
# Installs and configures AWS Controllers for Kubernetes (ACK)
|
|
4
|
+
#
|
|
5
|
+
# Examples:
|
|
6
|
+
# > main apply ack --cluster_name my-cluster --region us-west-2
|
|
7
|
+
def --env "main apply ack" [
|
|
8
|
+
--cluster_name = "dot"
|
|
9
|
+
--region = "us-east-1"
|
|
10
|
+
--apply_irsa = true
|
|
11
|
+
--aws-access-key-id: string, # AWS Access Key ID (optional, falls back to AWS_ACCESS_KEY_ID env var)
|
|
12
|
+
--aws-secret-access-key: string # AWS Secret Access Key (optional, falls back to AWS_SECRET_ACCESS_KEY env var)
|
|
13
|
+
] {
|
|
14
|
+
|
|
15
|
+
print $"\nApplying (ansi yellow_bold)ACK Controllers(ansi reset)...\n"
|
|
16
|
+
|
|
17
|
+
mut access_key = $aws_access_key_id
|
|
18
|
+
if ($access_key | is-empty) and ("AWS_ACCESS_KEY_ID" in $env) {
|
|
19
|
+
$access_key = $env.AWS_ACCESS_KEY_ID
|
|
20
|
+
} else if ($access_key | is-empty) {
|
|
21
|
+
error make { msg: "AWS Access Key ID required via --aws-access-key-id parameter or AWS_ACCESS_KEY_ID environment variable" }
|
|
22
|
+
}
|
|
23
|
+
$env.AWS_ACCESS_KEY_ID = $access_key
|
|
24
|
+
$"export AWS_ACCESS_KEY_ID=($env.AWS_ACCESS_KEY_ID)\n"
|
|
25
|
+
| save --append .env
|
|
26
|
+
|
|
27
|
+
mut secret_key = $aws_secret_access_key
|
|
28
|
+
if ($secret_key | is-empty) and ("AWS_SECRET_ACCESS_KEY" in $env) {
|
|
29
|
+
$secret_key = $env.AWS_SECRET_ACCESS_KEY
|
|
30
|
+
} else if ($secret_key | is-empty) {
|
|
31
|
+
error make { msg: "AWS Secret Access Key required via --aws-secret-access-key parameter or AWS_SECRET_ACCESS_KEY environment variable" }
|
|
32
|
+
}
|
|
33
|
+
$env.AWS_SECRET_ACCESS_KEY = $secret_key
|
|
34
|
+
$"export AWS_SECRET_ACCESS_KEY=($env.AWS_SECRET_ACCESS_KEY)\n"
|
|
35
|
+
| save --append .env
|
|
36
|
+
|
|
37
|
+
let password = (
|
|
38
|
+
aws ecr-public get-login-password --region us-east-1
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
(
|
|
42
|
+
helm registry login --username AWS --password $password
|
|
43
|
+
public.ecr.aws
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
mut aws_account_id = ""
|
|
47
|
+
mut oidc_provider = ""
|
|
48
|
+
|
|
49
|
+
if $apply_irsa {
|
|
50
|
+
|
|
51
|
+
if AWS_ACCOUNT_ID in $env {
|
|
52
|
+
$aws_account_id = $env.AWS_ACCOUNT_ID
|
|
53
|
+
} else {
|
|
54
|
+
$aws_account_id = (
|
|
55
|
+
aws sts get-caller-identity --query "Account"
|
|
56
|
+
--output text
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if OIDC_PROVIDER in $env {
|
|
61
|
+
$oidc_provider = $env.OIDC_PROVIDER
|
|
62
|
+
} else {
|
|
63
|
+
$oidc_provider = (
|
|
64
|
+
aws eks describe-cluster --name $cluster_name
|
|
65
|
+
--region $region
|
|
66
|
+
--query "cluster.identity.oidc.issuer"
|
|
67
|
+
--output text | str replace "https://" ""
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let controllers = [
|
|
74
|
+
{name: "ec2", version: "1.3.7"},
|
|
75
|
+
{name: "rds", version: "1.4.14"},
|
|
76
|
+
]
|
|
77
|
+
for controller in $controllers {
|
|
78
|
+
|
|
79
|
+
let ack_controller_iam_role = $"ack-($controller.name)-controller"
|
|
80
|
+
|
|
81
|
+
(
|
|
82
|
+
helm upgrade --install $ack_controller_iam_role
|
|
83
|
+
oci://public.ecr.aws/aws-controllers-k8s/($controller.name)-chart
|
|
84
|
+
$"--version=($controller.version)"
|
|
85
|
+
--create-namespace --namespace ack-system
|
|
86
|
+
--set aws.region=us-east-1
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
if $apply_irsa {
|
|
90
|
+
|
|
91
|
+
{
|
|
92
|
+
Version: "2012-10-17",
|
|
93
|
+
Statement: [
|
|
94
|
+
{
|
|
95
|
+
Effect: "Allow",
|
|
96
|
+
Principal: {
|
|
97
|
+
Federated: $"arn:aws:iam::($aws_account_id):oidc-provider/($oidc_provider)"
|
|
98
|
+
},
|
|
99
|
+
"Action": "sts:AssumeRoleWithWebIdentity",
|
|
100
|
+
"Condition": {
|
|
101
|
+
"StringEquals": {
|
|
102
|
+
$"($oidc_provider):sub": $"system:serviceaccount:ack-system:($ack_controller_iam_role)"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
} | to json | save trust.json --force
|
|
108
|
+
|
|
109
|
+
do --ignore-errors {(
|
|
110
|
+
aws iam create-role
|
|
111
|
+
--role-name $ack_controller_iam_role
|
|
112
|
+
--assume-role-policy-document file://trust.json
|
|
113
|
+
--description $"IRSA role for ACK ($controller.name) controller deployment on EKS cluster using Helm charts"
|
|
114
|
+
)}
|
|
115
|
+
|
|
116
|
+
let policy_arns = (
|
|
117
|
+
get policy_arns --controller $controller.name
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
for policy_arn in $policy_arns {(
|
|
121
|
+
aws iam attach-role-policy
|
|
122
|
+
--role-name $ack_controller_iam_role
|
|
123
|
+
--policy-arn $policy_arn
|
|
124
|
+
)}
|
|
125
|
+
|
|
126
|
+
let role_arn = (
|
|
127
|
+
aws iam get-role --role-name $ack_controller_iam_role
|
|
128
|
+
--query Role.Arn --output text
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
(
|
|
132
|
+
kubectl --namespace ack-system
|
|
133
|
+
annotate serviceaccount $ack_controller_iam_role
|
|
134
|
+
$"eks.amazonaws.com/role-arn=($role_arn)"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
(
|
|
138
|
+
kubectl --namespace ack-system
|
|
139
|
+
rollout restart deployment
|
|
140
|
+
$"($ack_controller_iam_role)-($controller.name)-chart"
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
(
|
|
144
|
+
kubectl --namespace ack-system wait
|
|
145
|
+
--for=condition=ready pods
|
|
146
|
+
--selector $"app.kubernetes.io/instance=($ack_controller_iam_role)"
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
# Removes AWS Controllers for Kubernetes (ACK) and deletes associated IAM roles
|
|
156
|
+
def --env "main delete ack" [] {
|
|
157
|
+
|
|
158
|
+
let controllers = [
|
|
159
|
+
"ec2",
|
|
160
|
+
"rds"
|
|
161
|
+
]
|
|
162
|
+
for controller in $controllers {
|
|
163
|
+
|
|
164
|
+
let ack_controller_iam_role = $"ack-($controller)-controller"
|
|
165
|
+
|
|
166
|
+
let policy_arns = (
|
|
167
|
+
get policy_arns --controller $controller
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
for policy_arn in $policy_arns {
|
|
171
|
+
|
|
172
|
+
do --ignore-errors {(
|
|
173
|
+
aws iam detach-role-policy
|
|
174
|
+
--role-name ($ack_controller_iam_role)
|
|
175
|
+
--policy-arn ($policy_arn)
|
|
176
|
+
)}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
aws iam delete-role --role-name $ack_controller_iam_role
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
def "get policy_arns" [
|
|
186
|
+
--controller = "ec2"
|
|
187
|
+
] {
|
|
188
|
+
|
|
189
|
+
let base_url = $"https://raw.githubusercontent.com/aws-controllers-k8s/($controller)-controller/main"
|
|
190
|
+
|
|
191
|
+
let policy_arn_url = $"($base_url)/config/iam/recommended-policy-arn"
|
|
192
|
+
|
|
193
|
+
http get $policy_arn_url | lines
|
|
194
|
+
|
|
195
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
# Retrieves Anthropic token
|
|
4
|
+
#
|
|
5
|
+
# Parameters:
|
|
6
|
+
# --anthropic-api-key: Anthropic API key (optional, falls back to ANTHROPIC_API_KEY env var)
|
|
7
|
+
#
|
|
8
|
+
# Returns:
|
|
9
|
+
# A record with token, and saves values to .env file
|
|
10
|
+
def --env "main get anthropic" [
|
|
11
|
+
--anthropic-api-key: string
|
|
12
|
+
] {
|
|
13
|
+
|
|
14
|
+
mut key = $anthropic_api_key
|
|
15
|
+
if ($key | is-empty) and ("ANTHROPIC_API_KEY" in $env) {
|
|
16
|
+
$key = $env.ANTHROPIC_API_KEY
|
|
17
|
+
} else if ($key | is-empty) {
|
|
18
|
+
error make { msg: "Anthropic API key required via --anthropic-api-key parameter or ANTHROPIC_API_KEY environment variable" }
|
|
19
|
+
}
|
|
20
|
+
$"export ANTHROPIC_API_KEY=($key)\n" | save --append .env
|
|
21
|
+
|
|
22
|
+
{token: $key}
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
# Installs Argo Workflows with container registry credentials
|
|
4
|
+
#
|
|
5
|
+
# Examples:
|
|
6
|
+
# > main apply argoworkflows my-user my-password user@example.com --registry ghcr.io
|
|
7
|
+
def "main apply argoworkflows" [
|
|
8
|
+
registry_user: string # Container image registry user
|
|
9
|
+
registry_password: string # Container image registry password
|
|
10
|
+
registry_email: string # Container image registry email
|
|
11
|
+
--registry = "ghcr.io" # Container image registry
|
|
12
|
+
] {
|
|
13
|
+
|
|
14
|
+
kubectl create namespace argo
|
|
15
|
+
|
|
16
|
+
(
|
|
17
|
+
kubectl --namespace argo apply
|
|
18
|
+
--filename "https://github.com/argoproj/argo-workflows/releases/download/v3.6.0/quick-start-minimal.yaml"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
let auth = ( $"($registry_user):($registry_password)" | base64 )
|
|
22
|
+
|
|
23
|
+
let json = {
|
|
24
|
+
"auths": {
|
|
25
|
+
$"($registry)": {
|
|
26
|
+
"auth": $"($auth)"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} | to json
|
|
30
|
+
|
|
31
|
+
(
|
|
32
|
+
kubectl --namespace argo create secret
|
|
33
|
+
docker-registry regcred
|
|
34
|
+
$"--docker-server=($registry)"
|
|
35
|
+
--docker-username=($registry_user)
|
|
36
|
+
--docker-password=($registry_password)
|
|
37
|
+
--docker-email=($registry_email)
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
(
|
|
41
|
+
kubectl --namespace argo create secret
|
|
42
|
+
generic registry-creds
|
|
43
|
+
--from-literal $"password=($registry_password)"
|
|
44
|
+
--from-literal $"config.json=($json)"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
# Installs ArgoCD with optional ingress and applications setup
|
|
4
|
+
#
|
|
5
|
+
# Examples:
|
|
6
|
+
# > main apply argocd --host_name argocd.example.com --ingress_class_name nginx
|
|
7
|
+
def "main apply argocd" [
|
|
8
|
+
--host-name = "",
|
|
9
|
+
--apply-apps = true,
|
|
10
|
+
--ingress-class-name = "traefik"
|
|
11
|
+
] {
|
|
12
|
+
|
|
13
|
+
let git_url = git config --get remote.origin.url
|
|
14
|
+
|
|
15
|
+
{
|
|
16
|
+
configs: {
|
|
17
|
+
secret: {
|
|
18
|
+
argocdServerAdminPassword: "$2a$10$m3eTlEdRen0nS86c5Zph5u/bDFQMcWZYdG3NVdiyaACCqoxLJaz16"
|
|
19
|
+
argocdServerAdminPasswordMtime: "2021-11-08T15:04:05Z"
|
|
20
|
+
}
|
|
21
|
+
cm: {
|
|
22
|
+
application.resourceTrackingMethod: annotation
|
|
23
|
+
timeout.reconciliation: 60s
|
|
24
|
+
}
|
|
25
|
+
params: { "server.insecure": true }
|
|
26
|
+
}
|
|
27
|
+
server: {
|
|
28
|
+
ingress: {
|
|
29
|
+
enabled: true
|
|
30
|
+
ingressClassName: $ingress_class_name
|
|
31
|
+
hostname: $host_name
|
|
32
|
+
}
|
|
33
|
+
extraArgs: [
|
|
34
|
+
--insecure
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
} | save argocd-values.yaml --force
|
|
38
|
+
|
|
39
|
+
helm repo add argo https://argoproj.github.io/argo-helm
|
|
40
|
+
|
|
41
|
+
helm repo update
|
|
42
|
+
|
|
43
|
+
(
|
|
44
|
+
helm upgrade --install argocd argo/argo-cd
|
|
45
|
+
--namespace argocd --create-namespace
|
|
46
|
+
--values argocd-values.yaml --wait
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
mkdir argocd
|
|
50
|
+
|
|
51
|
+
{
|
|
52
|
+
apiVersion: argoproj.io/v1alpha1
|
|
53
|
+
kind: Application
|
|
54
|
+
metadata: {
|
|
55
|
+
name: apps
|
|
56
|
+
namespace: argocd
|
|
57
|
+
}
|
|
58
|
+
spec: {
|
|
59
|
+
project: default
|
|
60
|
+
source: {
|
|
61
|
+
repoURL: $git_url
|
|
62
|
+
targetRevision: HEAD
|
|
63
|
+
path: apps
|
|
64
|
+
}
|
|
65
|
+
destination: {
|
|
66
|
+
server: "https://kubernetes.default.svc"
|
|
67
|
+
namespace: a-team
|
|
68
|
+
}
|
|
69
|
+
syncPolicy: {
|
|
70
|
+
automated: {
|
|
71
|
+
selfHeal: true
|
|
72
|
+
prune: true
|
|
73
|
+
allowEmpty: true
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
} | save argocd/app.yaml --force
|
|
78
|
+
|
|
79
|
+
if $apply_apps {
|
|
80
|
+
|
|
81
|
+
kubectl apply --filename argocd/app.yaml
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
}
|
package/scripts/aso.nu
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
def --env "main apply aso" [
|
|
4
|
+
--namespace = "default"
|
|
5
|
+
--apply_creds = true
|
|
6
|
+
--sync_period = "1h"
|
|
7
|
+
--azure-tenant: string # Azure Tenant ID (optional, falls back to AZURE_TENANT env var)
|
|
8
|
+
] {
|
|
9
|
+
|
|
10
|
+
(
|
|
11
|
+
helm upgrade --install aso2 azure-service-operator
|
|
12
|
+
--repo https://raw.githubusercontent.com/Azure/azure-service-operator/main/v2/charts
|
|
13
|
+
--namespace=azureserviceoperator-system
|
|
14
|
+
--create-namespace
|
|
15
|
+
--set crdPattern='resources.azure.com/*;dbforpostgresql.azure.com/*'
|
|
16
|
+
--wait
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
if $apply_creds {
|
|
20
|
+
|
|
21
|
+
mut tenant = $azure_tenant
|
|
22
|
+
if ($tenant | is-empty) and ("AZURE_TENANT" in $env) {
|
|
23
|
+
$tenant = $env.AZURE_TENANT
|
|
24
|
+
} else if ($tenant | is-empty) {
|
|
25
|
+
error make { msg: "Azure Tenant ID required via --azure-tenant parameter or AZURE_TENANT environment variable" }
|
|
26
|
+
}
|
|
27
|
+
$"export AZURE_TENANT=($tenant)\n" | save --append .env
|
|
28
|
+
|
|
29
|
+
az login --tenant $tenant
|
|
30
|
+
|
|
31
|
+
let subscription_id = (az account show --query id -o tsv)
|
|
32
|
+
|
|
33
|
+
let azure_data = (
|
|
34
|
+
az ad sp create-for-rbac --sdk-auth --role Owner
|
|
35
|
+
--scopes $"/subscriptions/($subscription_id)" | from json
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
{
|
|
39
|
+
apiVersion: "v1"
|
|
40
|
+
kind: "Secret"
|
|
41
|
+
metadata: {
|
|
42
|
+
name: "aso-credential"
|
|
43
|
+
namespace: $namespace
|
|
44
|
+
}
|
|
45
|
+
stringData: {
|
|
46
|
+
AZURE_SUBSCRIPTION_ID: $azure_data.subscriptionId
|
|
47
|
+
AZURE_TENANT_ID: $azure_data.tenantId
|
|
48
|
+
AZURE_CLIENT_ID: $azure_data.clientId
|
|
49
|
+
AZURE_CLIENT_SECRET: $azure_data.clientSecret
|
|
50
|
+
}
|
|
51
|
+
} | to yaml | kubectl apply --filename -
|
|
52
|
+
|
|
53
|
+
{
|
|
54
|
+
apiVersion: "v1"
|
|
55
|
+
kind: "Secret"
|
|
56
|
+
metadata: {
|
|
57
|
+
name: "aso-controller-settings"
|
|
58
|
+
namespace: "azureserviceoperator-system"
|
|
59
|
+
}
|
|
60
|
+
stringData: {
|
|
61
|
+
MAX_CONCURRENT_RECONCILES: "1"
|
|
62
|
+
AZURE_SYNC_PERIOD: $sync_period
|
|
63
|
+
}
|
|
64
|
+
} | to yaml | kubectl apply --filename -
|
|
65
|
+
|
|
66
|
+
(
|
|
67
|
+
kubectl --namespace azureserviceoperator-system
|
|
68
|
+
rollout restart deployment
|
|
69
|
+
azureserviceoperator-controller-manager
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
package/scripts/atlas.nu
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env nu
|
|
2
|
+
|
|
3
|
+
# Installs the Atlas Operator for database schema migrations
|
|
4
|
+
def "main apply atlas" [] {
|
|
5
|
+
|
|
6
|
+
print $"\nInstalling (ansi yellow_bold)Atlas Operator(ansi reset)...\n"
|
|
7
|
+
|
|
8
|
+
(
|
|
9
|
+
helm upgrade --install atlas-operator
|
|
10
|
+
oci://ghcr.io/ariga/charts/atlas-operator
|
|
11
|
+
--namespace atlas-operator --create-namespace
|
|
12
|
+
--wait
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
}
|