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

RuntimeConfig: Unable to retrieve "text" value of the Variable #1

Closed
mstal opened this issue Aug 10, 2018 · 1 comment · Fixed by #17
Closed

RuntimeConfig: Unable to retrieve "text" value of the Variable #1

mstal opened this issue Aug 10, 2018 · 1 comment · Fixed by #17
Assignees
Labels
api: runtimeconfig Issues related to the googleapis/python-runtimeconfig API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@mstal
Copy link

mstal commented Aug 10, 2018

Description

The runtimeconfig.v1beta1.variable needs to be updated with "text" property so users will be able to access the text value.

Steps to reproduce with code samples

For creating the config with the name of my-config
gcloud beta runtime-config configs create my-config

For creating the key value pair, key is "some-gibberish" and value is "hahahablblblbl"
gcloud beta runtime-config configs variables set some-gibberish \
'hahahablblblbl' --config-name my-config

Now enter the Python command line by typing 'python' in the terminal and then hit enter.
Run following simple Python snippet

from google.cloud import runtimeconfig
client = runtimeconfig.Client()
config = client.config('my-config')
var = config.get_variable('some-gibberish')

Expected output:
>>> var.value

But what if we don't need the base64 encoding option given in the documentation?

So we're going to change this gcloud command to store the value of "some-gibberish" as text
gcloud beta runtime-config configs variables set some-gibberish \
'hahahablblblbl' --config-name my-config --is-text

Exit the python command line

Run the gcloud command with --is-text flag

Go to the python command line again, execute the simple Python snippet from earlier.

Output for var.value
>>> var.value
>>>

Output for var.text
>>> var.text
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Variable' object has no attribute 'text'
>>>

Effect

For now this would mean that there's no way to retrieve the text values in Python which would force users to store everything as base64 encoded values.

@tseaver
Copy link
Contributor

tseaver commented Aug 20, 2018

Per the API doc for variables, text is indeed an alternate to value as bytes.

@busunkim96 busunkim96 transferred this issue from googleapis/google-cloud-python Feb 4, 2020
@product-auto-label product-auto-label bot added the api: runtimeconfig Issues related to the googleapis/python-runtimeconfig API. label Feb 4, 2020
@busunkim96 busunkim96 added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Feb 4, 2020
software-dov pushed a commit that referenced this issue Jun 5, 2020
This PR adds support for variable create and update methods.

The create method has been implemented in the Variable class instead of Config (which would have given symmetry with get_variable) for a couple of reasons:

it allows a more natural workflow of calling config.variable(), setting the desired attribute, then saving
it updates the created variable in place via _set_properties like other variable methods
This also adds support for the text attribute, which can now be used in alternative to the previously supported value. The create and update methods enforce mutual exclusivity of the two attributes.

Fixes #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: runtimeconfig Issues related to the googleapis/python-runtimeconfig API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants