Skip to content

Commit cbd33ad

Browse files
authored
Merge pull request #835 from puppetlabs/release
4.21.0 release merge back
2 parents df3b527 + 5d6cca1 commit cbd33ad

File tree

4 files changed

+71
-33
lines changed

4 files changed

+71
-33
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](http://semver.org).
55

6+
## Supported Release 4.21.0
7+
### Summary
8+
9+
This is a small feature release that includes a revamped, albeit backwards-compatible file_line type.
10+
11+
#### Added
12+
- `replace_all_matches_not_matching_line` parameter in file_line
13+
- additional tests and documentation for file_line
14+
15+
#### Removed
16+
- duplicate spec test for absolute_path
17+
18+
#### Fixed
19+
- Unixpath type to allow "/" as valid path
20+
- file_line behavior that caused infinite appending of `line` to a file ([MODULES-5651](https://tickets.puppet.com/browse/MODULES-5651))
21+
622
## Supported Release 4.20.0
723
### Summary
824

README.md

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,17 @@ file_line { 'bashrc_proxy':
127127
}
128128
```
129129

130-
In this code example, `match` looks for a line beginning with export followed by HTTP_PROXY and replaces it with the value in line. If a match is not found, then no changes are made to the file.
130+
In this code example, `match` looks for a line beginning with export followed by 'HTTP_PROXY' and replaces it with the value in line. If a match is not found, then no changes are made to the file.
131131

132-
Examples With `ensure => absent`:
132+
Examples of `ensure => absent`:
133133

134134
This type has two behaviors when `ensure => absent` is set.
135135

136-
One possibility is to set `match => ...` and `match_for_absence => true`,
137-
as in the following example:
136+
The first is to set `match => ...` and `match_for_absence => true`. Match looks for a line beginning with 'export', followed by 'HTTP_PROXY', and then deletes it. If multiple lines match, an error is raised unless the `multiple => true` parameter is set.
137+
138+
The `line => ...` parameter in this example would be accepted but ignored.
139+
140+
For example:
138141

139142
```puppet
140143
file_line { 'bashrc_proxy':
@@ -145,15 +148,9 @@ file_line { 'bashrc_proxy':
145148
}
146149
```
147150

148-
In this code example match will look for a line beginning with export
149-
followed by HTTP_PROXY and delete it. If multiple lines match, an
150-
error will be raised unless the `multiple => true` parameter is set.
151+
The second way of using `ensure => absent` is to specify a `line => ...` and no match. When ensuring lines are absent, the default behavior is to remove all lines matching. This behavior can't be disabled.
151152

152-
Note that the `line => ...` parameter would be accepted *but ignored* in
153-
the above example.
154-
155-
The second way of using `ensure => absent` is to specify a `line => ...`,
156-
and no match:
153+
For example:
157154

158155
```puppet
159156
file_line { 'bashrc_proxy':
@@ -163,9 +160,6 @@ file_line { 'bashrc_proxy':
163160
}
164161
```
165162

166-
Note that when ensuring lines are absent this way, the default behavior
167-
this time is to always remove all lines matching, and this behavior
168-
can't be disabled.
169163

170164
Encoding example:
171165

@@ -236,7 +230,7 @@ Default value: `false`.
236230

237231
##### `multiple`
238232

239-
Specifies whether `match` and `after` can change multiple lines. If set to `false`, allows file\_line to replace only one line and raises an error if more than one will be replaced. If set to `true`, allows file\_line to replace one or more lines.
233+
Specifies whether `match` and `after` can change multiple lines. If set to `false`, allows file_line to replace only one line and raises an error if more than one will be replaced. If set to `true`, allows file_line to replace one or more lines.
240234

241235
Values: `true`, `false`.
242236

@@ -271,7 +265,7 @@ Default value: `true`.
271265

272266
##### `replace_all_matches_not_matching_line`
273267

274-
Replace all lines matched by `match` parameter, even if `line` already exists in the file.
268+
Replaces all lines matched by `match` parameter, even if `line` already exists in the file.
275269

276270
Default value: `false`.
277271

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "puppetlabs-stdlib",
3-
"version": "4.20.0",
3+
"version": "4.21.0",
44
"author": "puppetlabs",
55
"summary": "Standard library of resources for Puppet modules.",
66
"license": "Apache-2.0",

readmes/README_ja_JP.md

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,29 +117,49 @@ file_line { 'bashrc_proxy':
117117

118118
マッチ例:
119119

120-
file_line { 'bashrc_proxy':
121-
ensure => present,
122-
path => '/etc/bashrc',
123-
line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
124-
match => '^export\ HTTP_PROXY\=',
125-
append_on_no_match => false,
126-
}
120+
```puppet
121+
file_line { 'bashrc_proxy':
122+
ensure => present,
123+
path => '/etc/bashrc',
124+
line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
125+
match => '^export\ HTTP_PROXY\=',
126+
append_on_no_match => false,
127+
}
128+
```
129+
130+
このコードの例では、`match`によってexportで始まり'HTTP_PROXY'が続く行が検索され、その行が行内の値に置き換えられます。マッチするものが見つからない場合、ファイルは変更されません。
131+
132+
`ensure => absent`の例:
127133

128-
このコードの例では、`match`によってexportで始まりHTTP_PROXYが続く行が検索され、その行が行内の値に置き換えられます。マッチするものが見つからない場合、ファイルは変更されません
134+
`ensure => absent`を設定する場合に、このタイプの動作には2通りがあります
129135

130-
`ensure => absent`を用いたマッチ例:
136+
1つは`match => ...``match_for_absence => true`の設定です。`match`により、'export'で始まり'HTTP_PROXY'と続く行が探され、その行が削除されます。複数の行がマッチし、`multiple => true`パラメータが設定されていない場合は、エラーが生じます。
137+
138+
この例で`line => ...`パラメータは承認されますが無視されます。
139+
140+
例:
131141

132142
```puppet
133143
file_line { 'bashrc_proxy':
134144
ensure => absent,
135145
path => '/etc/bashrc',
136-
line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
137146
match => '^export\ HTTP_PROXY\=',
138147
match_for_absence => true,
139148
}
140149
```
141150

142-
上の例では、`match`により、'export'で始まり'HTTP_PROXY'と続く行が探され、その行が削除されます。複数の行がマッチし、`multiple => true`パラメータが設定されていない場合は、エラーが生じます。
151+
`ensure => absent`を設定する場合のもう1つの動作は、`line => ...`の指定と一致なしです。行が存在しないことを確認した場合のデフォルトの動作では、マッチするすべての行を削除します。この動作を無効にすることはできません。
152+
153+
例:
154+
155+
```puppet
156+
file_line { 'bashrc_proxy':
157+
ensure => absent,
158+
path => '/etc/bashrc',
159+
line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
160+
}
161+
```
162+
143163

144164
エンコード例:
145165

@@ -193,7 +213,7 @@ file_line { "XScreenSaver":
193213

194214
##### `match`
195215

196-
ファイル内の既存の行と比較する正規表現を指定します。マッチが見つかった場合、新規の行を追加するかわりに、置き換えられます。正規表現の比較は行の値に照らして行われ、マッチしない場合は、例外が発生します
216+
ファイル内の既存の行と比較する正規表現を指定します。マッチが見つかった場合、新規の行を追加する代わりに、置き換えられます。
197217

198218
値: 正規表現を含む文字列
199219

@@ -210,7 +230,7 @@ file_line { "XScreenSaver":
210230

211231
##### `multiple`
212232

213-
`match`および`after`により複数の行を変更できるかどうかを指定します。`false`に設定すると、複数の行がマッチする場合に例外が発生します
233+
`match`および`after`により複数の行を変更できるかどうかを指定します。`false`に設定すると、file_lineは1つの行のみ置き換えることができますが、複数の行を置き換えようとするとエラーが発生します。`true`に設定すると、file_lineは1つまたは複数の行を置き換えることができます
214234

215235
値: `true``false`
216236

@@ -235,12 +255,20 @@ file_line { "XScreenSaver":
235255

236256
##### `replace`
237257

238-
`match`パラメータとマッチする既存の行を上書きするかどうかを指定します。`false`に設定すると、`match`パラメータにマッチする行が見つかった場合、その行はファイルに配置されません。
258+
`match`パラメータとマッチする既存の行をリソースで上書きするかどうかを指定します。`false`に設定すると、`match`パラメータにマッチする行が見つかった場合、その行はファイルに配置されません。
259+
260+
`false`に設定すると、`match`パラメータにマッチする行が見つかった場合、その行はファイルに配置されません。
239261

240262
ブーリアン
241263

242264
デフォルト値: `true`
243265

266+
##### `replace_all_matches_not_matching_line`
267+
268+
`line`がファイルにすでに存在する場合でも、`match`パラメータに一致するすべての行が置き換えられます。
269+
270+
デフォルト値: `false`
271+
244272
### データタイプ
245273

246274
#### `Stdlib::Absolutepath`
@@ -2214,7 +2242,7 @@ validate_ip_address('260.2.32.43')
22142242
例:
22152243

22162244
```puppet
2217-
validate_legacy("Optional[String]", "validate_re", "Value to be validated", ["."])
2245+
validate_legacy('Optional[String]', 'validate_re', 'Value to be validated', ["."])
22182246
```
22192247

22202248
この関数は、Puppet 3形式の引数確認(stdlibの`validate_*`関数を使用)からPuppet 4データタイプへのモジュールのアップデートに対応しており、Puppet 3形式の確認に頼っている場合も機能性が中断することはありません。

0 commit comments

Comments
 (0)