How to use managed identity with Bridge to Kubernetes? - visual-studio

Has anyone managed to use managed identity with Bridge to Kubernetes?
I've been reading these articles:
https://learn.microsoft.com/en-us/visualstudio/bridge/managed-identity?view=vs-2019
https://learn.microsoft.com/en-us/visualstudio/bridge/overview-bridge-to-kubernetes
https://learn.microsoft.com/en-us/visualstudio/bridge/configure-bridge-to-kubernetes
but I cannot get this to work
enableFeatures:
ManagedIdentity
I think there may be a documentation issue because it refers to both KubernetesLocalProcessConfig.yaml and KubernetesLocalConfig.yaml
I've tried both names. If I put the above yaml in KubernetesLocalProcessConfig.yaml I get a yaml serialization error. If I put it in KubernetesLocalConfig.yaml it doesn't seem to do anything so I suspect KubernetesLocalProcessConfig.yaml is the correct name, but I can't find any details of the correct yaml other than on the "Use managed identity with Bridge to Kubernetes" page linked above.

I worked it out by decompiling the extension. It is a documentation issue.
The correct file name is indeed KubernetesLocalProcessConfig.yaml
and the below yaml will work (note the - was missing in the docs)
version: 0.1
enableFeatures:
- ManagedIdentity

Related

Validating configurations files with viper

I was looking for a configuration parser for go and https://github.com/spf13/viper seems to come highly recommended.
I am very surprised to find that configuration files are not validated by default.
Viper parses files and extracts requested values from them but I cannot find a way to detect bad configuration.
For instance I if create a (Java style) .properties file containing just "???" and nothing else. This is accepted without any error.
I can understand the philosophy that you should ignore irrelevant configuration items but I desire more rigor. I would also like to reject anything that does not match the X=Y format in a properties file.
To me this is a fatal flaw that suggests I should use a different package (or roll my own as usual).
Have I missed something? Does viper in fact support detecting and rejecting bad configuration keys?
I think the answer is no. viper does not validate java .properties files.
I posted a bug report (or feature request depending on your point of view) as https://github.com/spf13/viper/issues/790
You can try https://github.com/num30/config library which is based on Viper. It has built-in validation.

In STS 4.0 ignoring unknown property support missing

Following error shown in the problem section for unknown property
There is no easy way to fix the warning in STS4
Even after adding the quickfix, the error is not seems to be going
Description Resource Path Location Type
'IntuitAccountingAPIHost' is an unknown property. application.properties /hk-qbo-connector/src/main/resources line 8 org.eclipse.lsp4e.diagnostic
'OAuth2AppClientId' is an unknown property. application.properties /hk-qbo-connector/src/main/resources line 2 org.eclipse.lsp4e.diagnostic
'OAuth2AppClientSecret' is an unknown property. application.properties /hk-qbo-connector/src/main/resources line 3 org.eclipse.lsp4e.diagnostic
'OAuth2AppRedirectUri' is an unknown property. application.properties /hk-qbo-connector/src/main/resources line 5 org.eclipse.lsp4e.diagnostic
You should probably consider raising your problem as a bug-report or feature request on our issue tracker. It doesn't read like a 'question' to me, and so it probably doesn't belong on SO as such.
Nevertheless let me try and answer as best as I can.
Even after adding the quickfix, the error is not seems to be going
It will, once you save the additional-spring-configuration-metadata.json file where the quickfix creates new metadata for you.
I agree it is a little unintuitve that the change is not saved automatically, but I'm afraid we (STS vscode extension) don't have control over this. The changes are being applied by the Vscode language server client, and it's the client's decision to apply the changes only to 'dirty' editor buffers rather than apply them directly to the files on disk.
As to your general statement that 'In STS 4.0 ignoring unknown property support is missing'... I think you are referring to the fact that in STS3 it used to be possible to ignore problems of a given type altogether and this is no longer possible in STS4. This is true. If you like to get this kind of user-configurability back again, please consider raising a feature request on our issue tracker. SO, really isn't the place to ask for this sort of thing.
In STS 4.11, you will find this option in Window -> Preferences -> Language Servers -> Spring Language Servers -> Spring Boot Language Servers -> Yaml Editor or Properties Editor.

Location of drools-spring.xsd on git hub (or reliable source)

My project depends on drools 5.6.0.Final version. As part of that I'm trying to find a uri that I can rely for the drools-spring.xsd file. I'm trying to locate a reliable URI for that file I can reference, so that eclipses doesn't show issues, and so that spring can also intercept the requests and replace with the files in the jar as it sees fit.
I can drill into drools-spring-5.6.0.Final.jar in eclipse and see the xsd files in org.drools.container.spring. I also can see the xsd file here: http://grepcode.com/file_/repository.jboss.org/nexus/content/repositories/releases/org.drools/drools-spring/5.6.0.Final/org/drools/container/spring/drools-spring.xsd/?v=source
Going to drools.org and following their link to github and follow the rename of their group shown in the README file to https://github.com/kiegroup. I've searched this group for the xsd file(s) but have had no luck. e.g. https://github.com/kiegroup/droolsjbpm-integration/find/5.6.0.Final and https://github.com/kiegroup/drools/find/5.6.0.Final
This makes me think that the xsd files
are generated? Can someone confirm this and if so, is there a reliable URI that I can reference for this?
For some reason, the Drools' team doesn't maintain a hosted version of this schema.
Here you have an old post from Mark Proctor explaining it.
As far as I understand, they policy is still the same: do not host any .xsd file.
Hope it helps,
The drools-spring.xsd file location on drools website will give you a 404 error. You can have below two approaches which i could find while searching on the net.
One : Host the file on your local machine
Two : Place the .xsd file in the same directory as the location of the xml file referencing it.
Please refer to the below information . This will give a better understanding of the two methods mentioned above.

Documentation for old versions of Clojure java.jdbc?

The [Using java.jdbc] documentation is very sparse and the clojure.java.jdbc - JDBC-based SQL Interface 0.3.0 API documentation is only for the latest version. [I imagine the title of that last link will change when a new version is released.]
I'm using version 0.2.3 – where can I find the API documentation for that vesion? Or where can I find the info that likely would have been in the API docs for that version?
You can read the docs in the proper tagged branch in GitHub.
Table dropping in your example.
If those docs are not enough you can always refer to the properly tagged source code of that version.
I can use the following commands from a Leiningen REPL to find what seems to be the same info as shown in the API docs to which I linked in my question.
List all keys (sorted) of "... a map of the public intern mappings for the namespace.", i.e. all of the symbols defined and publicly accessible in the namespace:
my-app=>(sort (keys (ns-publics 'clojure.java.jdbc)))
(as-identifier as-key as-keyword as-named-identifier as-named-keyword ...
Show the documentation for a particular symbol:
my-app=>(doc clojure.java.jdbc/drop-table)
-------------------------
clojure.java.jdbc/drop-table
([name])
Drops a table on the open database connection given its name, a string
or keyword
nil

YAML Schema Validation?

Is there a schema validation language for YAML? I've googled but couldn't find anything useful.
Something like XSD format, using the language itself to describe the schema, would be the best choice in my case.
JSON Schema can be used with most YAML documents resulting in a more portable and better documented solution than Rx or Kwalify. JSON Schema is the only of the three for which I have been able to find editor support.
More information on using YAML and JSON Schema including tools and editor support is tracked on this page. At the time of writing, there is editor support in Visual Studio Code and a command-line based validation tool available via npm.
Full Disclosure: I authored the web site linked above to try to make the application of JSON Schema to YAML more discoverable. I also wrote an editor extension for VS Code that has since been superseded by the RedHat extension linked above.
Try Kwalify (Ruby and Java only), or Rx (many languages)
I wonder if it would make sense to reuse JSON schema for this. YAML can be easily converted to JSON without loosing any information (?), so in theory YAML could be validated by the same tool chain, allowing open source community to concentrate on one good schema tool chain. The schema itself could also be written in YAML and converted to JSON.
Good idea. Googled this up because I was looking for the same.
It's possible to convert YAML to XML in a defined manner (similarly to JSON <-> XML) and validate with a standard XML validator.
Depending on your platform, there are tools or snippets for that conversion: JavaScript (NPM), Ruby, Java (Jackson), Java (TestNG) (you'll need to see the source for what parameters it wants).
If done using an API, the error positions can even be mapped back to the original YAML file.
You can use this python ysd project to validate your yaml files. https://github.com/yonahd/ysd
Super simple to use
python yaml-validator/main.py -v yamls/example-values.yaml -r yamls/example-rules.yaml
Example rule file:
required: // field must exist and type must match
env: str
enabled: bool
replicas: int
optional: // if field exists type must match
disk: str
Example yaml file (helm values file):
network:
service:
port: 8060
enabled: true
image:
app: my-app:build
replicas: 1
env: dev
disk: local
If your project is in C++, you can also use the yaml-schema-cpp library. It allows to validate (and complete) the .yaml input files using schema files (YAML files with extension .schema) from your C++ code.

Resources