Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

api: reject templates for particular unit types #1653

Merged
merged 2 commits into from
Aug 9, 2016

Conversation

dongsupark
Copy link
Contributor

Following unit types don't support templates:

  • automount
  • busname
  • device
  • mount
  • scope
  • slice
  • snapshot
  • swap

On the other hand, only the following types are allowed for templates:

  • path
  • service
  • socket
  • target
  • timer

As it's not that simple to support templates for particular unit types on systemd, reject templates for such units from the fleet side.

Fixes #1390

return fmt.Errorf("invalid unit type: %q", suffix)
}
if strings.Index(name, "@") != -1 && !templateTypes.Contains(suffix) {
Copy link
Contributor

Choose a reason for hiding this comment

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

strings.Contains

@jonboulle
Copy link
Contributor

LGTM after a couple of minor ones

Dongsu Park added 2 commits August 8, 2016 12:34
Following unit types don't support templates:

  automount, busname, device, mount, scope, slice, snapshot, swap

On the other hand, only the following types are allowed for templates:

  path, service, socket, target, timer

As it's not that simple to support templates for particular unit types
on systemd, reject templates for such units from the fleet side.

Fixes coreos#1390
Describe supported unit types for templates.
Also update the existing description about ordinary unit types.
@dongsupark
Copy link
Contributor Author

@jonboulle Done.
Replaced Index() != 1 with Contains(), renamed templateTypes to validTemplateTypes.
I'll merge it tomorrow. Thanks.

@dongsupark dongsupark merged commit a92c072 into coreos:master Aug 9, 2016
@dongsupark dongsupark deleted the dongsu/api-reject-unit-types branch August 9, 2016 08:58
@stevehorsfield
Copy link

This is quite frustrating. As an outsider, it's hard to understand why templates are only supported in some cases.

@dongsupark
Copy link
Contributor Author

@stevehorsfield Yeah, I feel your pain.
As I once mentioned, there's a systemd issue systemd/systemd#2556, which clarifies the underlying issue. It doesn't look trivial to achieve both template support and backward compatibility. TBH I don't have a brilliant idea.

@stevehorsfield
Copy link

@dongsupark - Thanks for the pointer. I've commented on that ticket. I have an ugly workaround for my current needs using a service unit to perform the mount. It's far from ideal.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants