Automate inclusion of Git submodules based on JSON file - json

This question may be too open-ended for Stack Overflow, but I'm getting nowhere on my own. I am looking for a way to use automate the use of designated Git submodules based on values in a text file. My company generates a lot of projects, but we reuse a lot of code. We use submodules and tags for this, but the volume is starting to get unwieldy.
I was thinking it would make sense to use something similar to an NPM packages.json file. Maybe like this:
{
"name": "Custom Development Components",
"description": "Reusable objects to increase the efficiency and quality of custom development",
"components": [
{
"name": "stats",
"description": "Statistics",
"URL": "https://my.git.repo/Statistics",
"folder-name": "STATS",
"version": "^"
},
{
"name": "standard",
"description": "Standard",
"URL": "https://my.git.repo/Standard",
"folder-name": "STANDARD",
"version": "X"
},
{
"name": "helpers",
"description": "Helper Objects and Scripts",
"URL": "https://my.git.repo/Helpers",
"folder-name": "HELPERS",
"version": "^"
}
]
}
But I haven't been able to figure out how to parse the JSON and turn it into Git commands. I've fiddled around with using JQ in a Windows batch file (we're all working in Windows environments), but I haven't gotten very far with it. Basically, I'm looking to be able to step through the JSON, find components where the version is a string other than ^ (which may or may not be a specific tag), and import the URL for the submodule.
Any guidance here would be appreciated.

just use something like this this:
$ jq -r < /tmp/o '.components[] | select( .version != "^" ) | "git submodule init \(.URL):\(.version)"'
git submodule init https://my.git.repo/Standard:X
I'm not much versed in the bat language, but you may have some luck with:
https://superuser.com/questions/652492/windows-equivalent-to-xargs

Related

How do you create custom settings for a vs code extension?

I have been researching for hours but to no avail.
Pretty much all VsCode extensions will have custom made settings, and they show up in the default settings json file like this from the Red Hat Java extension:
"java.dependency.showOutline": true,
I'm trying to write my own extension and I have found a lot of useful stuff, I can create custom themes, snippets, commands, etc. and it's all well documented on the VsCode API site, but I need to create custom user-defined settings, and I cannot find ANYWHERE that explains how to do so. Does anyone know?
This is done using contribution points, JSON declarations in the contributes field of your extension's package.json file.
You want the configuration contribution point.
For example:
// package.json
{
"contributes": {
"configuration": {
"title": "",
"properties": {
"scope.name": {
"type": "",
"default": "",
"description": ""
}
}
}
}
}
Then you can read those values using
vscode.workspace.getConfiguration('your-extension-name')

Deploying ARM template with 2 hostnamebindings returns conflict error can't modify because another operation is in progress

I am trying to deploy an ARM template through Azure DevOps. I've tried doing a test deployment (Test-AzResourceGroupDeployment) through PowerShell without any issues.
This issue has persisted for several weeks, and i've read some posts stating it dissapeared after a few hours or after a day, however this has not been the case for me.
In Azure DevOps my build is succeeding just fine. But when i try to create a release through my release pipeline using the resource "Azure resource group deployment" it will fail stating the error:
"Code": "Conflict",
"Message": "Cannot modify this site because another operation is in progress. Details: Id: 4f18af87-8848-4df5-82f0-ec6be47fb599, OperationName: Update, CreatedTime: 9/27/2019 8:55:26 AM, RequestId: 691b5183-aa8b-4a38-8891-36906a5e2d20, EntityType: 3"
Update
I have later noticed that the error surfaces when trying to deploy my hostNameBindings for the site.
I have 2 different hostNameBindings in my template which causes the failure.
It fails apparently because it tries to deploy both of them at the same time, though i am not aware of an apparent fix for this so any help would still be appreciated!
I tried to use the copy function but as far as i know that will make an exact copy for both hostNameBindings which is not what i need. first of all they have different names and properties, anyone got a fix for this?
Make the one hostNameBindings depend on the other host name binding. Then they will be executed 1 after another and you should not get the same error message.
"dependsOn": [
"[resourceId('Microsoft.Web/sites/', variables('websitename'))]",
"[resourceId('Microsoft.Web/sites/hostNameBindings/',variables('websitename'), variables('firstbindingame-aftertheslash-sowithoutthewebsitename'))]"
],
Look like people already notice this issue and trying to fix it.
https://status.azure.com/
I had the same issue when using the Copy function in order to add multiple Custom Domains. Thanks to David Gnanasekaran's blog I was able to fix this issue.
By default the copy function will execute in parallel. By setting the mode to serial and setting the batchSize to 1 I did not receive any operation is in progress errors.
Here is my piece of ARM template to set the custom domains.
"copy": {
"name": "hostNameBindingsCopy",
"count": "[length(parameters('customDomainNames'))]",
"mode": "Serial",
"batchSize": 1
},
"apiVersion": "[variables('webApiVersion')]",
"name": "[concat(variables('webAppName'), '/', parameters('customDomainNames')[copyIndex()])]",
"type": "Microsoft.Web/sites/hostNameBindings",
"kind": "string",
"location": "[resourceGroup().location]",
"condition": "[greater(length(parameters('customDomainNames')), 0)]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('webAppName'))]"
],
"properties": {
"customHostNameDnsRecordType": "CName",
"hostNameType": "Verified",
"siteName": "parameters('webAppName')"
}

Azure Functions: How do I control development/production/staging app settings?

I've just started experimenting with Azure functions and I'm trying to understand how to control the app settings depending on environment.
In dotnet core you could have appsettings.json, appsettings.development.json etc. And as you moved between different environments the config would change.
However from looking at Azure function documentation all I can find is that you can set up config in the azure portal but I can't see anything about setting up config in the solution?
So what is the best way to manage build environment?
Thanks in advance :-)
The best way, in my opinion, is using a proper build and release system, like VSTS.
What I've done in one of my solutions is creating an ARM template of my Function App and deploy this using a release pipeline with VSTS RM.
This way you can just add a value to the template.json, like the one from below.
"appSettings": [
// other entries
{
"name": "MyValue",
"value": "[parameters('myValue')]"
}
You will need another file, called parameters.json which will hold the values. This file looks like so (at the moment).
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {},
"storageName": {},
"location": {},
"subscriptionId": {}
}
}
Back in VSTS you can just change/override the values of these parameters in the portal.
By using such a workflow you will get a professional CI/CD implementation where no one has to bother themselves with the actual secrets. They are only known to the system administrators.

i don't know what's wrong it gives me Manifest is not valid JSON. Line: 1, column: 1, Unexpected token what do i do

i am running it on sublime text 3 it is for a project that i am working on its a chrome extension, I have searched a bit on youtube but i don't know what to do.
{
"manifest_version" : 2,
"name": "DJ_Khaled",
"version": "1.0",
"description": "This is a test extension",
"browser_action": {
"defualt_icon": "icon.png"
}
}
When you have a trouble like the best way to fix it is to copy/paste it in a linter.
Generically, lint or a linter is any tool that flags suspicious usage in software written in any computer language.
You can find a lot of the online. For you problem, try with JsonLint.com.
Since your are using SublimeText, you can use a plugin for this purpose too.
source

Kibana/ElasticSearch dashboard json schema definition

We've been using Kibana/ElasticSearch to analyze our logs for a bit and I'm trying to understand the dashboard definitions a bit. When I export a dashboard and inspect the resulting file, I can see that it's json. As such, I can manipulate it by hand and one thing I've found helpful is to add custom attributes for comments to my filters. e.g.
"2": {
"_filter_comment": "comment justifying this filter",
"type": "field",
"field": "msg",
"query": "\"something I want to filter\"",
"mandate": "mustNot",
"active": true,
"alias": "",
"id": 2
},
This then allows me to see the comment in Kibana. Playing with the json, I've been able to learn some more helpful tips, but I'd prefer to go to the "source" (a.k.a. docs) assuming such a thing exists to expedite my understanding. One specific feature that I'd love to get a better understanding of is how to use regexes in my filters. Does such a "source" exist, and if so can someone direct me to it?
The only documentation that I found is the one that they have in the folder docs in their Github repo. At the moment, I do not think that there is more docs provided by them, as I mention in this question.