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

[BUG] in vhosts/standard.sls the map.pop affects the apache variable as well because it is a reference, not a copy #377

Open
doubletwist13 opened this issue Jan 4, 2022 · 3 comments
Labels

Comments

@doubletwist13
Copy link

Your setup

Formula commit hash / release tag

apache-formula 1.2.2

Versions reports (master & minion)

          Salt: 3004
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: unknown
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: 0.6.4
     gitpython: 1.0.1
        Jinja2: 2.11.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.8 (default, Nov 18 2021, 10:07:16)
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 17.0.0
         smmap: 0.9.0
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.1.4
 
System Versions:
          dist: oracle 7.9 
        locale: UTF-8
       machine: x86_64
       release: 5.4.17-2136.302.6.1.el7uek.x86_64
        system: Linux
       version: Oracle Linux Server 7.9 

Pillar / config used

apache:
  sites:
    example.com_redirect:
      port: '80'
      ServerName: example.com
      RedirectSource: '/'
      RedirectTarget: 'https://example.com'
    example.com_ssl:
      port: '443'
      ServerName: example.com
      DocumentRoot: /path/to/webroot
        

Bug details

Describe the bug

In apache/config/vhosts/standard.sls lines 8-11 attempt to make a copy of the 'apache' variable to 'map' and then trim to only include the 'sites' data but instead of making a copy it just makes a reference. This causes the map.pop to trim the 'apache' variable as well as the 'map' variable.

Steps to reproduce the bug

Expected behaviour

map.pop should trim only the 'map' variable, not the 'apache' variable.

Attempts to fix the bug

Just need to tell it to copy the variable instead of creating a reference by changing from:

{%- set map = apache %}
{%- do map.pop('sites', None) %}

TO

{%- set map = apache.copy() %}
{%- do map.pop('sites', None) %}

Additional context

@myii
Copy link
Member

myii commented Jan 5, 2022

@doubletwist13 Thanks for the report. That change was provided in 1f488b6. @ixs, would you be able to respond to this?

@ixs
Copy link
Contributor

ixs commented Jan 5, 2022

Yeah, this looks good. Thank you @doubletwist13 for the good description and digging.
Reference vs. copy is exactly what's going on.

I'll whip up a PR to fix this issue now.

@doubletwist13
Copy link
Author

Just checking in. I didn't see a PR for this and it looks like the error still exists in the master branch.

I could maybe do a PR - as long as the change doesn't require any changes to tests - as that's a bit beyond my current ability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants