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

Extend Cloudflare provider #456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zorkian
Copy link

@zorkian zorkian commented Mar 28, 2020

This adds support for firewall Rate Limits as well as for Page Rules in the Cloudflare provider.

This adds support for firewall Rate Limits as well as for Page Rules.
for page := 1; ; page++ {
rateLimits, resultInfo, err := api.ListRateLimits(zoneID, cf.PaginationOptions{Page: page, PerPage: 10})
if err != nil {
log.Println(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you return error, not need log in resource level


pageRules, err := api.ListPageRules(zoneID)
if err != nil {
log.Println(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


zones, err := api.ListZones()
if err != nil {
panic(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why panic if it's return error?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I was copying the other services in this provider. I assumed there were reasons beyond my understanding for this madness... :)

I can definitely make it more proper Go, tho. Gimme a day or two.

func (g *PageRulesGenerator) InitResources() error {
api, err := g.initializeAPI()
if err != nil {
panic(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why panic if it's return error?

// Getting all firewall filters
tmpRes, err := f(api, zone.ID, zone.Name)
if err != nil {
panic(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why panic if it's return error?

@sergeylanzman
Copy link
Collaborator

@zorkian Thanks for you contribution.
I wrote few comments. Can you run gofmt on this code?

@github-actions github-actions bot added the Stale label Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants