Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Refactor custom wrapper structs into types #94

Open
elmiko opened this issue Nov 3, 2017 · 0 comments
Open

Refactor custom wrapper structs into types #94

elmiko opened this issue Nov 3, 2017 · 0 comments

Comments

@elmiko
Copy link
Contributor

elmiko commented Nov 3, 2017

There are several helper structs that are thin wrappers around kubernetes primitives. These structs don't add any members and are being used to create methods that extend the original kubernetes structs. This behavior could be made simpler by removing the extra struct declarations and instead making these types.

For example, in core/deploymentconfigs/deploymentconfigs.go this:

type ODeploymentConfig struct {
    api.DeploymentConfig
}

would be refactored into

type ODeploymentConfig api.DeploymentConfig

To make this change we will need to adjust how some of the methods that operate on the underlying struct work. Primarily, we should rename methods that have the same name as underlying members. These methods should change their names to reflect their status as setters.

For example, in helpers/containers/containers.go this:

func (c *OContainer) Command(args ...string) *OContainer {
    c.Container.Command = args
    return c
}

would be refactored into

func (c *OContainer) SetCommand(args ...string) *OContainer {
    c.Command = args
    return c
}

This would make the code more explicit in its functionality and allow access to the kubernetes primitives in a cleaner manner.

migrated from radanalyticsio/oshinko-rest#65

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

No branches or pull requests

1 participant