resources: Remove "NewRes" constructors
Remove the New constructors since calling Init should be done by the engine, and not by the user even when using mgmt as a lib. This is also the case in tests! It used to be the case that a user might want to call Init manually, but that is no longer the case!
This commit is contained in:
@@ -69,16 +69,6 @@ type AugeasSet struct {
|
||||
Value string `yaml:"value"` // The value to be set on the given Path.
|
||||
}
|
||||
|
||||
// NewAugeasRes is a constructor for this resource. It also calls Init() for you.
|
||||
func NewAugeasRes(name string) (*AugeasRes, error) {
|
||||
obj := &AugeasRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *AugeasRes) Default() Res {
|
||||
return &AugeasRes{}
|
||||
|
||||
@@ -50,25 +50,6 @@ type ExecRes struct {
|
||||
PollInt int `yaml:"pollint"` // the poll interval for the ifcmd
|
||||
}
|
||||
|
||||
// NewExecRes is a constructor for this resource. It also calls Init() for you.
|
||||
func NewExecRes(name, cmd, shell string, timeout int, watchcmd, watchshell, ifcmd, ifshell string, pollint int, state string) (*ExecRes, error) {
|
||||
obj := &ExecRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
Cmd: cmd,
|
||||
Shell: shell,
|
||||
Timeout: timeout,
|
||||
WatchCmd: watchcmd,
|
||||
WatchShell: watchshell,
|
||||
IfCmd: ifcmd,
|
||||
IfShell: ifshell,
|
||||
PollInt: pollint,
|
||||
State: state,
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *ExecRes) Default() Res {
|
||||
return &ExecRes{}
|
||||
|
||||
@@ -65,24 +65,6 @@ type FileRes struct {
|
||||
recWatcher *recwatch.RecWatcher
|
||||
}
|
||||
|
||||
// NewFileRes is a constructor for this resource. It also calls Init() for you.
|
||||
func NewFileRes(name, path, dirname, basename string, content *string, source, state string, recurse, force bool) (*FileRes, error) {
|
||||
obj := &FileRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
Path: path,
|
||||
Dirname: dirname,
|
||||
Basename: basename,
|
||||
Content: content,
|
||||
Source: source,
|
||||
State: state,
|
||||
Recurse: recurse,
|
||||
Force: force,
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *FileRes) Default() Res {
|
||||
return &FileRes{
|
||||
|
||||
@@ -69,19 +69,6 @@ type HostnameRes struct {
|
||||
conn *dbus.Conn
|
||||
}
|
||||
|
||||
// NewHostnameRes is a constructor for this resource. It also calls Init() for you.
|
||||
func NewHostnameRes(name, staticHostname, transientHostname, prettyHostname string) (*HostnameRes, error) {
|
||||
obj := &HostnameRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
PrettyHostname: prettyHostname,
|
||||
StaticHostname: staticHostname,
|
||||
TransientHostname: transientHostname,
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *HostnameRes) Default() Res {
|
||||
return &HostnameRes{}
|
||||
|
||||
@@ -52,27 +52,6 @@ type MsgUID struct {
|
||||
body string
|
||||
}
|
||||
|
||||
// NewMsgRes is a constructor for this resource.
|
||||
func NewMsgRes(name, body, priority string, journal, syslog bool, fields map[string]string) (*MsgRes, error) {
|
||||
message := name
|
||||
if body != "" {
|
||||
message = body
|
||||
}
|
||||
|
||||
obj := &MsgRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
Body: message,
|
||||
Priority: priority,
|
||||
Fields: fields,
|
||||
Journal: journal,
|
||||
Syslog: syslog,
|
||||
}
|
||||
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *MsgRes) Default() Res {
|
||||
return &MsgRes{}
|
||||
|
||||
@@ -35,17 +35,6 @@ type NoopRes struct {
|
||||
Comment string `yaml:"comment"` // extra field for example purposes
|
||||
}
|
||||
|
||||
// NewNoopRes is a constructor for this resource. It also calls Init() for you.
|
||||
func NewNoopRes(name string) (*NoopRes, error) {
|
||||
obj := &NoopRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
Comment: "",
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *NoopRes) Default() Res {
|
||||
return &NoopRes{}
|
||||
|
||||
@@ -57,17 +57,6 @@ type NspawnRes struct {
|
||||
svc *SvcRes
|
||||
}
|
||||
|
||||
// NewNspawnRes is the constructor for this resource
|
||||
func NewNspawnRes(name string, state string) (*NspawnRes, error) {
|
||||
obj := &NspawnRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
State: state,
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *NspawnRes) Default() Res {
|
||||
return &NspawnRes{
|
||||
|
||||
@@ -56,17 +56,6 @@ type PasswordRes struct {
|
||||
recWatcher *recwatch.RecWatcher
|
||||
}
|
||||
|
||||
// NewPasswordRes is a constructor for this resource. It also calls Init() for you.
|
||||
func NewPasswordRes(name string, length uint16) (*PasswordRes, error) {
|
||||
obj := &PasswordRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
Length: length,
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *PasswordRes) Default() Res {
|
||||
return &PasswordRes{
|
||||
|
||||
@@ -46,20 +46,6 @@ type PkgRes struct {
|
||||
fileList []string // FIXME: update if pkg changes
|
||||
}
|
||||
|
||||
// NewPkgRes is a constructor for this resource. It also calls Init() for you.
|
||||
func NewPkgRes(name, state string, allowuntrusted, allownonfree, allowunsupported bool) (*PkgRes, error) {
|
||||
obj := &PkgRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
State: state,
|
||||
AllowUntrusted: allowuntrusted,
|
||||
AllowNonFree: allownonfree,
|
||||
AllowUnsupported: allowunsupported,
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *PkgRes) Default() Res {
|
||||
return &PkgRes{
|
||||
|
||||
@@ -44,18 +44,6 @@ type SvcRes struct {
|
||||
Startup string `yaml:"startup"` // enabled, disabled, undefined
|
||||
}
|
||||
|
||||
// NewSvcRes is a constructor for this resource. It also calls Init() for you.
|
||||
func NewSvcRes(name, state, startup string) (*SvcRes, error) {
|
||||
obj := &SvcRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
State: state,
|
||||
Startup: startup,
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *SvcRes) Default() Res {
|
||||
return &SvcRes{}
|
||||
|
||||
@@ -44,17 +44,6 @@ type TimerUID struct {
|
||||
name string
|
||||
}
|
||||
|
||||
// NewTimerRes is a constructor for this resource. It also calls Init() for you.
|
||||
func NewTimerRes(name string, interval uint32) (*TimerRes, error) {
|
||||
obj := &TimerRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
Interval: interval,
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *TimerRes) Default() Res {
|
||||
return &TimerRes{}
|
||||
|
||||
@@ -79,22 +79,6 @@ type VirtRes struct {
|
||||
uriScheme virtURISchemeType
|
||||
}
|
||||
|
||||
// NewVirtRes is a constructor for this resource. It also calls Init() for you.
|
||||
func NewVirtRes(name string, uri, state string, transient bool, cpus uint, memory uint64, osinit string) (*VirtRes, error) {
|
||||
obj := &VirtRes{
|
||||
BaseRes: BaseRes{
|
||||
Name: name,
|
||||
},
|
||||
URI: uri,
|
||||
State: state,
|
||||
Transient: transient,
|
||||
CPUs: cpus,
|
||||
Memory: memory,
|
||||
OSInit: osinit,
|
||||
}
|
||||
return obj, obj.Init()
|
||||
}
|
||||
|
||||
// Default returns some sensible defaults for this resource.
|
||||
func (obj *VirtRes) Default() Res {
|
||||
return &VirtRes{}
|
||||
|
||||
Reference in New Issue
Block a user