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

feat: add icp query for ingress. #4069

Merged
merged 8 commits into from Oct 11, 2023
Merged

feat: add icp query for ingress. #4069

merged 8 commits into from Oct 11, 2023

Conversation

lingdie
Copy link
Collaborator

@lingdie lingdie commented Oct 11, 2023

🤖 Generated by Copilot at 86f2bbe

Summary

🧪🇨🇳🔑

This pull request adds a new feature to the IngressValidator webhook that validates the ICP licenses of ingress rule hosts in China regions. It defines a new type IcpValidator and its methods to query and cache the ICP license information using a third-party API. It also adds new environment variables and error codes to configure and handle the ICP validation. It modifies the IngressValidator type and its methods to integrate the IcpValidator and updates the unit tests, the docker image, and the deployment manifests accordingly.

Sing, O Muse, of the IngressValidator, the mighty webhook
That guards the ingress rules of clusters in the land of China
And how it joined with the IcpValidator, the cunning querier
That checks the ICP licenses of hosts with skill and finesse

Walkthrough

  • Add a new type IcpValidator and its methods to query and cache the ICP license information of a domain name using a third-party API endpoint and a key (link)
  • Add a new field IcpValidator to the IngressValidator type and initialize it with the environment variables ICP_ENABLED, ICP_ENDPOINT, and ICP_KEY in the SetupWithManager method (link, link)
  • Modify the validate method of the IngressValidator type to use a slice of check functions that includes the checkIcp method (link)
  • Add a new method checkIcp to the IngressValidator type that checks if the ingress rule host has a valid ICP license by calling the Query method of the IcpValidator field and returns an error if the validation fails or the query encounters an error (link)
  • Add new error codes IngressFailedIcpCheck and IngressWebhookInternalError to the common.go file to indicate the ICP validation failure or the ICP query error (link)
  • Add new environment variables ICP_ENABLED, ICP_ENDPOINT, and ICP_KEY to the manager.yaml, Kubefile, and deploy.yaml.tmpl files to configure the IcpValidator field of the IngressValidator instance (link, link, link)
  • Add a new test function TestIcpValidator_Query to the icp_test.go file that tests the Query method of the IcpValidator with a sample domain name (link)

@sealos-ci-robot
Copy link
Member

sealos-ci-robot commented Oct 11, 2023

🤖 Generated by lychee action

Summary

Status Count
🔍 Total 941
✅ Successful 369
⏳ Timeouts 0
🔀 Redirected 0
👻 Excluded 571
❓ Unknown 0
🚫 Errors 0

Full action output

Full Github Actions output

@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

All modified lines are covered by tests ✅

📢 Thoughts on this report? Let us know!.

@zzjin zzjin added this to the v5.0 milestone Oct 11, 2023
@zzjin zzjin merged commit 2c6d7df into labring:main Oct 11, 2023
35 checks passed
@lingdie lingdie deleted the icp branch October 13, 2023 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants