Skip to content

Commit 601c1a7

Browse files
authored
Merge pull request #319 from blanet/xx/fix-misspelling-WithHiearchy
rename misspelling WithHiearchy to WithHierarchy
2 parents 1e05688 + 675b7db commit 601c1a7

6 files changed

Lines changed: 31 additions & 23 deletions

File tree

Protobuild.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ generators = ["go"]
1313
# This is the default.
1414
after = ["/usr/local/include", "/usr/include"]
1515

16-
# Aggregrate the API descriptors to lock down API changes.
16+
# Aggregate the API descriptors to lock down API changes.
1717
[[descriptors]]
1818
prefix = "github.com/containerd/cgroups/cgroup1/stats"
1919
target = "cgroup1/stats/metrics.pb.txt"

cgroup1/cgroup_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestCreate(t *testing.T) {
3838
t.Errorf("failed delete: %v", err)
3939
}
4040
}()
41-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
41+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
4242
if err != nil {
4343
t.Error(err)
4444
return
@@ -69,7 +69,7 @@ func TestStat(t *testing.T) {
6969
t.Errorf("failed delete: %v", err)
7070
}
7171
}()
72-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
72+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
7373
if err != nil {
7474
t.Error(err)
7575
return
@@ -95,7 +95,7 @@ func TestAdd(t *testing.T) {
9595
t.Errorf("failed delete: %v", err)
9696
}
9797
}()
98-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
98+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
9999
if err != nil {
100100
t.Error(err)
101101
return
@@ -122,7 +122,7 @@ func TestAddFilteredSubsystems(t *testing.T) {
122122
t.Errorf("failed delete: %v", err)
123123
}
124124
}()
125-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
125+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
126126
if err != nil {
127127
t.Error(err)
128128
return
@@ -183,7 +183,7 @@ func TestAddTask(t *testing.T) {
183183
t.Errorf("failed delete: %v", err)
184184
}
185185
}()
186-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
186+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
187187
if err != nil {
188188
t.Error(err)
189189
return
@@ -210,7 +210,7 @@ func TestAddTaskFilteredSubsystems(t *testing.T) {
210210
t.Errorf("failed delete: %v", err)
211211
}
212212
}()
213-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
213+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
214214
if err != nil {
215215
t.Error(err)
216216
return
@@ -256,7 +256,7 @@ func TestListPids(t *testing.T) {
256256
t.Errorf("failed delete: %v", err)
257257
}
258258
}()
259-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
259+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
260260
if err != nil {
261261
t.Error(err)
262262
return
@@ -295,7 +295,7 @@ func TestListTasksPids(t *testing.T) {
295295
t.Errorf("failed delete: %v", err)
296296
}
297297
}()
298-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
298+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
299299
if err != nil {
300300
t.Error(err)
301301
return
@@ -386,7 +386,7 @@ func TestLoad(t *testing.T) {
386386
t.Errorf("failed delete: %v", err)
387387
}
388388
}()
389-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
389+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
390390
if err != nil {
391391
t.Error(err)
392392
return
@@ -396,7 +396,7 @@ func TestLoad(t *testing.T) {
396396
t.Errorf("failed to delete cgroup: %v", err)
397397
}
398398
}()
399-
if control, err = Load(StaticPath("test"), WithHiearchy(mock.hierarchy)); err != nil {
399+
if control, err = Load(StaticPath("test"), WithHierarchy(mock.hierarchy)); err != nil {
400400
t.Error(err)
401401
return
402402
}
@@ -430,7 +430,7 @@ func TestLoadWithMissingSubsystems(t *testing.T) {
430430
t.Error("control is nil")
431431
return
432432
}
433-
if control, err = Load(StaticPath("test"), WithHiearchy(mock.hierarchy)); err != nil {
433+
if control, err = Load(StaticPath("test"), WithHierarchy(mock.hierarchy)); err != nil {
434434
t.Error(err)
435435
return
436436
}
@@ -454,7 +454,7 @@ func TestDelete(t *testing.T) {
454454
t.Errorf("failed delete: %v", err)
455455
}
456456
}()
457-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
457+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
458458
if err != nil {
459459
t.Error(err)
460460
return
@@ -481,7 +481,7 @@ func TestCreateSubCgroup(t *testing.T) {
481481
t.Errorf("failed delete: %v", err)
482482
}
483483
}()
484-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
484+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
485485
if err != nil {
486486
t.Error(err)
487487
return
@@ -523,7 +523,7 @@ func TestFreezeThaw(t *testing.T) {
523523
t.Errorf("failed delete: %v", err)
524524
}
525525
}()
526-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
526+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
527527
if err != nil {
528528
t.Error(err)
529529
return
@@ -556,7 +556,7 @@ func TestSubsystems(t *testing.T) {
556556
t.Errorf("failed delete: %v", err)
557557
}
558558
}()
559-
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
559+
control, err := New(StaticPath("test"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
560560
if err != nil {
561561
t.Error(err)
562562
return
@@ -583,7 +583,7 @@ func TestCpusetParent(t *testing.T) {
583583
t.Errorf("failed delete: %v", err)
584584
}
585585
}()
586-
control, err := New(StaticPath("/parent/child"), &specs.LinuxResources{}, WithHiearchy(mock.hierarchy))
586+
control, err := New(StaticPath("/parent/child"), &specs.LinuxResources{}, WithHierarchy(mock.hierarchy))
587587
if err != nil {
588588
t.Error(err)
589589
return

cgroup1/opts.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,19 @@ func RequireDevices(s Subsystem, _ Path, _ error) error {
6262
return ErrIgnoreSubsystem
6363
}
6464

65-
// WithHiearchy sets a list of cgroup subsystems.
65+
// WithHierarchy sets a list of cgroup subsystems.
6666
// The default list is coming from /proc/self/mountinfo.
67-
func WithHiearchy(h Hierarchy) InitOpts {
67+
func WithHierarchy(h Hierarchy) InitOpts {
6868
return func(c *InitConfig) error {
6969
c.hierarchy = h
7070
return nil
7171
}
7272
}
73+
74+
// WithHiearchy sets a list of cgroup subsystems. It is just kept for backward
75+
// compatibility and will be removed in v4.
76+
//
77+
// Deprecated: use WithHierarchy instead.
78+
func WithHiearchy(h Hierarchy) InitOpts {
79+
return WithHierarchy(h)
80+
}

cgroup1/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ func getCgroupDestination(subsystem string) (string, error) {
236236
return "", ErrNoCgroupMountDestination
237237
}
238238

239-
func pathers(subystems []Subsystem) []pather {
239+
func pathers(subsystems []Subsystem) []pather {
240240
var out []pather
241-
for _, s := range subystems {
241+
for _, s := range subsystems {
242242
if p, ok := s.(pather); ok {
243243
out = append(out, p)
244244
}

cgroup2/devicefilter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
// Devicefilter containes eBPF device filter program
17+
// Devicefilter contains eBPF device filter program
1818
//
1919
// The implementation is based on https://github.com/containers/crun/blob/0.10.2/src/libcrun/ebpf.c
2020
//

cgroup2/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func (c *Manager) ToggleControllers(controllers []string, t ControllerToggle) er
317317
}
318318
filePath := filepath.Join(f, subtreeControl)
319319
if err := c.writeSubtreeControl(filePath, controllers, t); err != nil {
320-
// When running as rootless, the user may face EPERM on parent groups, but it is neglible when the
320+
// When running as rootless, the user may face EPERM on parent groups, but it is negligible when the
321321
// controller is already written.
322322
// So we only return the last error.
323323
lastErr = fmt.Errorf("failed to write subtree controllers %+v to %q: %w", controllers, filePath, err)

0 commit comments

Comments
 (0)