Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Refactor OS type string as abstract interface #269

Open
bboreham opened this issue Jul 13, 2020 · 0 comments
Open

Refactor OS type string as abstract interface #269

bboreham opened this issue Jul 13, 2020 · 0 comments
Labels
tech-debt Unpleasantness that does (or may in future) affect development

Comments

@bboreham
Copy link
Contributor

This code, where we store a different string according to what we found:

switch osID {
case centOS:
return &OS{Name: osID, runner: &sudo.Runner{Runner: sshClient}, PkgType: resource.PkgTypeRPM}, nil
case rhel:
return &OS{Name: osID, runner: &sudo.Runner{Runner: sshClient}, PkgType: resource.PkgTypeRHEL}, nil
case ubuntu:
return &OS{Name: osID, runner: &sudo.Runner{Runner: sshClient}, PkgType: resource.PkgTypeDeb}, nil

then later switch on that string:

switch pkgType {
case resource.PkgTypeRPM, resource.PkgTypeRHEL:

switch pkgType {
case resource.PkgTypeRPM, resource.PkgTypeRHEL:
// do nothing
case resource.PkgTypeDeb:

seems like a classic case where we could instantiate an object of different concrete type behind an interface.

@bboreham bboreham added the tech-debt Unpleasantness that does (or may in future) affect development label Jul 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tech-debt Unpleasantness that does (or may in future) affect development
Projects
None yet
Development

No branches or pull requests

1 participant