Movatterモバイル変換


[0]ホーム

URL:


CFEngine documentation homepage

How do I pass a data type variable?

Suggest changes
Table of contents

Data type variables also known as "data containers" are passed using the samesyntax as passing a list.

code
bundleagentexample{vars:# First you must have a data type variable, define it inline or read from a# file using `readjson()`."data"data=>parsejson('[{"x":1},{"y":2}]');methods:"use data"usebundle=>use_data(@(data));}bundleagentuse_data(dc){vars:# Use the data# Get its keys, or its index"dc_index"slist=>getindices(dc);classes:"have_x"expression=>isvariable("dc[$(dc_index)][x]");"have_z"expression=>isvariable("dc[$(dc_index)][z]");reports:"CFEngine version '$(sys.cf_version)'";have_x::"Index '$(dc_index)' has key for x";have_z::"Index '$(dc_index)' has key for z";}
code
$cf-agent -Kf ./example.cf -b exampleR: CFEngine version '3.6.4'R: Index '0' has key for xR: Index '1' has key for x

Still need help?

Chat Ask a question on Github Mailing list
Version 
master3.24 (LTS)3.21 (LTS)view all versions

[8]ページ先頭

©2009-2025 Movatter.jp