-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring: Support of different deployments kind #30
base: master
Are you sure you want to change the base?
Changes from 1 commit
adfa042
717f852
37baa39
f5a2f5a
34a2726
9e67db0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package upgradeagent | ||
|
||
type dockerComposeDeployment struct { | ||
upgradeInfo *UpstreamResponseUpgradeInfo | ||
upstreamClient UpstreamClient | ||
} | ||
|
||
// NewDockerComposeDeployment creates a new instance of docker-compose deployment kind. | ||
func NewDockerComposeDeployment(upstreamServiceClient UpstreamClient) DeploymentClient { | ||
return &dockerComposeDeployment{upgradeInfo: NewUpstreamResponseUpgradeInfo(), upstreamClient: upstreamServiceClient} | ||
} | ||
|
||
// UpgradeCheck do check if there is a new version of the current solution available | ||
func (d *dockerComposeDeployment) UpgradeCheck(localSolutionInfo LocalSolutionInfo) bool { | ||
if upgradeInfo, isNewVersion := d.upstreamClient.RequestUpgrade(localSolutionInfo); isNewVersion { | ||
d.upgradeInfo = upgradeInfo | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// Upgrade does upgrade the current solution | ||
func (d *dockerComposeDeployment) Upgrade() error { | ||
return nil | ||
} | ||
|
||
// Rollback does rollback the current solution to the previous state in case both upgrade or health check is fails | ||
func (d *dockerComposeDeployment) Rollback() { | ||
// TBD | ||
} | ||
|
||
// HealthCheck does a health check of the current solution after the upgrade | ||
func (d *dockerComposeDeployment) HealthCheck() bool { | ||
d.upgradeInfo.HealthCheckStatus = Unhealthy | ||
return false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package upgradeagent | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would suggest file names in snake case. kubernetes_deployment.go There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. |
||
type kubernetesDeployment struct { | ||
upgradeInfo *UpstreamResponseUpgradeInfo | ||
upstreamClient UpstreamClient | ||
} | ||
|
||
// NewKubernetesDeployment creates a new instance of kubernetes deployment kind. | ||
func NewKubernetesDeployment(upstreamServiceClient UpstreamClient) DeploymentClient { | ||
return &kubernetesDeployment{upgradeInfo: NewUpstreamResponseUpgradeInfo(), upstreamClient: upstreamServiceClient} | ||
} | ||
|
||
// UpgradeCheck do check if there is a new version of the current solution available | ||
func (d *kubernetesDeployment) UpgradeCheck(localSolutionInfo LocalSolutionInfo) bool { | ||
if upgradeInfo, isNewVersion := d.upstreamClient.RequestUpgrade(localSolutionInfo); isNewVersion { | ||
d.upgradeInfo = upgradeInfo | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// Upgrade does upgrade the current solution | ||
func (d *kubernetesDeployment) Upgrade() error { | ||
return nil | ||
} | ||
|
||
// Rollback does rollback the current solution to the previous state in case both upgrade or health check is fails | ||
func (d *kubernetesDeployment) Rollback() { | ||
// TBD | ||
} | ||
|
||
// HealthCheck does a health check of the current solution after the upgrade | ||
func (d *kubernetesDeployment) HealthCheck() bool { | ||
d.upgradeInfo.HealthCheckStatus = Unhealthy | ||
return false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package upgradeagent | ||
|
||
type mockUpstreamClient struct { | ||
} | ||
|
||
// NewMockUpstreamClient returns a new instance of mock upstream service client | ||
func NewMockUpstreamClient() UpstreamClient { | ||
return mockUpstreamClient{} | ||
} | ||
|
||
// RequestUpgrade implements the transport layer between Patrao and mocked upstream service | ||
func (mock mockUpstreamClient) RequestUpgrade(solutionInfo LocalSolutionInfo) (*UpstreamResponseUpgradeInfo, bool) { | ||
return nil, false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,19 @@ import ( | |
"time" | ||
) | ||
|
||
// DeploymentClient is a common interface for any deployment kinds. | ||
type DeploymentClient interface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whose client is this interface? Which is the server? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The client of this interface is the Patrao agent. It's not implemented yet. I'm working on it now. I suppose Today evening or Monday morning I'll commit these changes. |
||
UpgradeCheck(LocalSolutionInfo) bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would suggest that the names of functions be
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. I'll do changes. |
||
Upgrade() error | ||
HealthCheck() bool | ||
Rollback() | ||
} | ||
|
||
// UpstreamClient is a common interface for any upstream service kinds | ||
type UpstreamClient interface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whose client is this interface? Which is the server? Who uses this interface / calls its methods? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The client of this interface is DeploymentClient. We pass UpstreamClient while creation of DeploymentClient instance and then created instance calls RequestUpgrade() functions. For example, please see func (d *dockerComposeDeployment) UpgradeCheck(localSolutionInfo LocalSolutionInfo) bool implementation. As for the server (ip:port) it will be received from the command line arguments inside the implementation of mockUpstreamClient. Actually in the same way how it's working now. |
||
RequestUpgrade(LocalSolutionInfo) (*UpstreamResponseUpgradeInfo, bool) | ||
} | ||
|
||
// KindType Kind type for all structures | ||
type KindType string | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would suggest file names in snake case.
docker_compose_deployment.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I'll rename the files.