Skip to content
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

remove unused field for db's sake #3675

Open
wants to merge 2 commits into
base: release-3.0.0-0607
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/microservice/aslan/core/workflow/service/workflow/job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type JobCtl interface {
SetPreset() error
// SetOptions sets all the possible options for the workflow
SetOptions() error
// ClearOptions clears the option field to save space for db and memory
ClearOptions() error
ClearSelectionField() error
ToJobs(taskID int64) ([]*commonmodels.JobTask, error)
// MergeArgs merge the current workflow with the user input: args
Expand Down Expand Up @@ -182,6 +184,14 @@ func SetOptions(job *commonmodels.Job, workflow *commonmodels.WorkflowV4) error
return jobCtl.SetOptions()
}

func ClearOptions(job *commonmodels.Job, workflow *commonmodels.WorkflowV4) error {
jobCtl, err := InitJobCtl(job, workflow)
if err != nil {
return warpJobError(job.Name, err)
}
return jobCtl.ClearOptions()
}

func UpdateWithLatestSetting(job *commonmodels.Job, workflow *commonmodels.WorkflowV4) error {
jobCtl, err := InitJobCtl(job, workflow)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ func (j *ApolloJob) SetOptions() error {
return nil
}

func (j *ApolloJob) ClearOptions() error {
j.spec = &commonmodels.ApolloJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.NamespaceListOption = nil
j.job.Spec = j.spec
return nil
}

func (j *ApolloJob) ClearSelectionField() error {
j.spec = &commonmodels.ApolloJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ func (j *BlueGreenDeployV2Job) SetOptions() error {
return nil
}

func (j *BlueGreenDeployV2Job) ClearOptions() error {
j.spec = &commonmodels.BlueGreenDeployV2JobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.EnvOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *BlueGreenDeployV2Job) ClearSelectionField() error {
j.spec = &commonmodels.BlueGreenDeployV2JobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func (j *BlueGreenReleaseV2Job) SetOptions() error {
return nil
}

func (j *BlueGreenReleaseV2Job) ClearOptions() error {
return nil
}

func (j *BlueGreenReleaseV2Job) ClearSelectionField() error {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func (j *BlueKingJob) SetOptions() error {
return nil
}

func (j *BlueKingJob) ClearOptions() error {
return nil
}

func (j *BlueKingJob) ClearSelectionField() error {
j.spec = &commonmodels.BlueKingJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,17 @@ func (j *BuildJob) SetOptions() error {
return nil
}

func (j *BuildJob) ClearOptions() error {
j.spec = &commonmodels.ZadigBuildJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.ServiceAndBuildsOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *BuildJob) GetRepos() ([]*types.Repository, error) {
resp := []*types.Repository{}
j.spec = &commonmodels.ZadigBuildJobSpec{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ func (j *CanaryDeployJob) SetOptions() error {
return nil
}

func (j *CanaryDeployJob) ClearOptions() error {
j.spec = &commonmodels.CanaryDeployJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.TargetOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *CanaryDeployJob) ClearSelectionField() error {
j.spec = &commonmodels.CanaryDeployJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func (j *CanaryReleaseJob) SetOptions() error {
return nil
}

func (j *CanaryReleaseJob) ClearOptions() error {
return nil
}

func (j *CanaryReleaseJob) ClearSelectionField() error {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ func (j *CustomDeployJob) SetOptions() error {
return nil
}

func (j *CustomDeployJob) ClearOptions() error {
j.spec = &commonmodels.CustomDeployJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.TargetOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *CustomDeployJob) ClearSelectionField() error {
j.spec = &commonmodels.CustomDeployJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,17 @@ func (j *DeployJob) SetOptions() error {
return nil
}

func (j *DeployJob) ClearOptions() error {
j.spec = &commonmodels.ZadigDeployJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.EnvOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *DeployJob) ClearSelectionField() error {
j.spec = &commonmodels.ZadigDeployJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ func (j *ImageDistributeJob) SetOptions() error {
return nil
}

func (j *ImageDistributeJob) ClearOptions() error {
j.spec = &commonmodels.ZadigDistributeImageJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.TargetOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *ImageDistributeJob) ClearSelectionField() error {
j.spec = &commonmodels.ZadigDistributeImageJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func (j *FreeStyleJob) SetOptions() error {
return nil
}

func (j *FreeStyleJob) ClearOptions() error {
return nil
}

func (j *FreeStyleJob) ClearSelectionField() error {
j.spec = &commonmodels.FreestyleJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func (j *GrafanaJob) SetOptions() error {
return nil
}

func (j *GrafanaJob) ClearOptions() error {
return nil
}

func (j *GrafanaJob) ClearSelectionField() error {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ func (j *GrayReleaseJob) SetOptions() error {
return nil
}

func (j *GrayReleaseJob) ClearOptions() error {
j.spec = &commonmodels.GrayReleaseJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.TargetOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *GrayReleaseJob) ClearSelectionField() error {
j.spec = &commonmodels.GrayReleaseJobSpec{}
if err := commonmodels.IToiYaml(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ func (j *GrayRollbackJob) SetOptions() error {
return nil
}

func (j *GrayRollbackJob) ClearOptions() error {
j.spec = &commonmodels.GrayRollbackJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.Targets = make([]*commonmodels.GrayRollbackTarget, 0)
j.job.Spec = j.spec
return nil
}

func (j *GrayRollbackJob) ClearSelectionField() error {
j.spec = &commonmodels.GrayRollbackJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func (j *GuanceyunCheckJob) SetOptions() error {
return nil
}

func (j *GuanceyunCheckJob) ClearOptions() error {
return nil
}

func (j *GuanceyunCheckJob) ClearSelectionField() error {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ func (j *HelmChartDeployJob) SetOptions() error {
return nil
}

func (j *HelmChartDeployJob) ClearOptions() error {
j.spec = &commonmodels.ZadigHelmChartDeployJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.EnvOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *HelmChartDeployJob) ClearSelectionField() error {
j.spec = &commonmodels.ZadigHelmChartDeployJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ func (j *IstioReleaseJob) SetOptions() error {
return nil
}

func (j *IstioReleaseJob) ClearOptions() error {
j.spec = &commonmodels.IstioJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.TargetOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *IstioReleaseJob) ClearSelectionField() error {
j.spec = &commonmodels.IstioJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ func (j *IstioRollBackJob) SetOptions() error {
return nil
}

func (j *IstioRollBackJob) ClearOptions() error {
j.spec = &commonmodels.IstioRollBackJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.TargetOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *IstioRollBackJob) ClearSelectionField() error {
j.spec = &commonmodels.IstioRollBackJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ func (j *JenkinsJob) SetOptions() error {
return nil
}

func (j *JenkinsJob) ClearOptions() error {
return nil
}

func (j *JenkinsJob) ClearSelectionField() error {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func (j *JiraJob) SetOptions() error {
return nil
}

func (j *JiraJob) ClearOptions() error {
return nil
}

func (j *JiraJob) ClearSelectionField() error {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ func (j *K8sPacthJob) SetOptions() error {
return nil
}

func (j *K8sPacthJob) ClearOptions() error {
j.spec = &commonmodels.K8sPatchJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
return err
}

j.spec.PatchItemOptions = nil
j.job.Spec = j.spec
return nil
}

func (j *K8sPacthJob) ClearSelectionField() error {
j.spec = &commonmodels.K8sPatchJobSpec{}
if err := commonmodels.IToi(j.job.Spec, j.spec); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func (j *MeegoTransitionJob) SetOptions() error {
return nil
}

func (j *MeegoTransitionJob) ClearOptions() error {
return nil
}

func (j *MeegoTransitionJob) ClearSelectionField() error {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func (j *MseGrayOfflineJob) SetOptions() error {
return nil
}

func (j *MseGrayOfflineJob) ClearOptions() error {
return nil
}

func (j *MseGrayOfflineJob) ClearSelectionField() error {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func (j *MseGrayReleaseJob) SetOptions() error {
return nil
}

func (j *MseGrayReleaseJob) ClearOptions() error {
return nil
}

func (j *MseGrayReleaseJob) ClearSelectionField() error {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func (j *NacosJob) SetOptions() error {
return nil
}

func (j *NacosJob) ClearOptions() error {
return nil
}

func (j *NacosJob) ClearSelectionField() error {
return nil
}
Expand Down
Loading
Loading