Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable scripts to update and format packages #34

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/
yamlfmt
11 changes: 11 additions & 0 deletions .yamlfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2024 The Nephio Authors.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
formatter:
type: basic
retain_line_breaks: true
18 changes: 18 additions & 0 deletions Makefile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a Makefile?
Could we just run the yamlfmt from the main update script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, Makefile can be optional, I just thought it could be more easy to have it

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2024 The Nephio Authors.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

DOCKER_CMD ?= $(shell which docker 2> /dev/null || which podman 2> /dev/null || echo docker)

.PHONY: fmt
fmt:
sudo -E $(DOCKER_CMD) run --rm -u "$$(id -u):$$(id -g)" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to run as sudo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this depends how docker/podman was configured on the develeper's machine

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ideal but if necessary I guess can't be avoided.

-v "$$(pwd):/mnt" \
-w /mnt mvdan/shfmt -l -w -i 4 -s .
[ -f yamlfmt ] || curl -s "https://i.jpillora.com/google/yamlfmt" | bash
./yamlfmt -dstar **/*.{yaml,yml}
54 changes: 27 additions & 27 deletions distros/gcp/cc-rootsync/apply-replacements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@ metadata:
annotations:
config.kubernetes.io/local-config: "true"
replacements:
- source:
kind: ConfigMap
name: kptfile.kpt.dev
fieldPath: data.name
targets:
- select:
- source:
kind: ConfigMap
name: setters
fieldPaths:
- data.name
- source:
kind: ConfigMap
name: gcp-context
fieldPath: data.project-id
targets:
- select:
name: kptfile.kpt.dev
fieldPath: data.name
targets:
- select:
kind: ConfigMap
name: setters
fieldPaths:
- data.name
- source:
kind: ConfigMap
name: setters
fieldPaths:
- data.project-id
- source:
kind: ConfigMap
name: gcp-context
fieldPath: data.location
targets:
- select:
name: gcp-context
fieldPath: data.project-id
targets:
- select:
kind: ConfigMap
name: setters
fieldPaths:
- data.project-id
- source:
kind: ConfigMap
name: setters
fieldPaths:
- data.location
name: gcp-context
fieldPath: data.location
targets:
- select:
kind: ConfigMap
name: setters
fieldPaths:
- data.location
56 changes: 28 additions & 28 deletions distros/gcp/nephio-mgmt/cert-manager/cert-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4951,9 +4951,9 @@ metadata: # kpt-merge: /cert-manager-webhook:subjectaccessreviews
annotations:
internal.kpt.dev/upstream-identifier: 'rbac.authorization.k8s.io|ClusterRole|default|cert-manager-webhook:subjectaccessreviews'
rules:
- apiGroups: ["authorization.k8s.io"]
resources: ["subjectaccessreviews"]
verbs: ["create"]
- apiGroups: ["authorization.k8s.io"]
resources: ["subjectaccessreviews"]
verbs: ["create"]
---
# Source: cert-manager/templates/cainjector-rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -5171,10 +5171,10 @@ roleRef:
kind: ClusterRole
name: cert-manager-webhook:subjectaccessreviews
subjects:
- apiGroup: ""
kind: ServiceAccount
name: cert-manager-webhook
namespace: cert-manager
- apiGroup: ""
kind: ServiceAccount
name: cert-manager-webhook
namespace: cert-manager
---
# Source: cert-manager/templates/cainjector-rbac.yaml
# leader election rules
Expand Down Expand Up @@ -5243,15 +5243,15 @@ metadata: # kpt-merge: cert-manager/cert-manager-webhook:dynamic-serving
annotations:
internal.kpt.dev/upstream-identifier: 'rbac.authorization.k8s.io|Role|cert-manager|cert-manager-webhook:dynamic-serving'
rules:
- apiGroups: [""]
resources: ["secrets"]
resourceNames:
- 'cert-manager-webhook-ca'
verbs: ["get", "list", "watch", "update"]
# It's not possible to grant CREATE permission on a single resourceName.
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create"]
- apiGroups: [""]
resources: ["secrets"]
resourceNames:
- 'cert-manager-webhook-ca'
verbs: ["get", "list", "watch", "update"]
# It's not possible to grant CREATE permission on a single resourceName.
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create"]
---
# Source: cert-manager/templates/cainjector-rbac.yaml
# grant cert-manager permission to manage the leaderelection configmap in the
Expand Down Expand Up @@ -5323,10 +5323,10 @@ roleRef:
kind: Role
name: cert-manager-webhook:dynamic-serving
subjects:
- apiGroup: ""
kind: ServiceAccount
name: cert-manager-webhook
namespace: cert-manager
- apiGroup: ""
kind: ServiceAccount
name: cert-manager-webhook
namespace: cert-manager
---
# Source: cert-manager/templates/service.yaml
apiVersion: v1
Expand All @@ -5345,10 +5345,10 @@ metadata: # kpt-merge: cert-manager/cert-manager
spec:
type: ClusterIP
ports:
- protocol: TCP
port: 9402
name: tcp-prometheus-servicemonitor
targetPort: 9402
- protocol: TCP
port: 9402
name: tcp-prometheus-servicemonitor
targetPort: 9402
selector:
app.kubernetes.io/name: cert-manager
app.kubernetes.io/instance: cert-manager
Expand All @@ -5371,10 +5371,10 @@ metadata: # kpt-merge: cert-manager/cert-manager-webhook
spec:
type: ClusterIP
ports:
- name: https
port: 443
protocol: TCP
targetPort: "https"
- name: https
port: 443
protocol: TCP
targetPort: "https"
selector:
app.kubernetes.io/name: webhook
app.kubernetes.io/instance: cert-manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ metadata: # kpt-merge: /nephio-controller-approval-role
annotations:
internal.kpt.dev/upstream-identifier: 'rbac.authorization.k8s.io|ClusterRole|default|nephio-controller-approval-role'
rules:
- apiGroups:
- porch.kpt.dev
resources:
- packagerevisions
- packagerevisions/status
- packagerevisions/approval
verbs:
- get
- list
- watch
- patch
- update
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- config.porch.kpt.dev
resources:
- packagevariants
- packagevariants/status
verbs:
- get
- list
- watch
- apiGroups:
- porch.kpt.dev
resources:
- packagerevisions
- packagerevisions/status
- packagerevisions/approval
verbs:
- get
- list
- watch
- patch
- update
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- config.porch.kpt.dev
resources:
- packagevariants
- packagevariants/status
verbs:
- get
- list
- watch
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,44 @@ metadata: # kpt-merge: /nephio-controller-bootstrap-role
annotations:
internal.kpt.dev/upstream-identifier: 'rbac.authorization.k8s.io|ClusterRole|default|nephio-controller-bootstrap-role'
rules:
- apiGroups:
- cluster.x-k8s.io
resources:
- clusters
verbs:
- get
- list
- watch
- apiGroups:
- '*'
resources:
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- porch.kpt.dev
resources:
- packagerevisionresources
- packagerevisions
verbs:
- get
- list
- watch
- apiGroups:
- config.porch.kpt.dev
resources:
- repositories
verbs:
- get
- list
- watch
- apiGroups:
- porch.kpt.dev
resources:
- packagerevisionresources/status
- packagerevisions/status
- packagerevisions/approval
verbs:
- get
- apiGroups:
- cluster.x-k8s.io
resources:
- clusters
verbs:
- get
- list
- watch
- apiGroups:
- '*'
resources:
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- porch.kpt.dev
resources:
- packagerevisionresources
- packagerevisions
verbs:
- get
- list
- watch
- apiGroups:
- config.porch.kpt.dev
resources:
- repositories
verbs:
- get
- list
- watch
- apiGroups:
- porch.kpt.dev
resources:
- packagerevisionresources/status
- packagerevisions/status
- packagerevisions/approval
verbs:
- get
Loading