Jq to get all objectnames from a json file - jq

I have a json file like below. how can i get servicename1 vsads and its dependences using jq
ServiceName1:
VSAD1:
Dependent service1
Dependent service2
VSAD2:
Dependent service3
Dependent service4
ServiceName2:
VSAD:
Depenedent service1
Dependent service2
Thanks

Related

How to allow the user to override a subset of the configuration using their own yaml file?

Let's say I have this basic app:
from dataclasses import dataclass
import hydra
from hydra.core.config_store import ConfigStore
#dataclass
class MyAppConfig:
req_int: int
opt_str: str = "Default String"
opt_float: float = 3.14
cs = ConfigStore.instance()
# Registering the Config class with the name 'config'.
cs.store(name="base_config", node=MyAppConfig)
#hydra.main(version_base=None, config_name="base_config", config_path="conf")
def my_app(cfg: MyAppConfig) -> None:
print(cfg)
if __name__ == "__main__":
my_app()
Is it possible for the user to be able to call my app like this:
python my_app.py req_int=42 --config="~/path/to/user-defined-config.yaml"
And user-defined-config.yaml would contain only this:
opt_str: User Config String
The output should look like this:
{'req_int': 42, 'opt_str': 'User Config String', 'opt_float': 3.14, 'config': 'hydra-user-conf'}
The closest I got to that is:
user-defined-config.yaml
defaults:
- base_config
- _self_
opt_str: User Config String
And the invocation:
python hydra/app.py req_int=42 --config-path='~/path/to' --config-name="hydra-user-conf"
But this way the user (who I don't want to require to be familiar with hydra) has to specify the path to their config file via two cli arguments and also include the defaults section in their config, which would be redundant boilerplate to them if they have to always include it in all of their configuration files.
Is this the closest I can get with hydra to the desired interface?
One thing you can do is to pre-configure the config searchpath in the primary config. Adding something like ~/.my_app/ to your config searchpath (thus potentially eliminating the need for --config-path|-cp.
In yaml it would look like:
hydra:
searchpath:
- file://${oc.env:HOME}/.my_app
Another thing to consider is having the app generating an initial config for the user on demand. I took this approach with Configen.
In general, the current patterns are not amazing and maybe there is room for some improvements in Hydra to make this more ergonomic (You can open a discussion about it).

Airflow KubernetesPodOperator: pass securityContext parameter

Anyone could give me an example on passing some parameters as "runAsNonRoot" when creating a pod through KubernetesPodOperator?
I've tried to dig through the documentation but it is not clear.
At current this does not appear to be supported in the operator.
You can see that the KubePodOp has an init that makes a PodGenerator. It then adds all the volumes and mounts to it before generating. This does not at any point call the only method in which you could pass a SecurityContext add_init_containerwhose documentation appears to have been cut off mid sentence.
You can create pods through KubernetesPodOperator such as in python format. Here is the list of all parameters you can pass through KubernetesPodOperator.
I could not find a specific example on how to pass this "runAsNonRoot" parameters through KubernetesPodOperator. In YAML format, pod security parameters are defined as following:
spec:
containers:
# specification of the pod’s containers
# ...
securityContext:
readOnlyRootFilesystem: true
runAsNonRoot: true
You can pass a dictionary to the KubernetesPodOperator constructor with the following content:
security_context = {"runAsNonRoot": True}
You can look up the keys and value datatypes that you can pass via this dict in class "V1SecurityContext" and the linked classes (/python3.6/site-packages/kubernetes/client/models/v1_security_context.py).

Alice Bundle : dynamic entity loop parameter

I use Hautelook AliceBundle which use Faker to generate fixtures with real world data.
In Alice, we can use parameters in our YAML file like below:
parameters:
pwd_parameter: anything
My\UserEntity:
#generate 10 users with password equals to my parameter
user_{1..10}:
password: '<{pwd_parameter}>'
Is it possible to use parameters to generate dynamic numbers of fixtures?
The solution I am looking for is to do this:
parameters:
pwd_parameter: anything
nb_users: 10
My\UserEntity:
#generate nb_users users with password equals to my parameter
user_{1..nb_users}: #<---THIS IS THE PROBLEM
password: '<{pwd_parameter}>
I tried:
user_{1.. nb_users }
user_{1.. <nb_users> }
user_{1..<{nb_users}> }
user_{1..<{nb_users}> }
which throws:
Warning: array_merge(): Argument #1 is not an array
How can I generate my number of entities dynamically?
It is not possible to do something like that since fixtures yaml configuration files do not get merged with symfony parameters.
Nelmio\Alice\Fixtures\Fixture\RangeName is the class used to validate and parse configuration from your example.
Take a look at RangeName::canBuild() and you'll see regular expression that validates yaml key.
You could create your own Builder Method that would randomize number of fixture rows inserted.

Robot Framework: Populating parameters based off of a robot.properties file?

I am attempting to mock-up a 'robot.properties' file to be utilized within my test cases with the Robot Framework. Inside my robot.properties file it contains things like for example:
project.username=stackoverflow
inside my test case file I have tried several times to 'import' the robot.properties file via adding within Settings: Resource ../path/to/properties and etc (see directory structure below), but when I attempt to pass 'project.username' as an argument to a test it passes it as the literal string value 'project.username' and not the value 'stack overflow'. I am new to Robot, I have implemented this in other languages like Java/C#, but I fully assume that the import is preventing me from accessing my value. Any help would be greatly appreciated, unfortunately this way of driving testing isn't really referenced much online that I can find.
Dir Structure:
Tests/Acceptance/MyTestCase.robot
Tests/robot.properties
If I try Library ../robot.properties I get:
"Import by filename is not supported"
If I try Resource ../robot.properties I get:
"Unsupported file format .properties"
Robot framework doesn't support a ".properties" file.
One solution is to use a variable file, which lets you define variables in python. Since you want to use dot notation, one way is to create a class and define your variables as properties of the class. The variable file can then make an instance of that class as a variable, and you can use extended variable syntax to access the variables.
The advantage to using a variable file over a plain text file is that you can create variables dynamically by calling other python functions. As a simple example, you could create a variable called "now" that contains the current date, or "host" that is the hostname of the machine running the test.
Example:
properties.py
import platform
class Properties(object):
username = "stackoverflow"
password = "SuperSecret!"
hostname = platform.uname()[1]
properties = Properties()
example.robot
*** Settings ***
Variables properties.py
Suite Setup log running on ${properties.hostname}
*** Test Cases ***
Example
should be equal ${properties.username} stackoverflow

How to use a global config value in a private config file with symfony2

I defined some values in the define.yml in the app/config folder.
And I can access then in the PHP code.
Now I want to use the validate.yml file to check weather users give out too many data, could I use the configed valus in the config file(such as %maxInputLength%) rather than write it one more time in the
validate.yml?
for a example:
I defind a variable in define.yml:
maxLength: 10
So we can use it in the controller.
But if I want to use it in the validate.yml in my own bundle,
such as : myBandle/config/validation.yml
Now I just use the file like that:
myBundle\Entity\UserDesc:
properties:
content:
- NotBlank: ~
- MaxLength: 10
So it seems that the same value was defined at two place.In fact the 10 in the second file is just the value defined in the first file . But I don't know how to get the value from the first file.Is there any way to make that?
AFAIK you want to set value to variable in one config file and then reuse it in other .yml config file.
So you cant define some vars in e.g variables.yml file
parameters:
test_variable: "blabla"
Then in second .yml config file you can import file with defined variables:
imports:
- { resource: variables.yml }
Then you can use imported variable in this file:
property:
some_value: %test_variable%

Resources