From e1e097af65dc9f559ae79392f7ac456901a02d4b Mon Sep 17 00:00:00 2001 From: zirain Date: Sat, 29 Jun 2024 15:22:20 +0800 Subject: [PATCH 1/2] egctl: add new formula egctl is a command line tool to provide additional functionality for Envoy Gateway users, add a formula make it easier for brew users to install it. --- .github/autobump.txt | 1 + Formula/e/egctl.rb | 119 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 Formula/e/egctl.rb diff --git a/.github/autobump.txt b/.github/autobump.txt index abbbbb53a76af..46e799d8681a4 100644 --- a/.github/autobump.txt +++ b/.github/autobump.txt @@ -684,6 +684,7 @@ editorconfig-checker efl efm-langserver eg-examples +egctl eget ehco eigenpy diff --git a/Formula/e/egctl.rb b/Formula/e/egctl.rb new file mode 100644 index 0000000000000..86f07750906a9 --- /dev/null +++ b/Formula/e/egctl.rb @@ -0,0 +1,119 @@ +class Egctl < Formula + desc "Command-line utility for operating Envoy Gateway" + homepage "https://gateway.envoyproxy.io/" + url "https://github.com/envoyproxy/gateway/archive/refs/tags/v1.0.2.tar.gz" + sha256 "05406182dc165513925cf60722582613d4de9ea789d60e014e6da456bb229f65" + license "Apache-2.0" + head "https://github.com/envoyproxy/gateway.git", branch: "main" + + depends_on "go" => :build + + def install + ldflags = %W[ + -s -w + -X github.com/envoyproxy/gateway/internal/cmd/version.envoyGatewayVersion=#{version} + -X github.com/envoyproxy/gateway/internal/cmd/version.gitCommitID=#{tap.user} + ] + system "go", "build", *std_go_args(ldflags:), "./cmd/egctl" + + generate_completions_from_executable(bin/"egctl", "completion") + end + + test do + assert_equal version.to_s, shell_output("#{bin}/egctl version --remote=false").strip + + (testpath/"input.yaml").write <<~EOS + apiVersion: gateway.networking.k8s.io/v1 + kind: GatewayClass + metadata: + name: eg + spec: + controllerName: gateway.envoyproxy.io/gatewayclass-controller + --- + apiVersion: gateway.networking.k8s.io/v1 + kind: Gateway + metadata: + name: eg + namespace: default + spec: + gatewayClassName: eg + listeners: + - name: http + protocol: HTTP + port: 80 + --- + apiVersion: v1 + kind: Namespace + metadata: + name: default + --- + apiVersion: v1 + kind: Service + metadata: + name: backend + namespace: default + labels: + app: backend + service: backend + spec: + clusterIP: "1.1.1.1" + type: ClusterIP + ports: + - name: http + port: 3000 + targetPort: 3000 + protocol: TCP + selector: + app: backend + --- + apiVersion: gateway.networking.k8s.io/v1 + kind: HTTPRoute + metadata: + name: backend + namespace: default + spec: + parentRefs: + - name: eg + hostnames: + - "www.example.com" + rules: + - backendRefs: + - group: "" + kind: Service + name: backend + port: 3000 + weight: 1 + matches: + - path: + type: PathPrefix + value: / + EOS + + expected = <<~EOS + xds: + default/eg: + '@type': type.googleapis.com/envoy.admin.v3.RoutesConfigDump + dynamicRouteConfigs: + - routeConfig: + '@type': type.googleapis.com/envoy.config.route.v3.RouteConfiguration + ignorePortInHostMatching: true + name: default/eg/http + virtualHosts: + - domains: + - www.example.com + name: default/eg/http/www_example_com + routes: + - match: + prefix: / + name: httproute/default/backend/rule/0/match/0/www_example_com + route: + cluster: httproute/default/backend/rule/0 + upgradeConfigs: + - upgradeType: websocket + + EOS + + output = shell_output("#{bin}/egctl x translate --from gateway-api --to xds -t route -f #{testpath}/input.yaml") + assert_equal output, expected + end +end From 4a66129597b7cd12d81a1a5a55be02b6506ddee2 Mon Sep 17 00:00:00 2001 From: Branch Vincent <19800529+branchvincent@users.noreply.github.com> Date: Sun, 30 Jun 2024 16:45:13 +0000 Subject: [PATCH 2/2] egctl: add 1.0.2 bottle. --- Formula/e/egctl.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Formula/e/egctl.rb b/Formula/e/egctl.rb index 86f07750906a9..0dabc0b27820d 100644 --- a/Formula/e/egctl.rb +++ b/Formula/e/egctl.rb @@ -6,6 +6,16 @@ class Egctl < Formula license "Apache-2.0" head "https://github.com/envoyproxy/gateway.git", branch: "main" + bottle do + sha256 cellar: :any_skip_relocation, arm64_sonoma: "442ef19cd8d4abd3929ce289e8259b4618e915fe076a0b28cb433a83e83ee345" + sha256 cellar: :any_skip_relocation, arm64_ventura: "98026117b40295bd0dbccde6d7d5483669ed0cce00c66432712bd1631b809839" + sha256 cellar: :any_skip_relocation, arm64_monterey: "babab75268c48dd69cea1ded164a70e3c3fb63af258b488b7c6d58653f40bb60" + sha256 cellar: :any_skip_relocation, sonoma: "c39ebd95cad867bc1b8612f8ced46628f8598468258b63dd3254885733311dd4" + sha256 cellar: :any_skip_relocation, ventura: "2283eeb99931b79594b94f3c93ba50b03cb8af69643d174ce31614414b843c97" + sha256 cellar: :any_skip_relocation, monterey: "2789de921dd337393c43f85b2e808a35214f12f24f53505b8f72e31371f2f2e2" + sha256 cellar: :any_skip_relocation, x86_64_linux: "e623e4318e5e60496222dbfaee3fe4c7a6ee885d0b5875b5551ea730b87b49d5" + end + depends_on "go" => :build def install