Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

fix(whitelist): Handle empty whitelist from user gracefully#1045

Merged
kmala merged 1 commit intodeis:masterfrom
kmala:bug
Sep 8, 2016
Merged

fix(whitelist): Handle empty whitelist from user gracefully#1045
kmala merged 1 commit intodeis:masterfrom
kmala:bug

Conversation

@kmala
Copy link
Copy Markdown
Contributor

@kmala kmala commented Sep 8, 2016

fixes #1044

@deis-bot
Copy link
Copy Markdown

deis-bot commented Sep 8, 2016

@helgi, @bacongobbler and @mboersma are potential reviewers of this pull request based on my analysis of git blame information. Thanks @kmala!

@kmala kmala self-assigned this Sep 8, 2016
@kmala kmala added this to the v2.5 milestone Sep 8, 2016
Comment thread rootfs/api/models/app.py
addresses = ",".join(address for address in whitelist)
service['metadata']['annotations']['router.deis.io/whitelist'] = addresses
elif 'router.deis.io/whitelist' in service['metadata']['annotations']:
service['metadata']['annotations'].pop('router.deis.io/whitelist', None)
Copy link
Copy Markdown
Member

@bacongobbler bacongobbler Sep 8, 2016

Choose a reason for hiding this comment

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

don't we want to pop, then update it? Not sure how this is relevant for #1044

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

pop should fix deis/router#246 as i don't want to have the value empty.

@helgi helgi added the LGTM1 label Sep 8, 2016
whitelist = ArrayField(models.CharField(max_length=50), default=[])
# the default values is None to differentiate from user sending an empty whitelist
# and user just updating other fields meaning the values needs to be copied from prev release
whitelist = ArrayField(models.CharField(max_length=50), default=None)
Copy link
Copy Markdown
Member

@bacongobbler bacongobbler Sep 8, 2016

Choose a reason for hiding this comment

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

Won't this break the client since it expects an array? deis whitelist:list would break on an app with no whitelist set.

https://github.com/deis/workflow-cli/blob/master/cmd/whitelist.go#L24-L26
https://github.com/deis/controller-sdk-go/blob/master/api/appsettings.go#L25

Copy link
Copy Markdown
Contributor Author

@kmala kmala Sep 8, 2016

Choose a reason for hiding this comment

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

this is just the default value, the value saved in database will be empty array....i am doing it in update_whitelist function which is called before saving to database.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah I see what this does now. Same problem as with routable and maintenance mode... Need three values to differentiate between values unchanged (None), set and delete.

@codecov-io
Copy link
Copy Markdown

Current coverage is 86.92% (diff: 80.00%)

Merging #1045 into master will increase coverage by 0.09%

@@             master      #1045   diff @@
==========================================
  Files            42         42          
  Lines          3559       3563     +4   
  Methods           0          0          
  Messages          0          0          
  Branches        604        606     +2   
==========================================
+ Hits           3090       3097     +7   
+ Misses          309        307     -2   
+ Partials        160        159     -1   

Powered by Codecov. Last update 2f5c019...d66c20c

@kmala kmala merged commit 53871f9 into deis:master Sep 8, 2016
@kmala kmala deleted the bug branch September 8, 2016 18:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot remove whitelist

6 participants