Skip to content

Commit

Permalink
Merge branch 'main' into namespacedcrds
Browse files Browse the repository at this point in the history
  • Loading branch information
fedepaol committed Mar 30, 2022
2 parents 0bc043c + 4599096 commit c0b0aa8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 25 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions/setup-go@v2
with:
go-version: '1.17.1'

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install python3-pip arping ndisc6
sudo pip3 install invoke semver pyyaml
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.7.0
- uses: actions/setup-go@v2
with:
go-version: '1.17.1'

- name: Unit Tests
run: |
inv test
Expand All @@ -44,6 +45,10 @@ jobs:
inv checkpatch
inv lint -e host
inv verifylicense
inv gomodtidy
inv checkchanges --action="run inv gomodtidy"
inv generatemanifests
inv checkchanges --action="run inv generatemanifests"
helm:
runs-on: ubuntu-20.04
Expand Down
1 change: 1 addition & 0 deletions config/frr/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ resources:
- frr-cm.yaml
patchesStrategicMerge:
- speaker-patch.yaml
namespace: metallb-system
4 changes: 1 addition & 3 deletions config/native/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Adds namespace to all resources.
namespace: metallb-system

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ns.yaml
- ../crd
- ../rbac
- ../controllers
namespace: metallb-system
49 changes: 31 additions & 18 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,29 +252,12 @@ def validate_kind_version():
if delta < 0:
raise Exit(message="kind version >= {} required".format(min_version))

@task(help={
"controller_gen": "KubeBuilder CLI."
"Default: controller_gen (version v0.7.0).",
"crd_options": "CRD Options."
"Default: crd:crdVersions=v1.",
"kustomize_cli": "YAML files customization CLI."
"Default: kustomize (version v4.4.0).",
"bgp_type": "Type of BGP implementation to use."
"Supported: 'native' (default), 'frr'",
"namespace": "MetalLB deployment namespace."
"Default: 'metallb-system'.",
"output": "Optional output file name for generated manifest.",
})
def generate_manifest(ctx, controller_gen="controller-gen", crd_options="crd:crdVersions=v1",
kustomize_cli="kustomize", bgp_type="native", namespace="metallb-system", output=None):
kustomize_cli="kustomize", bgp_type="native", output=None):
res = run("{} {} rbac:roleName=manager-role webhook paths=\"./api/...\" output:crd:artifacts:config=config/crd/bases".format(controller_gen, crd_options))
if not res.ok:
raise Exit(message="Failed to generate manifests")

res = run("cd config/{} && {} edit set namespace {}".format(bgp_type, kustomize_cli, namespace))
if not res.ok:
raise Exit(message="Failed to set manifests namespace")

if output:
res = run("kubectl kustomize config/{} > {}".format(bgp_type, output))
if not res.ok:
Expand Down Expand Up @@ -744,3 +727,33 @@ def verifylicense(ctx):
print("{} is missing license".format(file))
if no_license:
raise Exit(message="#### Files with no license found.\n#### Please run ""inv bumplicense"" to add the license header")

@task
def gomodtidy(ctx):
"""Runs go mod tidy"""
res = run("go mod tidy", hide="out")
if not res.ok:
raise Exit(message="go mod tidy failed")

@task(help={
"controller_gen": "KubeBuilder CLI."
"Default: controller_gen (version v0.7.0).",
"kustomize_cli": "YAML files customization CLI."
"Default: kustomize (version v4.4.0).",
})
def generatemanifests(ctx, controller_gen="controller-gen", kustomize_cli="kustomize"):
""" Re-generates the all-in-one manifests under config/manifests"""
generate_manifest(ctx, controller_gen=controller_gen, kustomize_cli=kustomize_cli, bgp_type="frr", output="config/manifests/metallb-frr.yaml")
generate_manifest(ctx, controller_gen=controller_gen, kustomize_cli=kustomize_cli, bgp_type="native", output="config/manifests/metallb-native.yaml")


@task(help={
"action": "The action to take to fix the uncommitted changes",
})
def checkchanges(ctx, action="check uncommitted files"):
"""Verifies no uncommitted files are available"""
res = run("git status --porcelain", hide="out")
if res.stdout != "":
print("{} must be committed".format(res))
raise Exit(message="#### Uncommitted files found, you may need to {} ####\n".format(action))

0 comments on commit c0b0aa8

Please sign in to comment.