Skip to content

Commit 2147c31

Browse files
author
Michael Henderson
committed
merge 1.1.2 to main
2 parents 963498e + 3905130 commit 2147c31

38 files changed

+2150
-951
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# See GitHub's documentation for more information on this file:
2+
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
3+
version: 2
4+
updates:
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "daily"
9+
- package-ecosystem: "gomod"
10+
directory: "/"
11+
schedule:
12+
interval: "daily"

.github/workflows/keyfactor-merge-store-types.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

Makefile

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Setting SHELL to bash allows bash commands to be executed by recipes.
2+
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
3+
SHELL = /usr/bin/env bash -o pipefail
4+
.SHELLFLAGS = -ec
5+
6+
.PHONY: all
7+
all: build
8+
9+
# Required environemnt variables for the project
10+
ENV_VARS := AZURE_TENANT_ID AZURE_CLIENT_SECRET AZURE_CLIENT_ID AZURE_APP_GATEWAY_RESOURCE_ID
11+
12+
##@ General
13+
14+
# The help target prints out all targets with their descriptions organized
15+
# beneath their categories. The categories are represented by '##@' and the
16+
# target descriptions by '##'. The awk commands is responsible for reading the
17+
# entire set of makefiles included in this invocation, looking for lines of the
18+
# file as xyz: ## something, and then pretty-format the target and help. Then,
19+
# if there's a line with ##@ something, that gets pretty-printed as a category.
20+
# More info on the usage of ANSI control characters for terminal formatting:
21+
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
22+
# More info on the awk command:
23+
# http://linuxcommand.org/lc3_adv_awk.php
24+
25+
.PHONY: help
26+
help: ## Display this help.
27+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
28+
29+
##@ Development
30+
31+
.PHONY: reset
32+
reset: ## Reset the environment
33+
@echo "Resetting..."
34+
@rm -rf test.env
35+
@rm -rf .env
36+
37+
.PHONY: setup
38+
setup: ## Setup the environment for development
39+
@if [ ! -f .test.env ]; then \
40+
echo "Creating .test.env file..."; \
41+
> .env; \
42+
for var in $(ENV_VARS); do \
43+
echo -n "Enter value for $$var: "; \
44+
read value; \
45+
echo "export $$var=$$value" >> .test.env; \
46+
done; \
47+
echo ".test.env file created with input values."; \
48+
fi
49+
@if [ ! -f .env ]; then \
50+
echo "PROJECT_ROOT=$$(pwd)" >> .env; \
51+
echo "Select a project to target:"; \
52+
PS3="Enter your choice: "; \
53+
select opt in $$(ls */*.csproj); do \
54+
if [ -n "$$opt" ]; then \
55+
echo "You have selected $$opt"; \
56+
echo "PROJECT_FILE=$$opt" >> .env; \
57+
break; \
58+
else \
59+
echo "Invalid selection. Please try again."; \
60+
fi; \
61+
done; \
62+
echo "PROJECT_NAME=$$(basename $$(dirname $$(grep PROJECT_FILE .env | cut -d '=' -f 2)))" >> .env; \
63+
fi
64+
65+
.PHONY: newtest
66+
newtest: setup ## Create a new test project
67+
@source .env; \
68+
testProjectName="$$PROJECT_NAME".Tests; \
69+
echo "Creating new xUnit project called $$testProjectName"; \
70+
dotnet new xunit -o $$testProjectName; \
71+
dotnet sln add $$testProjectName/$$testProjectName.csproj; \
72+
dotnet add $$testProjectName reference $$PROJECT_FILE;
73+
74+
.PHONY: installpackage
75+
installpackage: ## Install a package to the project
76+
@source .env; \
77+
echo "Select a project to install the package into"; \
78+
PS3="Selection: "; \
79+
select opt in $$(ls */*.csproj); do \
80+
if [ -n "$$opt" ]; then \
81+
echo "You have selected $$opt"; \
82+
break; \
83+
else \
84+
echo "Invalid selection. Please try again."; \
85+
fi; \
86+
done; \
87+
echo "Enter the package name to install: "; \
88+
read packageName; \
89+
echo "Installing $$packageName to $$opt"; \
90+
dotnet add $$opt package $$packageName;
91+
92+
.PHONY: testall
93+
testall: ## Run all tests.
94+
@source .env; \
95+
source .test.env; \
96+
dotnet test
97+
98+
.PHONY: test
99+
test: ## Run a single test.
100+
@source .env; \
101+
source .test.env; \
102+
dotnet test --no-restore --list-tests | \
103+
grep -A 1000 "The following Tests are available:" | \
104+
awk 'NR>1' | \
105+
cut -d ' ' -f 5- | \
106+
sed 's/(.*//i' | \
107+
sort | uniq | \
108+
fzf | \
109+
xargs -I {} dotnet test --filter {} --logger "console;verbosity=detailed"
110+
111+
##@ Build
112+
113+
.PHONY: build
114+
build: ## Build the test project
115+
dotnet build

TestConsole/TestConsole.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Moq" Version="4.18.4" />
14+
<PackageReference Include="Moq" Version="4.20.70" />
1515
</ItemGroup>
1616

1717
</Project>

TestConsole/tests.json

Whitespace-only changes.

TestConsole/tests.yml

Whitespace-only changes.

dev_k8s_cluster/MODULE.MD

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Requirements
2+
3+
| Name | Version |
4+
|------|---------|
5+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
6+
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >=2.30 |
7+
8+
## Providers
9+
10+
| Name | Version |
11+
|------|---------|
12+
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 2.30.0 |
13+
14+
## Modules
15+
16+
No modules.
17+
18+
## Resources
19+
20+
| Name | Type |
21+
|------|------|
22+
| [kubernetes_cluster_role_binding.example](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/cluster_role_binding) | resource |
23+
| [kubernetes_namespace.keyfactor_command](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
24+
| [kubernetes_namespace.test](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
25+
| [kubernetes_secret.admin_user_token](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret) | resource |
26+
| [kubernetes_service_account.admin_user](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/service_account) | resource |
27+
| [kubernetes_namespace.dashboard](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/data-sources/namespace) | data source |
28+
29+
## Inputs
30+
31+
No inputs.
32+
33+
## Outputs
34+
35+
| Name | Description |
36+
|------|-------------|
37+
| <a name="output_admin_user_token"></a> [admin\_user\_token](#output\_admin\_user\_token) | n/a |

dev_k8s_cluster/Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.DEFAULT_GOAL := help
2+
3+
##@ Utility
4+
help: ## Display this help
5+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
6+
7+
deps: ## Install deps for macos
8+
@brew install pre-commit tflint terraform terraform-docs
9+
10+
docs: ## Run terraform-docs to update module docs.
11+
@terraform-docs markdown . > MODULE.MD
12+
@terraform-docs markdown table --output-file README.md --output-mode inject .
13+
14+
lint: ## Run tflint
15+
@tflint
16+
17+
validate: ## Run terraform validate
18+
@terraform init --upgrade
19+
@terraform validate
20+
21+
precommit/add: ## Install pre-commit hook
22+
@pre-commit install
23+
24+
precommit/remove: ## Uninstall pre-commit hook
25+
@pre-commit uninstall
26+

dev_k8s_cluster/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Docker Desktop Kubernetes Cluster
2+
This is a quick guide on how to setup a Kubernetes cluster using Docker Desktop that can be used for development purposes,
3+
and testing the Keyfactor Command Kubernetes Universal Orchestrator extension.
4+
5+
## Prerequisites
6+
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
7+
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
8+
- [helm](https://helm.sh/docs/intro/install/)
9+
- [terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli)
10+
11+
## Kubernetes Setup
12+
1. Enable Kubernetes in Docker Desktop
13+
- Open Docker Desktop
14+
- Click on the Docker icon in the system tray
15+
- Click on `Settings`
16+
- Click on `Kubernetes`
17+
- Check the box for `Enable Kubernetes`
18+
- Click `Apply & Restart`
19+
2. Configure kubectl to use the Docker Desktop Kubernetes cluster
20+
- Run the following command in a terminal
21+
```shell
22+
kubectl config use-context docker-desktop
23+
```
24+
3. Run the `setup_dashboard.sh` script to install the Kubernetes dashboard
25+
```shell
26+
./setup_dashboard.sh
27+
```
28+
4. Run the terraform code to create the necessary resources
29+
```shell
30+
terraform init
31+
terraform apply
32+
```
33+
Now the cluster is ready to be used for development and testing purposes.
34+
35+
<!-- BEGIN_TF_DOCS -->
36+
## Requirements
37+
38+
| Name | Version |
39+
|------|---------|
40+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
41+
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >=2.30 |
42+
43+
## Providers
44+
45+
| Name | Version |
46+
|------|---------|
47+
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 2.30.0 |
48+
49+
## Modules
50+
51+
No modules.
52+
53+
## Resources
54+
55+
| Name | Type |
56+
|------|------|
57+
| [kubernetes_cluster_role_binding.example](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/cluster_role_binding) | resource |
58+
| [kubernetes_namespace.keyfactor_command](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
59+
| [kubernetes_namespace.test](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
60+
| [kubernetes_secret.admin_user_token](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret) | resource |
61+
| [kubernetes_service_account.admin_user](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/service_account) | resource |
62+
| [kubernetes_namespace.dashboard](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/data-sources/namespace) | data source |
63+
64+
## Inputs
65+
66+
No inputs.
67+
68+
## Outputs
69+
70+
| Name | Description |
71+
|------|-------------|
72+
| <a name="output_admin_user_token"></a> [admin\_user\_token](#output\_admin\_user\_token) | n/a |
73+
<!-- END_TF_DOCS -->
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
client_machine_name="container_uo-11-4"
2+
kubeconfig_file="keyfactor-orchestrator-sa-context.json"
3+
4+
kfc_ca_domain="DC-CA.Command.local"
5+
kfc_ca_name="CommandCA"
6+
webserver_template="2YearTestWebServer"
7+
8+
kube_namespace="keyfactor-command"
9+
kube_tlssecr_name="tls-deployment"
10+
kube_cluster_name="docker-desktop"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Requirements
2+
3+
| Name | Version |
4+
|------|---------|
5+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
6+
| <a name="requirement_keyfactor"></a> [keyfactor](#requirement\_keyfactor) | >=2.1.11 |
7+
8+
## Providers
9+
10+
| Name | Version |
11+
|------|---------|
12+
| <a name="provider_keyfactor"></a> [keyfactor](#provider\_keyfactor) | 2.1.11 |
13+
14+
## Modules
15+
16+
No modules.
17+
18+
## Resources
19+
20+
| Name | Type |
21+
|------|------|
22+
| [keyfactor_certificate.pfx_enrollment_01](https://registry.terraform.io/providers/keyfactor-pub/keyfactor/latest/docs/resources/certificate) | resource |
23+
| [keyfactor_certificate_deployment.k8stlssecr](https://registry.terraform.io/providers/keyfactor-pub/keyfactor/latest/docs/resources/certificate_deployment) | resource |
24+
| [keyfactor_certificate_store.tls_store](https://registry.terraform.io/providers/keyfactor-pub/keyfactor/latest/docs/resources/certificate_store) | resource |
25+
| [keyfactor_agent.k8s](https://registry.terraform.io/providers/keyfactor-pub/keyfactor/latest/docs/data-sources/agent) | data source |
26+
27+
## Inputs
28+
29+
| Name | Description | Type | Default | Required |
30+
|------|-------------|------|---------|:--------:|
31+
| <a name="input_client_machine_name"></a> [client\_machine\_name](#input\_client\_machine\_name) | Name of the client machine name of the Keyfactor Command Universal Orchestrator to use. | `string` | n/a | yes |
32+
| <a name="input_default_ca_domain"></a> [default\_ca\_domain](#input\_default\_ca\_domain) | The default certificate authority domain to use in certificate generation | `string` | `"DC-CA.Command.local"` | no |
33+
| <a name="input_default_cert_ca"></a> [default\_cert\_ca](#input\_default\_cert\_ca) | The default certificate authority to use in certificate generation | `string` | `"CommandCA1"` | no |
34+
| <a name="input_kfc_ca_domain"></a> [kfc\_ca\_domain](#input\_kfc\_ca\_domain) | The default CA domain to use for the certificate | `string` | `"Keyfactor"` | no |
35+
| <a name="input_kfc_ca_name"></a> [kfc\_ca\_name](#input\_kfc\_ca\_name) | The name of the certificate authority to use for the Keyfactor Command certificate enrollments. | `string` | `"CommandCA"` | no |
36+
| <a name="input_kube_cluster_name"></a> [kube\_cluster\_name](#input\_kube\_cluster\_name) | The name of the Kubernetes cluster to use | `string` | `"dev-cluster"` | no |
37+
| <a name="input_kube_namespace"></a> [kube\_namespace](#input\_kube\_namespace) | Kubernetes namespace to store the certificate in | `string` | `"default"` | no |
38+
| <a name="input_kube_tlssecr_name"></a> [kube\_tlssecr\_name](#input\_kube\_tlssecr\_name) | The name of the Kubernetes TLS secret for the Keyfactor Command `k8s-orchestrator` extension to manage | `string` | `"kfc-k8stlssecr-deployment"` | no |
39+
| <a name="input_kubeconfig_file"></a> [kubeconfig\_file](#input\_kubeconfig\_file) | Path to the kubeconfig file | `string` | `"~/.kube/config"` | no |
40+
| <a name="input_webserver_template"></a> [webserver\_template](#input\_webserver\_template) | The webserver template to use in certificate generation | `string` | `"2YearTestWebServer"` | no |
41+
42+
## Outputs
43+
44+
No outputs.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.DEFAULT_GOAL := help
2+
3+
##@ Utility
4+
help: ## Display this help
5+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
6+
7+
deps: ## Install deps for macos
8+
@brew install pre-commit tflint terraform terraform-docs
9+
10+
docs: ## Run terraform-docs to update module docs.
11+
@terraform-docs markdown . > MODULE.MD
12+
@terraform-docs markdown table --output-file README.md --output-mode inject .
13+
14+
lint: ## Run tflint
15+
@tflint
16+
17+
validate: ## Run terraform validate
18+
@terraform init --upgrade
19+
@terraform validate
20+
21+
precommit/add: ## Install pre-commit hook
22+
@pre-commit install
23+
24+
precommit/remove: ## Uninstall pre-commit hook
25+
@pre-commit uninstall
26+

0 commit comments

Comments
 (0)