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

egctl 1.0.2 (new formula) #175940

Merged
merged 2 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/autobump.txt
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ editorconfig-checker
efl
efm-langserver
eg-examples
egctl
eget
ehco
eigenpy
Expand Down
119 changes: 119 additions & 0 deletions Formula/e/egctl.rb
Original file line number Diff line number Diff line change
@@ -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
chenrui333 marked this conversation as resolved.
Show resolved Hide resolved

(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
Loading