2017-06-14 4 views

答えて

1

正確ではありませんが、ほとんどです。クラス式 (expression::)を使用する場合は、次の式までコンテキスト制限が適用されるか、または次の約束タイプまで になるので、複数の約束に同時に適用されることに注意してください。 ifvarclassは1つの約束時間。また3.7.0以来、 はif aliasifvarclassであり、これはIMHOを入力するとより良いです。

単純なクラスベースの制約については、互換性があります。

bundle agent main 
{ 
    vars: 
    "classes" slist => { "linux", "windows" }; 

    reports: 

    "I am a Linux box" 
     ifvarclass => "linux"; 

    linux:: 
     "I am still a Linux box"; 
} 

R: I am a Linux box 
R: I am still a Linux box 

また、簡単な表現を同じ意味で使用することもできます。

bundle agent main 
{ 
    vars: 
    "classes" slist => { "linux", "windows" }; 

    reports: 

    "I am a Linux box" 
     ifvarclass => "linux.64_bit"; 

    linux.64_bit:: 
     "I am still a Linux box"; 
} 

R: I am a Linux box 
R: I am still a Linux box 
あなたは伝統的なコンテキストクラス式の中で変数を使用することができませんでした3.7.0まで

$(my_variable)::)とifvarclassは制約として canonified変数を使用することができることのために有用でした。例えば

3.7まであなたがこれを行う必要があった:3.7のよう

bundle agent main 
{ 
    vars: 
    "classes" slist => { "linux", "windows" }; 

    reports: 

    "I am $(classes) box" 
     ifvarclass => "$(classes)"; 
} 

R: I am linux box 

あなたがvariable class expressionsを使用することができます。

bundle agent main 
{ 
    vars: 
    "classes" slist => { "linux", "windows" }; 

    reports: 

    "$(classes)":: 
     "I am $(classes) box"; 
} 

R: I am linux box 

のもののリストは、あなたのチェックが 文字を含むまで正常に動作しますクラス(ダッシュなど)では無効です。ここではifvarclassが最も多く、 は文字列を変換することができ、 という関数を使用してisvariable()のようなブール値を返すので便利です。

canonify()で使用中のifvarclassを示す例です。

bundle agent main 
{ 
    classes: 
    # A class that was derived from a string containing invalid characters like special-class 
    "special_class" expression => "any"; 

    vars: 
    "classes" slist => { "linux", "windows", "special-class" }; 

    reports: 

    "I am $(classes) box" 
     ifvarclass => canonify($(classes)); 
} 

R: I am linux box 
R: I am special-class box 
関連する問題