Skip to content

Commit

Permalink
Don't require nodeup tasks to have SetName()
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers committed Jun 8, 2020
1 parent cd8681c commit 852e70f
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 42 deletions.
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

if inferredName {
hn, ok := o.Interface().(fi.HasName)
hn, ok := o.Interface().(fi.HasSetName)
if ok {
hn.SetName(name)
}
Expand Down
6 changes: 5 additions & 1 deletion upup/pkg/fi/named.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ limitations under the License.

package fi

// HasName indicates that the task has a Name
// HasName indicates that the task has a Name.
type HasName interface {
GetName() *string
}

// HasSetName indicates that the task can set its Name.
type HasSetName interface {
SetName(name string)
}
4 changes: 0 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ func (e *Archive) GetName() *string {
return &e.Name
}

func (e *Archive) SetName(name string) {
e.Name = name
}

// String returns a string representation, implementing the Stringer interface
func (e *Archive) String() string {
return fmt.Sprintf("Archive: %s %s->%s", e.Name, e.Source, e.TargetDir)
Expand Down
4 changes: 0 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/bindmount.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ func (e *BindMount) GetName() *string {
return fi.String("BindMount-" + e.Mountpoint)
}

func (e *BindMount) SetName(name string) {
klog.Fatalf("SetName not supported for BindMount task")
}

var _ fi.HasDependencies = &BindMount{}

// GetDependencies implements HasDependencies::GetDependencies
Expand Down
4 changes: 0 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/chattr.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ func (e *Chattr) GetName() *string {
return fi.String("Chattr-" + e.File)
}

func (e *Chattr) SetName(name string) {
klog.Fatalf("SetName not supported for Chattr task")
}

var _ fi.HasDependencies = &Chattr{}

// GetDependencies implements HasDependencies::GetDependencies
Expand Down
4 changes: 0 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ func (f *File) GetName() *string {
return &f.Path
}

func (f *File) SetName(name string) {
klog.Fatalf("SetName not supported for File task")
}

func (f *File) String() string {
return fmt.Sprintf("File: %q", f.Path)
}
Expand Down
4 changes: 0 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ func (f *GroupTask) GetName() *string {
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) {
info, err := fi.LookupGroup(e.Name)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/issue_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ func (i *IssueCert) GetName() *string {
return &i.Name
}

func (i *IssueCert) SetName(name string) {
i.Name = name
}

// String returns a string representation, implementing the Stringer interface
func (i *IssueCert) String() string {
return fmt.Sprintf("IssueCert: %s", i.Name)
Expand Down
4 changes: 0 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/load_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ func (t *LoadImageTask) GetName() *string {
return &t.Name
}

func (t *LoadImageTask) SetName(name string) {
klog.Fatalf("SetName not supported for LoadImageTask")
}

func (t *LoadImageTask) String() string {
return fmt.Sprintf("LoadImageTask: %v", t.Sources)
}
Expand Down
4 changes: 0 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,6 @@ func (f *Package) GetName() *string {
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)
func (p *Package) isOSPackage() bool {
return fi.StringValue(p.Source) == ""
Expand Down
4 changes: 0 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,3 @@ var _ fi.HasName = &Service{}
func (f *Service) GetName() *string {
return &f.Name
}

func (f *Service) SetName(name string) {
klog.Fatalf("SetName not supported for Service task")
}
4 changes: 0 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ func (f *UserTask) GetName() *string {
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) {
info, err := fi.LookupUser(e.Name)
if err != nil {
Expand Down

0 comments on commit 852e70f

Please sign in to comment.