Skip to content

Commit

Permalink
fix loading previous v1beta1 helmcharts
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh committed Dec 20, 2023
1 parent f9c9c06 commit b0b5860
Show file tree
Hide file tree
Showing 28 changed files with 311 additions and 87 deletions.
2 changes: 1 addition & 1 deletion pkg/airgap/airgap.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func CreateAppFromAirgap(opts CreateAirgapAppOpts) (finalError error) {
return errors.Wrap(err, "failed to create support bundle dependencies")
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(tmpRoot)
kotsKinds, err := kotsutil.LoadKotsKinds(tmpRoot)
if err != nil {
return errors.Wrap(err, "failed to load kotskinds from path")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/airgap/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func UpdateAppFromPath(a *apptypes.App, airgapRoot string, airgapBundlePath stri
}
defer os.RemoveAll(archiveDir)

beforeKotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
beforeKotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
return errors.Wrap(err, "failed to load current kotskinds")
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func UpdateAppFromPath(a *apptypes.App, airgapRoot string, airgapBundlePath stri
}
}

afterKotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
afterKotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
return errors.Wrap(err, "failed to read after kotskinds")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/gitops/gitops.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ func getAuth(privateKey string) (transport.AuthMethod, error) {
}

func CreateGitOpsCommit(gitOpsConfig *GitOpsConfig, appSlug string, appName string, newSequence int, archiveDir string, downstreamName string) (string, error) {
kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
return "", errors.Wrap(err, "failed to load kots kinds")
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/handlers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func (h *Handler) LiveAppConfig(w http.ResponseWriter, r *http.Request) {
return
}

kotsKinds, err = kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err = kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
liveAppConfigResponse.Error = "failed to load kots kinds from path"
logger.Error(errors.Wrap(err, liveAppConfigResponse.Error))
Expand Down Expand Up @@ -607,7 +607,7 @@ func (h *Handler) CurrentAppConfig(w http.ResponseWriter, r *http.Request) {
return
}

kotsKinds, err = kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err = kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
currentAppConfigResponse.Error = "failed to load kots kinds from path"
logger.Error(errors.Wrap(err, currentAppConfigResponse.Error))
Expand Down Expand Up @@ -749,7 +749,7 @@ func getAppConfigValueForFile(downloadApp *apptypes.App, sequence int64, filenam
return "", errors.Wrap(err, "failed to get app version archive")
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
return "", errors.Wrap(err, "failed to load kots kinds from archive")
}
Expand Down Expand Up @@ -783,7 +783,7 @@ func updateAppConfig(updateApp *apptypes.App, sequence int64, configGroups []kot
return updateAppConfigResponse, err
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
updateAppConfigResponse.Error = "failed to load kots kinds from path"
return updateAppConfigResponse, err
Expand All @@ -810,7 +810,7 @@ func updateAppConfig(updateApp *apptypes.App, sequence int64, configGroups []kot
return updateAppConfigResponse, err
}

if err := ioutil.WriteFile(filepath.Join(archiveDir, "upstream", "userdata", "config.yaml"), []byte(configValuesSpec), 0644); err != nil {
if err := os.WriteFile(filepath.Join(archiveDir, "upstream", "userdata", "config.yaml"), []byte(configValuesSpec), 0644); err != nil {
updateAppConfigResponse.Error = "failed to write config.yaml to upstream/userdata"
return updateAppConfigResponse, err
}
Expand Down Expand Up @@ -1079,7 +1079,7 @@ func (h *Handler) SetAppConfigValues(w http.ResponseWriter, r *http.Request) {
return
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
setAppConfigValuesResponse.Error = "failed to load kots kinds from path"
logger.Error(errors.Wrap(err, setAppConfigValuesResponse.Error))
Expand Down
2 changes: 1 addition & 1 deletion pkg/handlers/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (h *Handler) DownloadApp(w http.ResponseWriter, r *http.Request) {
}

if decryptPasswordValues {
kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archivePath)
kotsKinds, err := kotsutil.LoadKotsKinds(archivePath)
if err != nil {
logger.Error(err)
w.WriteHeader(500)
Expand Down
8 changes: 4 additions & 4 deletions pkg/handlers/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (h *Handler) ConfigureAppIdentityService(w http.ResponseWriter, r *http.Req
return
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
err = errors.Wrap(err, "failed to load kots kinds from path")
logger.Error(err)
Expand Down Expand Up @@ -312,7 +312,7 @@ func (h *Handler) ConfigureAppIdentityService(w http.ResponseWriter, r *http.Req
return
}

b, err := ioutil.ReadFile(identityConfigFile)
b, err := os.ReadFile(identityConfigFile)
if err != nil {
err = errors.Wrap(err, "failed to read identityconfig file")
logger.Error(err)
Expand Down Expand Up @@ -424,7 +424,7 @@ func (h *Handler) ConfigureAppIdentityService(w http.ResponseWriter, r *http.Req
return
}

if err := ioutil.WriteFile(filepath.Join(archiveDir, "upstream", "userdata", "identityconfig.yaml"), []byte(identityConfigSpec), 0644); err != nil {
if err := os.WriteFile(filepath.Join(archiveDir, "upstream", "userdata", "identityconfig.yaml"), []byte(identityConfigSpec), 0644); err != nil {
err = errors.Wrap(err, "failed to write identityconfig.yaml to upstream/userdata")
logger.Error(err)
w.WriteHeader(http.StatusInternalServerError)
Expand Down Expand Up @@ -680,7 +680,7 @@ func (h *Handler) GetAppIdentityServiceConfig(w http.ResponseWriter, r *http.Req
return
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
err = errors.Wrap(err, "failed to load kotskinds from path")
logger.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/handlers/preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (h *Handler) GetPreflightCommand(w http.ResponseWriter, r *http.Request) {
return
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archivePath)
kotsKinds, err := kotsutil.LoadKotsKinds(archivePath)
if err != nil {
logger.Error(errors.Wrap(err, "failed to load kots kinds"))
w.WriteHeader(http.StatusInternalServerError)
Expand Down
2 changes: 1 addition & 1 deletion pkg/handlers/rendered_contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (h *Handler) GetAppRenderedContents(w http.ResponseWriter, r *http.Request)
return
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archivePath)
kotsKinds, err := kotsutil.LoadKotsKinds(archivePath)
if err != nil {
logger.Error(errors.Wrap(err, "failed to load kots kinds from path"))
w.WriteHeader(http.StatusInternalServerError)
Expand Down
7 changes: 3 additions & 4 deletions pkg/handlers/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -63,7 +62,7 @@ func (h *Handler) UploadExistingApp(w http.ResponseWriter, r *http.Request) {
return
}

tmpFile, err := ioutil.TempFile("", "kotsadm")
tmpFile, err := os.CreateTemp("", "kotsadm")
if err != nil {
uploadResponse.Error = util.StrPointer("failed to create temp file")
logger.Error(errors.Wrap(err, *uploadResponse.Error))
Expand All @@ -89,7 +88,7 @@ func (h *Handler) UploadExistingApp(w http.ResponseWriter, r *http.Request) {
defer os.RemoveAll(archiveDir)

// encrypt any plain text values
kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
uploadResponse.Error = util.StrPointer("failed to load kotskinds")
logger.Error(errors.Wrap(err, *uploadResponse.Error))
Expand All @@ -112,7 +111,7 @@ func (h *Handler) UploadExistingApp(w http.ResponseWriter, r *http.Request) {
return
}

if err := ioutil.WriteFile(filepath.Join(archiveDir, "upstream", "userdata", "config.yaml"), []byte(updated), 0644); err != nil {
if err := os.WriteFile(filepath.Join(archiveDir, "upstream", "userdata", "config.yaml"), []byte(updated), 0644); err != nil {
uploadResponse.Error = util.StrPointer("failed to write config values")
logger.Error(errors.Wrap(err, *uploadResponse.Error))
JSON(w, http.StatusInternalServerError, uploadResponse)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kotsadmlicense/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Sync(a *apptypes.App, licenseString string, failOnVersionCreate bool) (*kot
return nil, false, errors.Wrap(err, "failed to get latest app sequence")
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
return nil, false, errors.Wrap(err, "failed to load kotskinds from path")
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/kotsadmsnapshot/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func CreateApplicationBackup(ctx context.Context, a *apptypes.App, isScheduled b
zap.String("appID", a.ID),
zap.Int64("sequence", parentSequence))

archiveDir, err := ioutil.TempDir("", "kotsadm")
archiveDir, err := os.MkdirTemp("", "kotsadm")
if err != nil {
return nil, errors.Wrap(err, "failed to create temp dir")
}
Expand Down Expand Up @@ -93,7 +93,7 @@ func CreateApplicationBackup(ctx context.Context, a *apptypes.App, isScheduled b
return nil, errors.New("no backup store location found")
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
return nil, errors.Wrap(err, "failed to load kots kinds from path")
}
Expand Down Expand Up @@ -267,7 +267,7 @@ func CreateInstanceBackup(ctx context.Context, cluster *downstreamtypes.Downstre
return nil, errors.Wrapf(err, "failed to get app version archive for app %s", a.Slug)
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
kotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
return nil, errors.Wrap(err, "failed to load kots kinds from path")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kotsadmupstream/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func DownloadUpdate(appID string, update types.Update, skipPreflights bool, skip
}
defer os.RemoveAll(archiveDir)

beforeKotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
beforeKotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
finalError = errors.Wrap(err, "failed to read kots kinds before update")
return
Expand Down Expand Up @@ -241,7 +241,7 @@ func DownloadUpdate(appID string, update types.Update, skipPreflights bool, skip
}

if update.AppSequence == nil {
afterKotsKinds, err := kotsutil.LoadKotsKindsFromPath(archiveDir)
afterKotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
finalError = errors.Wrap(err, "failed to read kots kinds after update")
return
Expand Down
Loading

0 comments on commit b0b5860

Please sign in to comment.