-
Notifications
You must be signed in to change notification settings - Fork 183
[SDK] Add type parameter for DeploymentSource and unmarshalling the spec #5740
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
Changes from 30 commits
e5dda81
f9e47e0
629d27e
e1c797b
77fb2c1
9b2aef2
3dd620a
7624171
f2e80ad
419eab1
afc87ac
e9fbf82
900f69f
1e28d94
03cecc8
b3ff4ce
2405095
91a7527
b0f18f8
1a0fdbb
fd6e873
797e588
dccdae5
be77e83
0cec7a9
384a0f9
e710fd4
d152c23
2f52c38
3ed79a2
c92050d
5abbdd5
53ef850
30bd753
4885a40
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 |
---|---|---|
|
@@ -41,18 +41,20 @@ func TestPlugin_executeK8sRollbackStage_NoPreviousDeployment(t *testing.T) { | |
dtConfig, _ := setupTestDeployTargetConfigAndDynamicClient(t) | ||
|
||
// Read the application config from the example file | ||
cfg, err := os.ReadFile(filepath.Join(examplesDir(), "kubernetes", "simple", "app.pipecd.yaml")) | ||
cfgBytes, err := os.ReadFile(filepath.Join(examplesDir(), "kubernetes", "simple", "app.pipecd.yaml")) | ||
require.NoError(t, err) | ||
cfg, err := sdk.DecodeYAML[kubeConfigPkg.KubernetesApplicationSpec](cfgBytes) | ||
require.NoError(t, err) | ||
|
||
// Prepare the input | ||
input := &sdk.ExecuteStageInput{ | ||
Request: sdk.ExecuteStageRequest{ | ||
input := &sdk.ExecuteStageInput[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
Request: sdk.ExecuteStageRequest[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
StageName: "K8S_ROLLBACK", | ||
StageConfig: []byte(``), | ||
RunningDeploymentSource: sdk.DeploymentSource{ | ||
RunningDeploymentSource: sdk.DeploymentSource[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
CommitHash: "", // Empty commit hash indicates no previous deployment | ||
}, | ||
TargetDeploymentSource: sdk.DeploymentSource{ | ||
TargetDeploymentSource: sdk.DeploymentSource[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
ApplicationDirectory: filepath.Join(examplesDir(), "kubernetes", "simple"), | ||
CommitHash: "0123456789", | ||
ApplicationConfig: cfg, | ||
|
@@ -88,21 +90,23 @@ func TestPlugin_executeK8sRollbackStage_SuccessfulRollback(t *testing.T) { | |
dtConfig, dynamicClient := setupTestDeployTargetConfigAndDynamicClient(t) | ||
|
||
// Read the application config from the example file | ||
cfg, err := os.ReadFile(filepath.Join(examplesDir(), "kubernetes", "simple", "app.pipecd.yaml")) | ||
cfgBytes, err := os.ReadFile(filepath.Join(examplesDir(), "kubernetes", "simple", "app.pipecd.yaml")) | ||
require.NoError(t, err) | ||
cfg, err := sdk.DecodeYAML[kubeConfigPkg.KubernetesApplicationSpec](cfgBytes) | ||
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. [imo] 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. I agree with you, so I added sdk.LoadApplicationConfig and removed sdk.DecodeYAML 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. @Warashi
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. It sounds good. 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. @Warashi Sounds great!!! Let's go with that! 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. 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. Sounds nice! That's a nice improvement! |
||
require.NoError(t, err) | ||
|
||
// Prepare the input | ||
input := &sdk.ExecuteStageInput{ | ||
Request: sdk.ExecuteStageRequest{ | ||
input := &sdk.ExecuteStageInput[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
Request: sdk.ExecuteStageRequest[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
StageName: "K8S_ROLLBACK", | ||
StageConfig: []byte(``), | ||
RunningDeploymentSource: sdk.DeploymentSource{ | ||
RunningDeploymentSource: sdk.DeploymentSource[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
ApplicationDirectory: filepath.Join(examplesDir(), "kubernetes", "simple"), | ||
CommitHash: "previous-hash", | ||
ApplicationConfig: cfg, | ||
ApplicationConfigFilename: "app.pipecd.yaml", | ||
}, | ||
TargetDeploymentSource: sdk.DeploymentSource{ | ||
TargetDeploymentSource: sdk.DeploymentSource[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
ApplicationDirectory: filepath.Join(examplesDir(), "kubernetes", "simple"), | ||
CommitHash: "0123456789", | ||
ApplicationConfig: cfg, | ||
|
@@ -155,21 +159,23 @@ func TestPlugin_executeK8sRollbackStage_WithVariantLabels(t *testing.T) { | |
dtConfig, dynamicClient := setupTestDeployTargetConfigAndDynamicClient(t) | ||
|
||
// Read the application config and modify it to include variant labels | ||
cfg, err := os.ReadFile(filepath.Join(examplesDir(), "kubernetes", "simple", "app.pipecd.yaml")) | ||
cfgBytes, err := os.ReadFile(filepath.Join(examplesDir(), "kubernetes", "simple", "app.pipecd.yaml")) | ||
require.NoError(t, err) | ||
cfg, err := sdk.DecodeYAML[kubeConfigPkg.KubernetesApplicationSpec](cfgBytes) | ||
require.NoError(t, err) | ||
|
||
// Prepare the input | ||
input := &sdk.ExecuteStageInput{ | ||
Request: sdk.ExecuteStageRequest{ | ||
input := &sdk.ExecuteStageInput[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
Request: sdk.ExecuteStageRequest[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
StageName: "K8S_ROLLBACK", | ||
StageConfig: []byte(``), | ||
RunningDeploymentSource: sdk.DeploymentSource{ | ||
RunningDeploymentSource: sdk.DeploymentSource[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
ApplicationDirectory: filepath.Join(examplesDir(), "kubernetes", "simple"), | ||
CommitHash: "previous-hash", | ||
ApplicationConfig: cfg, | ||
ApplicationConfigFilename: "app.pipecd.yaml", | ||
}, | ||
TargetDeploymentSource: sdk.DeploymentSource{ | ||
TargetDeploymentSource: sdk.DeploymentSource[kubeConfigPkg.KubernetesApplicationSpec]{ | ||
ApplicationDirectory: filepath.Join(examplesDir(), "kubernetes", "simple"), | ||
CommitHash: "0123456789", | ||
ApplicationConfig: cfg, | ||
|
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.
[imo] It would be nice to add a method into DeploySource to get ApplicationConfig from DeploySource, including a nil check because
ApplicationConfig
is a pointer.WDYT?
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.
I agree with you and I added AppConfig method
53ef850