-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature: CRD, Controller and Webhook For Hot News #12
Merged
werniq
merged 130 commits into
feature/operator-and-crd
from
feature/hotnews-operator-and-crd
Sep 6, 2024
Merged
Feature: CRD, Controller and Webhook For Hot News #12
werniq
merged 130 commits into
feature/operator-and-crd
from
feature/hotnews-operator-and-crd
Sep 6, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…/werniq/Go-Gator into feature/hotnews-operator-and-crd
…espace using kubebuilder annotations
…/werniq/Go-Gator into feature/hotnews-operator-and-crd
… config map is changed
…nfig_map_controller.go
…ssions. Removed redundant code from config map controller
… package from manage_sources
…/werniq/Go-Gator into feature/hotnews-operator-and-crd
…' into feature/hotnews-operator-and-crd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduce Kubebuilder Controller, CRD, and Webhook for Hot News
Overview
This pull request introduces a new Kubebuilder Controller, Custom Resource Definition, and a Validating Webhook for Retrieving news from Go-Gator Server.
This operator validates fields specified in Spec group, and constructs a URL to retrieve news within given range, with specified keywords, or from particular Feeds.
Additionally, it listens for updates in
feed-group-source
Config Map, andFeeds
CRD, and if anything was changed it is considered as changing state in HotNews.Key Changes
HotNews
Hotnews
CRD with fields for specifying arguments for news retrievalHotNews.Spec
grouptitlesCount
to 10, and validating webhook to verify that date range is valid (dateStart
is beforedateEnd
), either feeds orfeedGroups
are specified, and iffeedGroups
were specified, they are valid.Details
Controller: Implemented logic to retrieve latest news. The controller has a
Reconcile
function, which is triggered when Feed is created, updated or deleted. Also, theReconcile
func is called when we have updates infeed-group-source
config map, or updates withFeeds
CRD, if it is associated with HotNews.Spec.FeedsCustom Resource Definition: Defines the schema for a HotNews resource, which includes the fields required for fetching news like
keywords
,dateStart
ordateEnd
.Mutating Webhook: A mutating webhook which sets following values by default:
status.articlesTitles
, is set to 10Validating Webhook: A validating webhook which checks for:
HotNews
date range is valid -dateStart
should be beforedateEnd
feedGroups
are valid (e.g. exist infeed-group-source
)Example:
![image](https://private-user-images.githubusercontent.com/73220736/357856934-4bb958e3-d3e3-41aa-a290-6064d6cb6c0f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MDM4NjYsIm5iZiI6MTczOTcwMzU2NiwicGF0aCI6Ii83MzIyMDczNi8zNTc4NTY5MzQtNGJiOTU4ZTMtZDNlMy00MWFhLWEyOTAtNjA2NGQ2Y2I2YzBmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDEwNTkyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlmMWQ3N2VlMGQ4ODNkNDhhYmQ0OWNiYjZkY2VkNTIyZDZmNmMzMTc0ZmNmNjAyN2YwYmRhMWQyODdlMjE1YjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Jp6tNP7VSVeWIPe2gYDF4c-s3VAgW1nX0ckGrNFwKqY)
![image](https://private-user-images.githubusercontent.com/73220736/357857016-4521987b-bb3c-433b-b99a-65483b704e95.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MDM4NjYsIm5iZiI6MTczOTcwMzU2NiwicGF0aCI6Ii83MzIyMDczNi8zNTc4NTcwMTYtNDUyMTk4N2ItYmIzYy00MzNiLWI5OWEtNjU0ODNiNzA0ZTk1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDEwNTkyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThkMzBkZWZlZGMwOWU0OWM3M2Q2MDA3N2NkMmEyOGJkOTdhN2IyZjY3YWFlNjgzMGM4ZGZkZTk0YTZhNDBjZWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.FSMQOsbmKT1zqIjTQaKc19td_lJJu2Fw0Un3tm_rn8A)
Result:
![image](https://private-user-images.githubusercontent.com/73220736/357857057-1e3f991c-f024-4ed5-a592-afa25a8eb1f5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MDM4NjYsIm5iZiI6MTczOTcwMzU2NiwicGF0aCI6Ii83MzIyMDczNi8zNTc4NTcwNTctMWUzZjk5MWMtZjAyNC00ZWQ1LWE1OTItYWZhMjVhOGViMWY1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDEwNTkyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBhNGM1OGVlM2VkY2ZjNTg0NmJlN2FhMjUyYmEwYzc5OTllZmU0ZWRmMGM5MmYzYWY2NTU3OTBhMmQ0OWMwNmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ogiseZrs5NKUM4aqUar_qJA3fkz774jQjFNkveHgtWQ)
Config Map Data:
![image](https://private-user-images.githubusercontent.com/73220736/357857240-aff44a39-e3d9-4b25-983d-8b4daf028287.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk3MDM4NjYsIm5iZiI6MTczOTcwMzU2NiwicGF0aCI6Ii83MzIyMDczNi8zNTc4NTcyNDAtYWZmNDRhMzktZTNkOS00YjI1LTk4M2QtOGI0ZGFmMDI4Mjg3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDEwNTkyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE2NDRiZjRjZmFmOWQwY2VkY2NjMTQzMWE3YjgzZjFiNmUxODAwNDFhNTI3MmVjMTVhMTc4NDFmYzNmNjI2YmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.fD32DHbn1nP1ZGlmMe7Y7QcA3dpmu5qI1fmOPPS_eyI)
Pull Request Template
Checklist before submitting a PR for a review