Skip to content

Commit d7dff12

Browse files
authored
Merge pull request #703 from arithx/drop_networkd
*: drop networkd section
2 parents f02989f + e7e7aa2 commit d7dff12

File tree

19 files changed

+48
-606
lines changed

19 files changed

+48
-606
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ignition
22

3-
Ignition is the utility used by CoreOS Container Linux to manipulate disks during the initramfs. This includes partitioning disks, formatting partitions, writing files (regular files, systemd units, networkd units, etc.), and configuring users. On first boot, Ignition reads its configuration from a source of truth (remote URL, network metadata service, hypervisor bridge, etc.) and applies the configuration.
3+
Ignition is the utility used by CoreOS Container Linux to manipulate disks during the initramfs. This includes partitioning disks, formatting partitions, writing files (regular files, systemd units, etc.), and configuring users. On first boot, Ignition reads its configuration from a source of truth (remote URL, network metadata service, hypervisor bridge, etc.) and applies the configuration.
44

55
Ignition has two main development branches: master and spec2x. This is the master branch which is for Ignition included in Red Hat CoreOS and Fedora CoreOS. For Ignition development for Container Linux see the [spec2x](https://github.com/coreos/ignition/tree/spec2x) branch.
66

config/shared/errors/errors.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,9 @@ var (
7979
ErrPasswdCreateAndSystem = errors.New("cannot use both the create object and the user-level system field")
8080
ErrPasswdCreateAndUID = errors.New("cannot use both the create object and the user-level uid field")
8181

82-
// Systemd and Networkd section errors
83-
ErrInvalidSystemdExt = errors.New("invalid systemd unit extension")
84-
ErrInvalidSystemdDropinExt = errors.New("invalid systemd drop-in extension")
85-
ErrInvalidNetworkdExt = errors.New("invalid networkd unit extension")
86-
ErrInvalidNetworkdDropinExt = errors.New("invalid networkd drop-in extension")
82+
// Systemd section errors
83+
ErrInvalidSystemdExt = errors.New("invalid systemd unit extension")
84+
ErrInvalidSystemdDropinExt = errors.New("invalid systemd drop-in extension")
8785

8886
// Misc errors
8987
ErrInvalidScheme = errors.New("invalid url scheme")

config/v3_0_experimental/types/schema.go

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ type CaReference struct {
99

1010
type Config struct {
1111
Ignition Ignition `json:"ignition"`
12-
Networkd Networkd `json:"networkd,omitempty"`
1312
Passwd Passwd `json:"passwd,omitempty"`
1413
Storage Storage `json:"storage,omitempty"`
1514
Systemd Systemd `json:"systemd,omitempty"`
@@ -44,6 +43,11 @@ type Disk struct {
4443
WipeTable bool `json:"wipeTable,omitempty"`
4544
}
4645

46+
type Dropin struct {
47+
Contents string `json:"contents,omitempty"`
48+
Name string `json:"name"`
49+
}
50+
4751
type File struct {
4852
Node
4953
FileEmbedded1
@@ -103,21 +107,6 @@ type Mount struct {
103107

104108
type MountOption string
105109

106-
type Networkd struct {
107-
Units []Networkdunit `json:"units,omitempty"`
108-
}
109-
110-
type NetworkdDropin struct {
111-
Contents string `json:"contents,omitempty"`
112-
Name string `json:"name"`
113-
}
114-
115-
type Networkdunit struct {
116-
Contents string `json:"contents,omitempty"`
117-
Dropins []NetworkdDropin `json:"dropins,omitempty"`
118-
Name string `json:"name"`
119-
}
120-
121110
type Node struct {
122111
Filesystem string `json:"filesystem"`
123112
Group *NodeGroup `json:"group,omitempty"`
@@ -191,7 +180,7 @@ type RaidOption string
191180
type SSHAuthorizedKey string
192181

193182
type Security struct {
194-
TLS `json:"tls,omitempty"`
183+
TLS TLS `json:"tls,omitempty"`
195184
}
196185

197186
type Storage struct {
@@ -207,11 +196,6 @@ type Systemd struct {
207196
Units []Unit `json:"units,omitempty"`
208197
}
209198

210-
type SystemdDropin struct {
211-
Contents string `json:"contents,omitempty"`
212-
Name string `json:"name"`
213-
}
214-
215199
type TLS struct {
216200
CertificateAuthorities []CaReference `json:"certificateAuthorities,omitempty"`
217201
}
@@ -222,12 +206,12 @@ type Timeouts struct {
222206
}
223207

224208
type Unit struct {
225-
Contents string `json:"contents,omitempty"`
226-
Dropins []SystemdDropin `json:"dropins,omitempty"`
227-
Enable bool `json:"enable,omitempty"`
228-
Enabled *bool `json:"enabled,omitempty"`
229-
Mask bool `json:"mask,omitempty"`
230-
Name string `json:"name"`
209+
Contents string `json:"contents,omitempty"`
210+
Dropins []Dropin `json:"dropins,omitempty"`
211+
Enable bool `json:"enable,omitempty"`
212+
Enabled *bool `json:"enabled,omitempty"`
213+
Mask bool `json:"mask,omitempty"`
214+
Name string `json:"name"`
231215
}
232216

233217
type Usercreate struct {

config/v3_0_experimental/types/unit.go

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (u Unit) ValidateName() report.Report {
5555
return r
5656
}
5757

58-
func (d SystemdDropin) Validate() report.Report {
58+
func (d Dropin) Validate() report.Report {
5959
r := report.Report{}
6060

6161
if _, err := validateUnitContent(d.Contents); err != nil {
@@ -77,50 +77,6 @@ func (d SystemdDropin) Validate() report.Report {
7777
return r
7878
}
7979

80-
func (u Networkdunit) Validate() report.Report {
81-
r := report.Report{}
82-
83-
if _, err := validateUnitContent(u.Contents); err != nil {
84-
r.Add(report.Entry{
85-
Message: err.Error(),
86-
Kind: report.EntryError,
87-
})
88-
}
89-
90-
switch path.Ext(u.Name) {
91-
case ".link", ".netdev", ".network":
92-
default:
93-
r.Add(report.Entry{
94-
Message: errors.ErrInvalidNetworkdExt.Error(),
95-
Kind: report.EntryError,
96-
})
97-
}
98-
99-
return r
100-
}
101-
102-
func (d NetworkdDropin) Validate() report.Report {
103-
r := report.Report{}
104-
105-
if _, err := validateUnitContent(d.Contents); err != nil {
106-
r.Add(report.Entry{
107-
Message: err.Error(),
108-
Kind: report.EntryError,
109-
})
110-
}
111-
112-
switch path.Ext(d.Name) {
113-
case ".conf":
114-
default:
115-
r.Add(report.Entry{
116-
Message: errors.ErrInvalidNetworkdDropinExt.Error(),
117-
Kind: report.EntryError,
118-
})
119-
}
120-
121-
return r
122-
}
123-
12480
func validateUnitContent(content string) ([]*unit.UnitOption, error) {
12581
c := strings.NewReader(content)
12682
opts, err := unit.Deserialize(c)

config/v3_0_experimental/types/unit_test.go

Lines changed: 4 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestSystemdUnitValidateContents(t *testing.T) {
4444
out: out{err: fmt.Errorf("invalid unit content: unable to find end of section")},
4545
},
4646
{
47-
in: in{unit: Unit{Name: "test.service", Contents: "", Dropins: []SystemdDropin{{}}}},
47+
in: in{unit: Unit{Name: "test.service", Contents: "", Dropins: []Dropin{{}}}},
4848
out: out{err: nil},
4949
},
5050
}
@@ -93,7 +93,7 @@ func TestSystemdUnitValidateName(t *testing.T) {
9393

9494
func TestSystemdUnitDropInValidate(t *testing.T) {
9595
type in struct {
96-
unit SystemdDropin
96+
unit Dropin
9797
}
9898
type out struct {
9999
err error
@@ -104,109 +104,11 @@ func TestSystemdUnitDropInValidate(t *testing.T) {
104104
out out
105105
}{
106106
{
107-
in: in{unit: SystemdDropin{Name: "test.conf", Contents: "[Foo]\nQux=Bar"}},
107+
in: in{unit: Dropin{Name: "test.conf", Contents: "[Foo]\nQux=Bar"}},
108108
out: out{err: nil},
109109
},
110110
{
111-
in: in{unit: SystemdDropin{Name: "test.conf", Contents: "[Foo"}},
112-
out: out{err: fmt.Errorf("invalid unit content: unable to find end of section")},
113-
},
114-
}
115-
116-
for i, test := range tests {
117-
err := test.in.unit.Validate()
118-
if !reflect.DeepEqual(report.ReportFromError(test.out.err, report.EntryError), err) {
119-
t.Errorf("#%d: bad error: want %v, got %v", i, test.out.err, err)
120-
}
121-
}
122-
}
123-
124-
func TestNetworkdUnitNameValidate(t *testing.T) {
125-
type in struct {
126-
unit string
127-
}
128-
type out struct {
129-
err error
130-
}
131-
132-
tests := []struct {
133-
in in
134-
out out
135-
}{
136-
{
137-
in: in{unit: "test.network"},
138-
out: out{err: nil},
139-
},
140-
{
141-
in: in{unit: "test.link"},
142-
out: out{err: nil},
143-
},
144-
{
145-
in: in{unit: "test.netdev"},
146-
out: out{err: nil},
147-
},
148-
{
149-
in: in{unit: "test.blah"},
150-
out: out{err: errors.ErrInvalidNetworkdExt},
151-
},
152-
}
153-
154-
for i, test := range tests {
155-
err := Networkdunit{Name: test.in.unit, Contents: "[Foo]\nQux=Bar"}.Validate()
156-
if !reflect.DeepEqual(report.ReportFromError(test.out.err, report.EntryError), err) {
157-
t.Errorf("#%d: bad error: want %v, got %v", i, test.out.err, err)
158-
}
159-
}
160-
}
161-
162-
func TestNetworkdUnitValidate(t *testing.T) {
163-
type in struct {
164-
unit Networkdunit
165-
}
166-
type out struct {
167-
err error
168-
}
169-
170-
tests := []struct {
171-
in in
172-
out out
173-
}{
174-
{
175-
in: in{unit: Networkdunit{Name: "test.network", Contents: "[Foo]\nQux=Bar"}},
176-
out: out{err: nil},
177-
},
178-
{
179-
in: in{unit: Networkdunit{Name: "test.network", Contents: "[Foo"}},
180-
out: out{err: fmt.Errorf("invalid unit content: unable to find end of section")},
181-
},
182-
}
183-
184-
for i, test := range tests {
185-
err := test.in.unit.Validate()
186-
if !reflect.DeepEqual(report.ReportFromError(test.out.err, report.EntryError), err) {
187-
t.Errorf("#%d: bad error: want %v, got %v", i, test.out.err, err)
188-
}
189-
}
190-
}
191-
192-
func TestNetworkdUnitDropInValidate(t *testing.T) {
193-
type in struct {
194-
unit NetworkdDropin
195-
}
196-
type out struct {
197-
err error
198-
}
199-
200-
tests := []struct {
201-
in in
202-
out out
203-
}{
204-
{
205-
in: in{unit: NetworkdDropin{Name: "test.conf", Contents: "[Foo]\nQux=Bar"}},
206-
out: out{err: nil},
207-
},
208-
{
209-
in: in{unit: NetworkdDropin{Name: "test.conf", Contents: "[Foo"}},
111+
in: in{unit: Dropin{Name: "test.conf", Contents: "[Foo"}},
210112
out: out{err: fmt.Errorf("invalid unit content: unable to find end of section")},
211113
},
212114
}

doc/configuration-v3_0-experimental.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,6 @@ The Ignition configuration is a JSON document conforming to the following specif
108108
* **_dropins_** (list of objects): the list of drop-ins for the unit.
109109
* **name** (string): the name of the drop-in. This must be suffixed with ".conf".
110110
* **_contents_** (string): the contents of the drop-in.
111-
* **_networkd_** (object): describes the desired state of the networkd files.
112-
* **_units_** (list of objects): the list of networkd files.
113-
* **name** (string): the name of the file. This must be suffixed with a valid unit type (e.g. "00-eth0.network").
114-
* **_contents_** (string): the contents of the networkd file.
115-
* **_dropins_** (list of objects): the list of drop-ins for the unit.
116-
* **name** (string): the name of the drop-in. This must be suffixed with ".conf".
117-
* **_contents_** (string): the contents of the drop-in.
118111
* **_passwd_** (object): describes the desired additions to the passwd database.
119112
* **_users_** (list of objects): the list of accounts that shall exist.
120113
* **name** (string): the username for the account.

doc/examples.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ WantedBy=multi-user.target
3434

3535
### Modify Services
3636

37-
This config will add a [systemd unit drop-in](https://coreos.com/os/docs/latest/using-systemd-drop-in-units.html) to modify the existing service `systemd-networkd` and sets its environment variable `SYSTEMD_LOG_LEVEL` to `debug`.
37+
This config will add a [systemd unit drop-in](https://coreos.com/os/docs/latest/using-systemd-drop-in-units.html) to modify the existing service `systemd-journald` and sets its environment variable `SYSTEMD_LOG_LEVEL` to `debug`.
3838

3939
```json ignition
4040
{
4141
"ignition": { "version": "2.2.0" },
4242
"systemd": {
4343
"units": [{
44-
"name": "systemd-networkd.service",
44+
"name": "systemd-journald.service",
4545
"dropins": [{
4646
"name": "debug.conf",
4747
"contents": "[Service]\nEnvironment=SYSTEMD_LOG_LEVEL=debug"
@@ -51,7 +51,7 @@ This config will add a [systemd unit drop-in](https://coreos.com/os/docs/latest/
5151
}
5252
```
5353

54-
#### systemd-networkd.service.d/debug.conf
54+
#### systemd-journald.service.d/debug.conf
5555

5656
```INI
5757
[Service]

internal/config/translate.go

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,6 @@ func Translate(old from.Config) types.Config {
6565
}
6666
return res
6767
}
68-
translateNetworkdDropinSlice := func(old []from.NetworkdDropin) []types.NetworkdDropin {
69-
var res []types.NetworkdDropin
70-
for _, x := range old {
71-
res = append(res, types.NetworkdDropin{
72-
Contents: x.Contents,
73-
Name: x.Name,
74-
})
75-
}
76-
return res
77-
}
78-
translateNetworkdUnitSlice := func(old []from.Networkdunit) []types.Networkdunit {
79-
var res []types.Networkdunit
80-
for _, u := range old {
81-
res = append(res, types.Networkdunit{
82-
Contents: u.Contents,
83-
Name: u.Name,
84-
Dropins: translateNetworkdDropinSlice(u.Dropins),
85-
})
86-
}
87-
return res
88-
}
8968
translatePasswdGroupSlice := func(old []from.PasswdGroup) []types.PasswdGroup {
9069
var res []types.PasswdGroup
9170
for _, g := range old {
@@ -334,10 +313,10 @@ func Translate(old from.Config) types.Config {
334313
}
335314
return res
336315
}
337-
translateSystemdDropinSlice := func(old []from.SystemdDropin) []types.SystemdDropin {
338-
var res []types.SystemdDropin
316+
translateDropinSlice := func(old []from.Dropin) []types.Dropin {
317+
var res []types.Dropin
339318
for _, x := range old {
340-
res = append(res, types.SystemdDropin{
319+
res = append(res, types.Dropin{
341320
Contents: x.Contents,
342321
Name: x.Name,
343322
})
@@ -349,7 +328,7 @@ func Translate(old from.Config) types.Config {
349328
for _, x := range old {
350329
res = append(res, types.Unit{
351330
Contents: x.Contents,
352-
Dropins: translateSystemdDropinSlice(x.Dropins),
331+
Dropins: translateDropinSlice(x.Dropins),
353332
Enable: x.Enable,
354333
Enabled: x.Enabled,
355334
Mask: x.Mask,
@@ -375,9 +354,6 @@ func Translate(old from.Config) types.Config {
375354
},
376355
},
377356
},
378-
Networkd: types.Networkd{
379-
Units: translateNetworkdUnitSlice(old.Networkd.Units),
380-
},
381357
Passwd: types.Passwd{
382358
Groups: translatePasswdGroupSlice(old.Passwd.Groups),
383359
Users: translatePasswdUserSlice(old.Passwd.Users),

0 commit comments

Comments
 (0)