Skip to content

Commit

Permalink
feat: add cluster-name validator, update README (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Aug 4, 2022
1 parent 1ac8e49 commit 5e0966b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions catalog/gitops/configsync/Kptfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ info:
2. Manage plain KRM or manually rendered blueprints
3. Automatically apply your config changes to your Config Controller
cluster on merge

NOTE: cluster-name must not exceed 25 characters in length, as it is
included in the service account ID which has a maximum character length.
pipeline:
mutators:
- image: gcr.io/kpt-fn/apply-setters:v0.1
configPath: setters.yaml
validators:
- image: gcr.io/kpt-fn/starlark:v0.4
configPath: validation.yaml
3 changes: 3 additions & 0 deletions catalog/gitops/configsync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ After installing this blueprint, you will be able to:
3. Automatically apply your config changes to your Config Controller
cluster on merge

NOTE: cluster-name must not exceed 25 characters in length, as it is
included in the service account ID which has a maximum character length.

## Setters

| Name | Value | Type | Count |
Expand Down
1 change: 1 addition & 0 deletions catalog/gitops/configsync/setters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ metadata:
config.kubernetes.io/local-config: "true"
data:
namespace: config-control
# cluster-name must not exceed 25 characters in length
cluster-name: cluster-name
configsync-dir: config
deployment-repo: deployment-repo
Expand Down
25 changes: 25 additions & 0 deletions catalog/gitops/configsync/validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: fn.kpt.dev/v1alpha1
kind: StarlarkRun
metadata:
name: validate-cluster-name-length
annotations:
config.kubernetes.io/local-config: 'true'
source: |
for resource in ctx.resource_list["items"]:
if resource["kind"] == "IAMServiceAccount" and \
len(resource["metadata"]["name"]) > 30:
fail("cluster-name cannot exceed 25 characters in length:", \
len(resource["metadata"]["name"])-5)

0 comments on commit 5e0966b

Please sign in to comment.