Tanka - VS Code - "Unexpected type string" while getting namespace from spec file - visual-studio-code

I'm trying out Tanka for k8s configs generation. Also, I'm using VS Code extension by Grafana Labs.
I've problems in VS Code with referencing Tanka configuration as described here. I'm using configuration to retrieve namespace, like so:
local k = import 'k.libsonnet';
local tk = import 'tk';
{
namespace: k.core.v1.namespace.new(tk.env.spec.namespace),
}
Initially, I was receiving an error: RUNTIME ERROR: Undefined external variable: tanka.dev/environment. I supposed that Tanka wants path to my environment, and so added it to VS Code settings:
{
"jsonnet.languageServer.extVars": {
"tanka.dev/environment": "environments/default"
}
}
Now I'm receiving another error in the k.core.v1.namespace.new(tk.env.spec.namespace) expression:
RUNTIME ERROR: Unexpected type string, expected number
<path to repo>/environments/default/main.jsonnet:7:38-49
<path to repo>/vendor/github.com/jsonnet-libs/k8s-libsonnet/1.25/_gen/core/v1/namespace.libsonnet:51:35-39 thunk from <function <anonymous>>
<path to repo>/vendor/github.com/jsonnet-libs/k8s-libsonnet/1.25/_gen/core/v1/namespace.libsonnet:33:42-46 object <anonymous>
Field "name"
Field "metadata"
Field "namespace"
During manifestation
The error is quite confusing to me. What and where expects number?
both namespace and name are strings in my spec.json
according to the same configuration docs they should be strings
on line 33 of namespace.libsonnet there is a function withName which expects name argument of type d.T.string
tk works fine from the CLI
I suppose that I've set wrong tanka.dev/environment, but I can't find docs that say what should be set there.
Also, just to check if it helps, I tried setting "jsonnet.languageServer.tankaMode": true in VS Code settings to no avail.
Please, help me to resolve the error and if possible explain what's going on here.

Related

giter8 escape with '\$'

I'm developing giter8 templates for Scala project.
All the templates were running as expected. However, today I faced with error:
Exiting due to error in the template: /var/folders/zg/dspycv2d6sqc92801kmqy3yw0000gn/T/giter8-75157374435862
relative: $name__norm$/src/main/resources/prod-application.conf, toPath: /Users/***/., An unexpected error occurred while processing the template. Check that all literal '$' are properly escaped with '\$'
mentioned file is as follows:
akka {
discovery {
method = akka-dns
kubernetes-api {
pod-namespace = \${SERVICE_NAMESPACE}
pod-label-selector = "app=$name;format="norm"$"
pod-port-name = management
}
I tried different options of $ escaping. I even deleted all the text and tried to build a template but I still receive the same error with pointing to the same file.
Does anyone know possible way to solve this?

Specify injection order of user-defined monitor files in apama_project

Can an apama_project specify the injection order of user-defined types?
It appears the engine_deploy does not automatically resolve the user-defined dependency graph.
Using the apama_project tool, I have setup a project with two *.mon files. 1.mon depends on an event definition in 2.mon.
TestProject
|-.dependencies
...
|-events
|-monitors
| |-1.mon // depends 2.mon
| |-2.mon
|-.project
The intent was to see if the engine_deploy tool could identify the dependency tree of user-defined types. Unfortunately, it does not appear to:
engine_deploy -d ../Deployment .
INFO: copying the project file from /home/twanas/base_project to output directory ../Deployment
WARN: Overwriting output deployment directory ../Deployment
ERROR: Failed to generate initialization list as the project has below error(s):
/home/twanas/base_project/monitors/1.mon: 1: the name rt in the com namespace does not exist
/home/twanas/base_project/monitors/1.mon: 5: "A" does not exist
Full source:
// 1.mon
using com.rt.sub_a;
monitor B {
action onload() {
on all A() as a {
log a.toString();
}
}
}
// 2.mon
package com.rt.sub_a;
event A {
string mystring;
}
Assuming the user is developing on linux so does not use the 'SoftwareAG Designer' - how can this be achieved?
On a separate note - the apama_project and engine_deploy are great additions to toolbase.
The issue was actually caused by invalid EPL using com.rt.sub_a;
The tools did indeed resolve the user-defined dependencies which is excellent.

How to add Babel support for nullishCoalescingOperator to vue project?

In my Vue-CLI project, when I tried using the ?? operator, I got this error:
Syntax Error: SyntaxError: /Users/stevebennett/odev/freelancing/v-map/src/components/Map.vue: >Support for the experimental syntax 'nullishCoalescingOperator' isn't currently enabled (30:29):
...
Add #babel/plugin-proposal-nullish-coalescing-operator (https://git.io/vb4Se) to the 'plugins' section of your Babel config to enable transformation.
I installed #babel/plugin-syntax-nullish-coalescing-operator (its name seems to have changed), added it to my babel.config.js:
module.exports = {
presets: ['#vue/app'],
plugins: ['#babel/plugin-syntax-nullish-coalescing-operator'],
};
Now the error message seems to have gone backwards, no reference to the operator name at all:
Module parse failed: Unexpected token (39:35)
You may need an appropriate loader to handle this file type.
| case 8:
| points = _context.sent;
console.log(sheetID ?? 37);
What am I doing wrong?
For me, the #babel/plugin-syntax-nullish-coalescing-operator plugin would not work, which is the one you are using.
I had to use the #babel/plugin-proposal-nullish-coalescing-operator plugin which is the one that the error message suggests you use.
Additionally, I noticed this on the page for the #babel/plugin-syntax-nullish-coalescing-operator plugin:
I can't say for sure if this will fix your problem, but it certainly fixed mine

Check for empty file and quit cakebuild

I am attempting to write a check in my Cake build script to pull in a file from BuildParameters and check if the file contents are empty -- if contents are empty, throw an exception and quit the build.
I am attempting to use FileReadText from the FileHelpers namespace but for some reason I cannot get my build to recognize the file command. I am following the syntax and documentation found here: https://cakebuild.net/api/Cake.FileHelpers/FileHelperAliases/97F5679A
Here is the code I am trying in build.cake:
var fileReadText= FileReadText(Parameters.TestParameters.TestListFP);
var fileText= fileReadText.ThrowIfNullOrEmpty(nameof(fileReadText));
The argument Parameters.TestParameters.TestListFP is set in my Parameters.cake file as such:
TestListFP = context.File("C:\Some\Path\some_file_name.txt");
Using the above code, I see this error:
error CS0103: The name 'FileReadText' does not exist in the current
context
Note that I do not have a ICakeContext in build.cake, just BuildParameters.
I tried to resolve the issue by adding using Cake.FileHelpers; at the top of my build.cake file, but then I see this error:
The type or namespace name 'FileHelpers' does not exist in the namespace 'Cake' (are you missing an assembly reference?)
The script works fine without my FileReadText code, so I know TestListFP is actually a valid file.
I think I am inherently misunderstanding how to use FileHelpers and FileReadText and I could not find any examples of usage in documentation or anywhere else. If anyone has guidance on how to use this method, or a better way to accomplish what I am trying to do, I would appreciate the help.
Have you added the #addin pre-processor directive, as mentioned here:
https://github.com/cake-contrib/Cake.FileHelpers/#cakefilehelpers
You can easily reference Cake.FileHelpers directly in your build script via a cake addin:
#addin "Cake.FileHelpers"

CMake add_custom_command inside of a macro

My CMake code looks like the following:
macro(macro_name target_name)
add_custom_command(TARGET ${target_name}
POST_BUILD
COMMAND MyCommand)
endmacro()
Running this I get the following message:
CMake Warning (dev) at ... (add_custom_command):
Policy CMP0040 is not set: The target in the TARGET signature of
add_custom_command() must exist. Run "cmake --help-policy CMP0040" for
policy details. Use the cmake_policy command to set the policy and
suppress this warning.
The target name "target_name" is unknown in this context.
The same code inside of a function works great but I need macro for other things.
CMake policy (http://www.cmake.org/cmake/help/v3.0/policy/CMP0040.html) suggests just ignoring of this warning (and ignoring of adding of postbuild step at all) or treating it as error depending on the settings.
This: http://www.cmake.org/cmake/help/v3.0/command/macro.html states that parameters behavior in macros is different from one in functions.
How do I properly refer to macro parameters to get this work?
I've managed to figure out the reason: in my case wrong directory was used as ${CMAKE_CURRENT_BINARY_DIR} inside of the macro. Fixing paths allowed to get desirable result