Don't require nodeup tasks to have SetName()

This commit is contained in:
John Gardiner Myers 2020-06-05 22:14:30 -07:00
parent cd8681ccd0
commit 852e70f54d
12 changed files with 6 additions and 42 deletions

View File

@ -466,7 +466,7 @@ func (l *Loader) loadObjectMap(key string, data map[string]interface{}) (map[str
klog.V(4).Infof("Built %s:%s => %v", key, k, o.Interface()) klog.V(4).Infof("Built %s:%s => %v", key, k, o.Interface())
if inferredName { if inferredName {
hn, ok := o.Interface().(fi.HasName) hn, ok := o.Interface().(fi.HasSetName)
if ok { if ok {
hn.SetName(name) hn.SetName(name)
} }

View File

@ -16,8 +16,12 @@ limitations under the License.
package fi package fi
// HasName indicates that the task has a Name // HasName indicates that the task has a Name.
type HasName interface { type HasName interface {
GetName() *string GetName() *string
}
// HasSetName indicates that the task can set its Name.
type HasSetName interface {
SetName(name string) SetName(name string)
} }

View File

@ -77,10 +77,6 @@ func (e *Archive) GetName() *string {
return &e.Name return &e.Name
} }
func (e *Archive) SetName(name string) {
e.Name = name
}
// String returns a string representation, implementing the Stringer interface // String returns a string representation, implementing the Stringer interface
func (e *Archive) String() string { func (e *Archive) String() string {
return fmt.Sprintf("Archive: %s %s->%s", e.Name, e.Source, e.TargetDir) return fmt.Sprintf("Archive: %s %s->%s", e.Name, e.Source, e.TargetDir)

View File

@ -55,10 +55,6 @@ func (e *BindMount) GetName() *string {
return fi.String("BindMount-" + e.Mountpoint) return fi.String("BindMount-" + e.Mountpoint)
} }
func (e *BindMount) SetName(name string) {
klog.Fatalf("SetName not supported for BindMount task")
}
var _ fi.HasDependencies = &BindMount{} var _ fi.HasDependencies = &BindMount{}
// GetDependencies implements HasDependencies::GetDependencies // GetDependencies implements HasDependencies::GetDependencies

View File

@ -46,10 +46,6 @@ func (e *Chattr) GetName() *string {
return fi.String("Chattr-" + e.File) return fi.String("Chattr-" + e.File)
} }
func (e *Chattr) SetName(name string) {
klog.Fatalf("SetName not supported for Chattr task")
}
var _ fi.HasDependencies = &Chattr{} var _ fi.HasDependencies = &Chattr{}
// GetDependencies implements HasDependencies::GetDependencies // GetDependencies implements HasDependencies::GetDependencies

View File

@ -122,10 +122,6 @@ func (f *File) GetName() *string {
return &f.Path return &f.Path
} }
func (f *File) SetName(name string) {
klog.Fatalf("SetName not supported for File task")
}
func (f *File) String() string { func (f *File) String() string {
return fmt.Sprintf("File: %q", f.Path) return fmt.Sprintf("File: %q", f.Path)
} }

View File

@ -47,10 +47,6 @@ func (f *GroupTask) GetName() *string {
return &f.Name return &f.Name
} }
func (f *GroupTask) SetName(name string) {
klog.Fatalf("SetName not supported for Group task")
}
func (e *GroupTask) Find(c *fi.Context) (*GroupTask, error) { func (e *GroupTask) Find(c *fi.Context) (*GroupTask, error) {
info, err := fi.LookupGroup(e.Name) info, err := fi.LookupGroup(e.Name)
if err != nil { if err != nil {

View File

@ -48,10 +48,6 @@ func (i *IssueCert) GetName() *string {
return &i.Name return &i.Name
} }
func (i *IssueCert) SetName(name string) {
i.Name = name
}
// String returns a string representation, implementing the Stringer interface // String returns a string representation, implementing the Stringer interface
func (i *IssueCert) String() string { func (i *IssueCert) String() string {
return fmt.Sprintf("IssueCert: %s", i.Name) return fmt.Sprintf("IssueCert: %s", i.Name)

View File

@ -74,10 +74,6 @@ func (t *LoadImageTask) GetName() *string {
return &t.Name return &t.Name
} }
func (t *LoadImageTask) SetName(name string) {
klog.Fatalf("SetName not supported for LoadImageTask")
}
func (t *LoadImageTask) String() string { func (t *LoadImageTask) String() string {
return fmt.Sprintf("LoadImageTask: %v", t.Sources) return fmt.Sprintf("LoadImageTask: %v", t.Sources)
} }

View File

@ -117,10 +117,6 @@ func (f *Package) GetName() *string {
return &f.Name return &f.Name
} }
func (f *Package) SetName(name string) {
f.Name = name
}
// isOSPackage returns true if this is an OS provided package (as opposed to a bare .deb, for example) // isOSPackage returns true if this is an OS provided package (as opposed to a bare .deb, for example)
func (p *Package) isOSPackage() bool { func (p *Package) isOSPackage() bool {
return fi.StringValue(p.Source) == "" return fi.StringValue(p.Source) == ""

View File

@ -381,7 +381,3 @@ var _ fi.HasName = &Service{}
func (f *Service) GetName() *string { func (f *Service) GetName() *string {
return &f.Name return &f.Name
} }
func (f *Service) SetName(name string) {
klog.Fatalf("SetName not supported for Service task")
}

View File

@ -49,10 +49,6 @@ func (f *UserTask) GetName() *string {
return &f.Name return &f.Name
} }
func (f *UserTask) SetName(name string) {
klog.Fatalf("SetName not supported for User task")
}
func (e *UserTask) Find(c *fi.Context) (*UserTask, error) { func (e *UserTask) Find(c *fi.Context) (*UserTask, error) {
info, err := fi.LookupUser(e.Name) info, err := fi.LookupUser(e.Name)
if err != nil { if err != nil {