Skip to content

change drop-ins to drop_ins #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ spec:
description: Content is the unit's content.
type: string
dropIns:
description: DropIns is a list of drop-ins for this unit.
description: DropIns is a list of drop_ins for this unit.
items:
description: DropIn is a drop-in configuration for a systemd
unit.
Expand Down Expand Up @@ -314,7 +314,7 @@ spec:
description: Content is the unit's content.
type: string
dropIns:
description: DropIns is a list of drop-ins for this unit.
description: DropIns is a list of drop_ins for this unit.
items:
description: DropIn is a drop-in configuration for a systemd
unit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ spec:
description: Content is the unit's content.
type: string
dropIns:
description: DropIns is a list of drop-ins for this unit.
description: DropIns is a list of drop_ins for this unit.
items:
description: DropIn is a drop-in configuration for a systemd
unit.
Expand Down Expand Up @@ -417,7 +417,7 @@ spec:
description: Content is the unit's content.
type: string
dropIns:
description: DropIns is a list of drop-ins for this unit.
description: DropIns is a list of drop_ins for this unit.
items:
description: DropIn is a drop-in configuration for a systemd
unit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ spec:
description: Content is the unit's content.
type: string
dropIns:
description: DropIns is a list of drop-ins for this unit.
description: DropIns is a list of drop_ins for this unit.
items:
description: DropIn is a drop-in configuration for a systemd unit.
properties:
Expand Down Expand Up @@ -387,7 +387,7 @@ spec:
description: Content is the unit's content.
type: string
dropIns:
description: DropIns is a list of drop-ins for this unit.
description: DropIns is a list of drop_ins for this unit.
items:
description: DropIn is a drop-in configuration for a systemd unit.
properties:
Expand Down
2 changes: 1 addition & 1 deletion pkg/crd/osm/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type Unit struct {
Mask *bool `json:"mask,omitempty"`
// Content is the unit's content.
Content *string `json:"content,omitempty"`
// DropIns is a list of drop-ins for this unit.
// DropIns is a list of drop_ins for this unit.
DropIns []DropIn `json:"dropIns,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ coreos:
{{ $unit.Content | indent 6 }}
{{- end }}
{{ if $unit.Content }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koflanx Isn't this a bug as well?
Should be {{ if $unit.DropIns }} instead of {{ if $unit.Content }} imo.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kron4eg Maybe you can give your 2 cents about this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it's it definitely.

diff --git pkg/generator/generator.go pkg/generator/generator.go
index b158bcc..ac966fd 100644
--- pkg/generator/generator.go
+++ pkg/generator/generator.go
@@ -253,13 +253,13 @@ coreos:
 	command: start
 	{{- end }}
     mask: {{or $unit.Mask false}}
-{{ if $unit.Content }}
+{{ with $unit.Content }}
     content: |
-{{ $unit.Content | indent 6 }}
+{{ . | indent 6 }}
 {{- end }}
-{{ if $unit.Content }}
+{{ with $unit.DropIns }}
     drop_ins:
-{{- range $_, $dropIn := $unit.DropIns }}
+{{- range $_, $dropIn := . }}
       - name: "{{ $dropIn.Name }}"
         content: |
 {{ $dropIn.Content | indent 10 }}

This is how it should look like (using go's {{ with }} template operator to avoid such bugs in the future).

drop-ins:
drop_ins:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make a copy, for have both drop-ins: and drop_ins:. For backward compatibility 🤷‍♂️

{{- range $_, $dropIn := $unit.DropIns }}
- name: "{{ $dropIn.Name }}"
content: |
Expand Down