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

Unable to define target variable #454

Closed
maximejanssens opened this issue Apr 26, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@maximejanssens
Copy link

commented Apr 26, 2019

Hello, I'm currently trying to pass a variable for a target.
sqitch.conf file (initial state):

[core]
engine = snowflake
[target "Test_Stable_TSTEV3"]
uri = "db❄️//****"

I used this command:

sqitch target alter Test_Stable_TSTEV3 --set database='TSTEV3'
sqitch.conf file:
[core]
engine = snowflake
[target "Test_Stable_TSTEV3"]
uri = "db❄️//****"
[target "Test_Stable_TSTEV3.variables"]
database = "TSTEV3"

However, when I try deploying:

sqitch deploy Test_Stable_TSTEV3
Deploying changes to Test_Stable_TSTEV3

  • MOVESTATEMENT ................... Variable database is not defined

For some reason it's not recognising the variable:

sqitch target show Test_Stable_TSTEV3

  • Test_Stable_TSTEV3
    URI: db❄️***
    Registry: sqitch
    Client: /var/snowsql
    Top Directory: .
    Plan File: sqitch.plan
    Extension: sql
    Script Directories:
    Deploy: deploy
    Revert: revert
    Verify: verify
    Reworked Script Directories:
    Reworked: .
    Deploy: deploy
    Revert: revert
    Verify: verify
    No Variables

When I define the variable on command level it does pass the variable:

sqitch deploy Test_Stable_TSTEV3 --set database='TSTEV3'

Now the variable 'database' in the deploy/revert and verify scripts is replaced by TSTEV3 and everything is working fine, but I'd prefer defining it beforehand in the sqitch.conf file.
Could anybody tell me what I'm doing wrong? I've also tried creating the target and defining the variables at the same time with 'sqitch target add $target --set $key=$val -s $key2=$val2' as described in the documentation but it gives the same result.

@maximejanssens

This comment has been minimized.

Copy link
Author

commented Apr 26, 2019

Update: appearently this issue occurs when you have a capital letter in the targetname.
If I use test_stable_tstev3 it does recognise the variable
command: sqitch target show test_stable_tstev3

test_stable_tstev3
URI: db❄️***
Registry: sqitch
Client: /var/snowsql
Top Directory: .
Plan File: sqitch.plan
Extension: sql
Script Directories:
Deploy: deploy
Revert: revert
Verify: verify
Reworked Script Directories:
Reworked: .
Deploy: deploy
Revert: revert
Verify: verify
Negative repeat count does nothing at /bin/../lib/perl5/App/Sqitch/Command/target.pm line 218.
Variables:
Negative repeat count does nothing at /bin/../lib/perl5/App/Sqitch/Command/target.pm line 221.
database:TSTEV3

Still getting a weird notification
'Negative repeat count does nothing at /bin/../lib/perl5/App/Sqitch/Command/target.pm line 218.'
But it does seem to solve the issue.

@theory

This comment has been minimized.

Copy link
Collaborator

commented Apr 26, 2019

I've replicated that it can't find the variables, but not finding them lowercase. What's the command you're running in that last example? And does the target still have a name with uppercase characters, or did you change it, too? IOW, what's in your sqitch.conf file?

@theory theory self-assigned this Apr 26, 2019

@theory theory added the bug label Apr 26, 2019

@theory theory added this to the v1.0.0 milestone Apr 26, 2019

@theory

This comment has been minimized.

Copy link
Collaborator

commented Apr 26, 2019

Never mind, I figured it out. Fix forthcoming.

theory added a commit that referenced this issue Apr 26, 2019

Fix config section case sensistivity.
Config::GitLike treats sections case-insensitively, but subsections are
case-sensitive. So if a variable was added for a target named "FooBar", Sqitch
could not find it, becaues the config section was named
`target.FooBar.variables`, but the App::Sqitch::Config treated it as
`target.foobar.variables`. So add the `_skey` function to properly handle the
canonicalization of section keys, and add some tests to make sure it works
properly.

While at it, require Config::GitLike 1.15 on all platforms. It's nearly five
years old, so should be safe to require everywhere, and allows for the removal
of some legacy code and workarounds (some of which were looking for 1.08!).

Finally, fix the display spacing of variable keys and values in the output of
`target show` and `engine show`. No idea why it was looking at the spacing of
values instead of keys, but it resulted in warnings and improperly spaced
values.

Resolves #454.
@maximejanssens

This comment has been minimized.

Copy link
Author

commented Apr 29, 2019

Wasn't on my computer for the weekend so couldn't reply.

Thanks for the fix :)

theory added a commit that referenced this issue May 1, 2019

Fix config section case sensistivity.
Config::GitLike treats sections case-insensitively, but subsections are
case-sensitive. So if a variable was added for a target named "FooBar", Sqitch
could not find it, becaues the config section was named
`target.FooBar.variables`, but the App::Sqitch::Config treated it as
`target.foobar.variables`. So add the `_skey` function to properly handle the
canonicalization of section keys, and add some tests to make sure it works
properly.

While at it, require Config::GitLike 1.15 on all platforms. It's nearly five
years old, so should be safe to require everywhere, and allows for the removal
of some legacy code and workarounds (some of which were looking for 1.08!).

Finally, fix the display spacing of variable keys and values in the output of
`target show` and `engine show`. No idea why it was looking at the spacing of
values instead of keys, but it resulted in warnings and improperly spaced
values.

Resolves #454.

@theory theory closed this May 20, 2019

theory added a commit that referenced this issue May 20, 2019

Fix config section case sensistivity.
Config::GitLike treats sections case-insensitively, but subsections are
case-sensitive. So if a variable was added for a target named "FooBar", Sqitch
could not find it, becaues the config section was named
`target.FooBar.variables`, but the App::Sqitch::Config treated it as
`target.foobar.variables`. So add the `_skey` function to properly handle the
canonicalization of section keys, and add some tests to make sure it works
properly.

While at it, require Config::GitLike 1.15 on all platforms. It's nearly five
years old, so should be safe to require everywhere, and allows for the removal
of some legacy code and workarounds (some of which were looking for 1.08!).

Finally, fix the display spacing of variable keys and values in the output of
`target show` and `engine show`. No idea why it was looking at the spacing of
values instead of keys, but it resulted in warnings and improperly spaced
values.

Resolves #454.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.