|
@@ -768,48 +768,51 @@ func (app *App) HandleUpgradeRelease(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
release, err := app.Repo.Release.ReadRelease(uint(clusterID), name, rel.Namespace)
|
|
release, err := app.Repo.Release.ReadRelease(uint(clusterID), name, rel.Namespace)
|
|
|
- gitAction := release.GitActionConfig
|
|
|
|
|
|
|
|
|
|
- if release != nil && gitAction.ID != 0 {
|
|
|
|
|
- // parse env into build env
|
|
|
|
|
- cEnv := &ContainerEnvConfig{}
|
|
|
|
|
-
|
|
|
|
|
- yaml.Unmarshal([]byte(form.Values), cEnv)
|
|
|
|
|
-
|
|
|
|
|
- gr, err := app.Repo.GitRepo.ReadGitRepo(gitAction.GitRepoID)
|
|
|
|
|
-
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
|
|
- Code: ErrReleaseReadData,
|
|
|
|
|
- Errors: []string{"github repo integration not found"},
|
|
|
|
|
- }, w)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- repoSplit := strings.Split(gitAction.GitRepo, "/")
|
|
|
|
|
-
|
|
|
|
|
- gaRunner := &actions.GithubActions{
|
|
|
|
|
- GitIntegration: gr,
|
|
|
|
|
- GitRepoName: repoSplit[1],
|
|
|
|
|
- GitRepoOwner: repoSplit[0],
|
|
|
|
|
- Repo: *app.Repo,
|
|
|
|
|
- GithubConf: app.GithubProjectConf,
|
|
|
|
|
- WebhookToken: release.WebhookToken,
|
|
|
|
|
- ProjectID: uint(projID),
|
|
|
|
|
- ReleaseName: name,
|
|
|
|
|
- GitBranch: gitAction.GitBranch,
|
|
|
|
|
- DockerFilePath: gitAction.DockerfilePath,
|
|
|
|
|
- FolderPath: gitAction.FolderPath,
|
|
|
|
|
- ImageRepoURL: gitAction.ImageRepoURI,
|
|
|
|
|
- BuildEnv: cEnv.Container.Env.Normal,
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- err = gaRunner.CreateEnvSecret()
|
|
|
|
|
-
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
|
|
- Code: ErrReleaseReadData,
|
|
|
|
|
- Errors: []string{"could not update github secret"},
|
|
|
|
|
- }, w)
|
|
|
|
|
|
|
+ if release != nil {
|
|
|
|
|
+ gitAction := release.GitActionConfig
|
|
|
|
|
+
|
|
|
|
|
+ if gitAction.ID != 0 {
|
|
|
|
|
+ // parse env into build env
|
|
|
|
|
+ cEnv := &ContainerEnvConfig{}
|
|
|
|
|
+
|
|
|
|
|
+ yaml.Unmarshal([]byte(form.Values), cEnv)
|
|
|
|
|
+
|
|
|
|
|
+ gr, err := app.Repo.GitRepo.ReadGitRepo(gitAction.GitRepoID)
|
|
|
|
|
+
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
|
|
+ Code: ErrReleaseReadData,
|
|
|
|
|
+ Errors: []string{"github repo integration not found"},
|
|
|
|
|
+ }, w)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ repoSplit := strings.Split(gitAction.GitRepo, "/")
|
|
|
|
|
+
|
|
|
|
|
+ gaRunner := &actions.GithubActions{
|
|
|
|
|
+ GitIntegration: gr,
|
|
|
|
|
+ GitRepoName: repoSplit[1],
|
|
|
|
|
+ GitRepoOwner: repoSplit[0],
|
|
|
|
|
+ Repo: *app.Repo,
|
|
|
|
|
+ GithubConf: app.GithubProjectConf,
|
|
|
|
|
+ WebhookToken: release.WebhookToken,
|
|
|
|
|
+ ProjectID: uint(projID),
|
|
|
|
|
+ ReleaseName: name,
|
|
|
|
|
+ GitBranch: gitAction.GitBranch,
|
|
|
|
|
+ DockerFilePath: gitAction.DockerfilePath,
|
|
|
|
|
+ FolderPath: gitAction.FolderPath,
|
|
|
|
|
+ ImageRepoURL: gitAction.ImageRepoURI,
|
|
|
|
|
+ BuildEnv: cEnv.Container.Env.Normal,
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ err = gaRunner.CreateEnvSecret()
|
|
|
|
|
+
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
|
|
+ Code: ErrReleaseReadData,
|
|
|
|
|
+ Errors: []string{"could not update github secret"},
|
|
|
|
|
+ }, w)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1013,63 +1016,66 @@ func (app *App) HandleRollbackRelease(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
release, err := app.Repo.Release.ReadRelease(uint(clusterID), name, rel.Namespace)
|
|
release, err := app.Repo.Release.ReadRelease(uint(clusterID), name, rel.Namespace)
|
|
|
- gitAction := release.GitActionConfig
|
|
|
|
|
-
|
|
|
|
|
- if release != nil && gitAction.ID != 0 {
|
|
|
|
|
- // parse env into build env
|
|
|
|
|
- cEnv := &ContainerEnvConfig{}
|
|
|
|
|
- rawValues, err := yaml.Marshal(rel.Config)
|
|
|
|
|
-
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
|
|
- Code: ErrReleaseReadData,
|
|
|
|
|
- Errors: []string{"could not get values of previous revision"},
|
|
|
|
|
- }, w)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- yaml.Unmarshal(rawValues, cEnv)
|
|
|
|
|
-
|
|
|
|
|
- gr, err := app.Repo.GitRepo.ReadGitRepo(gitAction.GitRepoID)
|
|
|
|
|
-
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
|
|
- Code: ErrReleaseReadData,
|
|
|
|
|
- Errors: []string{"github repo integration not found"},
|
|
|
|
|
- }, w)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- repoSplit := strings.Split(gitAction.GitRepo, "/")
|
|
|
|
|
-
|
|
|
|
|
- projID, err := strconv.ParseUint(chi.URLParam(r, "project_id"), 0, 64)
|
|
|
|
|
|
|
|
|
|
- if err != nil || projID == 0 {
|
|
|
|
|
- app.handleErrorFormDecoding(err, ErrProjectDecode, w)
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- gaRunner := &actions.GithubActions{
|
|
|
|
|
- GitIntegration: gr,
|
|
|
|
|
- GitRepoName: repoSplit[1],
|
|
|
|
|
- GitRepoOwner: repoSplit[0],
|
|
|
|
|
- Repo: *app.Repo,
|
|
|
|
|
- GithubConf: app.GithubProjectConf,
|
|
|
|
|
- WebhookToken: release.WebhookToken,
|
|
|
|
|
- ProjectID: uint(projID),
|
|
|
|
|
- ReleaseName: name,
|
|
|
|
|
- GitBranch: gitAction.GitBranch,
|
|
|
|
|
- DockerFilePath: gitAction.DockerfilePath,
|
|
|
|
|
- FolderPath: gitAction.FolderPath,
|
|
|
|
|
- ImageRepoURL: gitAction.ImageRepoURI,
|
|
|
|
|
- BuildEnv: cEnv.Container.Env.Normal,
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- err = gaRunner.CreateEnvSecret()
|
|
|
|
|
-
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
|
|
- Code: ErrReleaseReadData,
|
|
|
|
|
- Errors: []string{"could not update github secret"},
|
|
|
|
|
- }, w)
|
|
|
|
|
|
|
+ if release != nil {
|
|
|
|
|
+ gitAction := release.GitActionConfig
|
|
|
|
|
+
|
|
|
|
|
+ if gitAction.ID != 0 {
|
|
|
|
|
+ // parse env into build env
|
|
|
|
|
+ cEnv := &ContainerEnvConfig{}
|
|
|
|
|
+ rawValues, err := yaml.Marshal(rel.Config)
|
|
|
|
|
+
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
|
|
+ Code: ErrReleaseReadData,
|
|
|
|
|
+ Errors: []string{"could not get values of previous revision"},
|
|
|
|
|
+ }, w)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ yaml.Unmarshal(rawValues, cEnv)
|
|
|
|
|
+
|
|
|
|
|
+ gr, err := app.Repo.GitRepo.ReadGitRepo(gitAction.GitRepoID)
|
|
|
|
|
+
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
|
|
+ Code: ErrReleaseReadData,
|
|
|
|
|
+ Errors: []string{"github repo integration not found"},
|
|
|
|
|
+ }, w)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ repoSplit := strings.Split(gitAction.GitRepo, "/")
|
|
|
|
|
+
|
|
|
|
|
+ projID, err := strconv.ParseUint(chi.URLParam(r, "project_id"), 0, 64)
|
|
|
|
|
+
|
|
|
|
|
+ if err != nil || projID == 0 {
|
|
|
|
|
+ app.handleErrorFormDecoding(err, ErrProjectDecode, w)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ gaRunner := &actions.GithubActions{
|
|
|
|
|
+ GitIntegration: gr,
|
|
|
|
|
+ GitRepoName: repoSplit[1],
|
|
|
|
|
+ GitRepoOwner: repoSplit[0],
|
|
|
|
|
+ Repo: *app.Repo,
|
|
|
|
|
+ GithubConf: app.GithubProjectConf,
|
|
|
|
|
+ WebhookToken: release.WebhookToken,
|
|
|
|
|
+ ProjectID: uint(projID),
|
|
|
|
|
+ ReleaseName: name,
|
|
|
|
|
+ GitBranch: gitAction.GitBranch,
|
|
|
|
|
+ DockerFilePath: gitAction.DockerfilePath,
|
|
|
|
|
+ FolderPath: gitAction.FolderPath,
|
|
|
|
|
+ ImageRepoURL: gitAction.ImageRepoURI,
|
|
|
|
|
+ BuildEnv: cEnv.Container.Env.Normal,
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ err = gaRunner.CreateEnvSecret()
|
|
|
|
|
+
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ app.sendExternalError(err, http.StatusInternalServerError, HTTPError{
|
|
|
|
|
+ Code: ErrReleaseReadData,
|
|
|
|
|
+ Errors: []string{"could not update github secret"},
|
|
|
|
|
+ }, w)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|