trying to deploy resource group but getting below error
Error: Unsupported argument
on auto.tfvars.tf line 1:
1: resource_group = "india1111"
An argument named "resource_group" is not expected here.
code
code attached
You could specfiy the variable values with file .auto.tfvars instead of auto.tfvars.tf.
For example, the content of the variables.tf file.
variable "resource_group" {
type = string
}
The content of the .auto.tfvars file.
resource_group = "trafff"
To specify variable values in a variable definitions file (with a filename ending in either .tfvars or .tfvars.json) and then specify that file on the command line with -var-file:
terraform apply -var-file="testing.tfvars"
Terraform also automatically loads a number of variable definitions files if they are present:
Files named exactly terraform.tfvars or terraform.tfvars.json.
Any files with names ending in .auto.tfvars or .auto.tfvars.json.
Ref: https://www.terraform.io/docs/language/values/variables.html#variable-definitions-tfvars-files
Related
Imagine I have a java_binary target triggered by a custom rule that generates source code and places the generated sources under a directory, let's call it "root".
So after the code generation we will have something like this:
// bazel-bin/...../src/com/example/root
root:
-> Foo.java
-> Bar.java
-> utils
-> Baz.java
Now, I have another target, a java_library, that depends on the previously generated sources, so it depends on the custom rule.
My custom rule definition currently looks something like this:
def _code_generator(ctx):
outputDir = ctx.actions.declare_directory("root")
files = [
ctx.actions.declare_file("root/Foo.java"),
ctx.actions.declare_file("root/Bar.java"),
ctx.actions.declare_file("root/utils/Baz.java"),
// and many,
// many other files
]
outputs = []
outputs.append(outputDir)
outputs.extend(files)
ctx.actions.run(
executable = // executable pointing to the java_binary
outputs = outputs
// ....
)
This works. But as you can see, every anticipated file that is to be generated, is hard-coded in the rule definition. This makes it very fragile, should the code generation produce a different set of files in the future (which it will).
(Without specifying each of the files, as shown above, Bazel will fail the build saying that the files have no generating action)
So I was wondering, is there a way to read the content of the root directory and automatically, somehow, declare each of the files as an output?
What I tried:
The documentation of declare_directory says:
The contents of the directory are not directly accessible from Starlark, but can be expanded in an action command with Args.add_all().
And add_all says:
[...] Each directory File item is replaced by all Files recursively contained in that directory.
This sounds like there could be a way to get access to the individual files in the directory, but I am not sure how.
I tried:
outputDir = ctx.actions.declare_directory("root")
//...
args = ctx.actions.args()
args.add_all(outputDir)
with the intention to access the individual files later from args, but the build fails with: "Error in add_all: expected value of type sequence or depset for values, got File".
Any other ideas on how to implement the rule, so that I don't have to hard-code each and every file that will be generated?
How do I replace the new File method with a secure one? Is it possible to create a python script and connect it?
Part of the code where I have a problem:
def template Name = new File(file: "${template}").normalize.name.replace(".html", "").replace(".yaml", "")
But when I run my pipeline, I get the error
java.lang.SecurityException: Unable to find constructor: new java.io .File java.util.LinkedHashMap
This method is prohibited and is blacklisted. How do I replace it and with what?
If you're reading the contents of the file, you can replace that "new File" with "readFile".
See https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#readfile-read-file-from-workspace
readFile: Read file from workspace
Reads a file from a relative path (with root in current directory, usually > workspace) and returns its content as a plain string.
file : String
Relative (/-separated) path to file within a workspace to read.
encoding : String (optional)
The encoding to use when reading the file. If left blank, the platform default encoding will be used. Binary files can be read into a Base64-encoded string by specifying "Base64" as the encoding.
I have an array that contains multiple file names of images.
file_name = ["/tmp/image_1.tiff","/tmp/image_2.tiff"]
When I do this operation Magick::ImageList.new(file_name), I get the following error message.
Magick::ImageMagickError Exception: unable to open image
`'/home/tmp/image_1.tiff','/home/tmp/image_2.tiff'': No such file or
directory # error/blob.c/OpenBlob/2712.
How to call multiple image files in a single imagelist?
Thanks in advance.
Try:
Magick::ImageList.new(*file_name)
With the * (or "splat") operator you can turn an Array into an argument list. When applied in your case you get:
Magick::ImageList.new(*["/tmp/image_1.tiff","/tmp/image_2.tiff"])
I am relatively new to razor, so there is probably a lot wrong with this code, but I cannot get it to work. I am trying the grab the full path of a file, and get a loop of all files in that specific folders, and to output the name of the files in a list
First I declare a variable with the full path to a file like this: folder/folder/filename.jpg
Then I try to get the substring to this like folder/folder
Last I try to loop through the files in the folder, and output the full path to the files.
My code is
#foreach (LoopItem i in GetLoop("Products")){
string input = i.GetValue("Ecom:Product:Field.Images.Clean");
string folder = input.Substring(0, input.LastIndexOf("/"));
foreach(var file in GetLoop(folder.ListOfFiles)){
GetValue(folder)/file.GetValue(folder.FileName);
}
}
Error message I get is:
Line 28: Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)
Line 32: 'string' does not contain a definition for 'ListOfFiles' and no extension method 'ListOfFiles' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
I run my .fsx file like
>fsi A.fsx
In this file I read csv with CsvProvider that has to have path to csv data.
type Data = CsvProvider<"my_data.txt", ";", Schema
I need to pass file name as command line argument and it is possible
>fsi A.fsx my_data.txt
I can read it like
let originalPath = fsi.CommandLineArgs.ElementAt(1)
Problem is, that file name used in CsvProvider constructor needs to be constant and command line argument is not. How I can initialize CsvProvider from command line argument?
The value inside the angle brackes <"my_data.txt"...> specifies an example format file and is checked at compile time, hence the need for it to be a constant string. Assuming your .fsx script merely wants to load a different CSV file of the same general format, you would use
let contents = Data.Load(originalPath)