Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh committed Nov 5, 2024
1 parent 41a9ed0 commit a120552
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pkg/airgap/airgap.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func CreateAppFromAirgap(opts CreateAirgapAppOpts) (finalError error) {
return errors.Wrap(err, "failed to set app is airgap the second time")
}

newSequence, err := store.GetStore().CreateAppVersion(a.ID, nil, tmpRoot, "Airgap Install", opts.IsAutomated, configFile, opts.SkipPreflights, render.Renderer{})
newSequence, err := store.GetStore().CreateAppVersion(a.ID, nil, tmpRoot, "Airgap Install", true, opts.IsAutomated, configFile, opts.SkipPreflights, render.Renderer{})
if err != nil {
return errors.Wrap(err, "failed to create new version")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/airgap/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func UpdateAppFromPath(a *apptypes.App, airgapRoot string, airgapBundlePath stri
}

// Create the app in the db
newSequence, err := store.GetStore().CreateAppVersion(a.ID, &baseSequence, archiveDir, "Airgap Update", false, "", skipPreflights, render.Renderer{})
newSequence, err := store.GetStore().CreateAppVersion(a.ID, &baseSequence, archiveDir, "Airgap Update", false, false, "", skipPreflights, render.Renderer{})
if err != nil {
return errors.Wrap(err, "failed to create new version")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/handlers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ func updateAppConfig(updateApp *apptypes.App, sequence int64, configGroups []kot
}

if createNewVersion {
newSequence, err := store.GetStore().CreateAppVersion(updateApp.ID, &sequence, archiveDir, "Config Change", false, "", skipPreflights, render.Renderer{})
newSequence, err := store.GetStore().CreateAppVersion(updateApp.ID, &sequence, archiveDir, "Config Change", false, false, "", skipPreflights, render.Renderer{})
if err != nil {
updateAppConfigResponse.Error = "failed to create an app version"
return updateAppConfigResponse, err
Expand All @@ -761,7 +761,7 @@ func updateAppConfig(updateApp *apptypes.App, sequence int64, configGroups []kot
updateAppConfigResponse.Error = "failed to get existing downstream version source"
return updateAppConfigResponse, err
}
if err := store.GetStore().UpdateAppVersion(updateApp.ID, sequence, nil, archiveDir, source, false, "", skipPreflights, render.Renderer{}); err != nil {
if err := store.GetStore().UpdateAppVersion(updateApp.ID, sequence, nil, archiveDir, source, skipPreflights, render.Renderer{}); err != nil {
updateAppConfigResponse.Error = "failed to update app version"
return updateAppConfigResponse, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/handlers/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ func (h *Handler) ConfigureAppIdentityService(w http.ResponseWriter, r *http.Req
return
}

newSequence, err := store.GetStore().CreateAppVersion(a.ID, &latestSequence, archiveDir, "Identity Service", false, "", false, render.Renderer{})
newSequence, err := store.GetStore().CreateAppVersion(a.ID, &latestSequence, archiveDir, "Identity Service", false, false, "", false, render.Renderer{})
if err != nil {
err = errors.Wrap(err, "failed to create an app version")
logger.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/handlers/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (h *Handler) UpdateAppRegistry(w http.ResponseWriter, r *http.Request) {
}
defer os.RemoveAll(appDir)

newSequence, err := store.GetStore().CreateAppVersion(foundApp.ID, &latestSequence, appDir, "Registry Change", false, "", false, render.Renderer{})
newSequence, err := store.GetStore().CreateAppVersion(foundApp.ID, &latestSequence, appDir, "Registry Change", false, false, "", false, render.Renderer{})
if err != nil {
logger.Error(errors.Wrap(err, "failed to create app version"))
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/handlers/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (h *Handler) UploadExistingApp(w http.ResponseWriter, r *http.Request) {
return
}

newSequence, err := store.GetStore().CreateAppVersion(a.ID, &baseSequence, archiveDir, "KOTS Upload", false, "", uploadExistingAppRequest.SkipPreflights, render.Renderer{})
newSequence, err := store.GetStore().CreateAppVersion(a.ID, &baseSequence, archiveDir, "KOTS Upload", false, false, "", uploadExistingAppRequest.SkipPreflights, render.Renderer{})
if err != nil {
uploadResponse.Error = util.StrPointer("failed to create app version")
logger.Error(errors.Wrap(err, *uploadResponse.Error))
Expand Down
4 changes: 2 additions & 2 deletions pkg/kotsadmupstream/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,14 @@ func DownloadUpdate(appID string, update types.Update, skipPreflights bool, skip
if afterKotsKinds.Installation.Spec.UpdateCursor == beforeInstallation.UpdateCursor && afterKotsKinds.Installation.Spec.ChannelID == beforeInstallation.ChannelID {
return
}
newSequence, err := store.GetStore().CreateAppVersion(a.ID, &baseSequence, archiveDir, "Upstream Update", false, "", skipPreflights, render.Renderer{})
newSequence, err := store.GetStore().CreateAppVersion(a.ID, &baseSequence, archiveDir, "Upstream Update", false, false, "", skipPreflights, render.Renderer{})
if err != nil {
finalError = errors.Wrap(err, "failed to create version")
return
}
finalSequence = &newSequence
} else {
err := store.GetStore().UpdateAppVersion(a.ID, *update.AppSequence, &baseSequence, archiveDir, "Upstream Update", false, "", skipPreflights, render.Renderer{})
err := store.GetStore().UpdateAppVersion(a.ID, *update.AppSequence, &baseSequence, archiveDir, "Upstream Update", skipPreflights, render.Renderer{})
if err != nil {
finalError = errors.Wrap(err, "failed to create version")
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/online/online.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func CreateAppFromOnline(opts CreateOnlineAppOpts) (_ *kotsutil.KotsKinds, final
return nil, errors.Wrap(err, "failed to set app is not airgap")
}

newSequence, err := store.GetStore().CreateAppVersion(opts.PendingApp.ID, nil, tmpRoot, "Online Install", opts.IsAutomated, configFile, opts.SkipPreflights, render.Renderer{})
newSequence, err := store.GetStore().CreateAppVersion(opts.PendingApp.ID, nil, tmpRoot, "Online Install", true, opts.IsAutomated, configFile, opts.SkipPreflights, render.Renderer{})
if err != nil {
return nil, errors.Wrap(err, "failed to create new version")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ func (o *Operator) reconcileDeployment(cm *corev1.ConfigMap) (finalError error)
return errors.Wrap(err, "failed to extract app archive")
}

sequence, err := o.store.CreateAppVersion(appID, &baseSequence, archiveDir, source, false, "", skipPreflights, render.Renderer{})
sequence, err := o.store.CreateAppVersion(appID, &baseSequence, archiveDir, source, false, false, "", skipPreflights, render.Renderer{})
if err != nil {
return errors.Wrap(err, "failed to create app version")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/kotsstore/license_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (s *KOTSStore) createNewVersionForLicenseChangeStatements(appID string, bas
return nil, int64(0), errors.Wrap(err, "failed to render new version")
}

appVersionStatements, newSequence, err := s.createAppVersionStatements(appID, &baseSequence, archiveDir, "License Change", false, "", false, renderer)
appVersionStatements, newSequence, err := s.createAppVersionStatements(appID, &baseSequence, archiveDir, "License Change", false, false, "", false, renderer)
if err != nil {
return nil, int64(0), errors.Wrap(err, "failed to construct app version statements")
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/store/kotsstore/version_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func (s *KOTSStore) CreatePendingDownloadAppVersion(appID string, update upstrea
return newSequence, nil
}

func (s *KOTSStore) UpdateAppVersion(appID string, sequence int64, baseSequence *int64, filesInDir string, source string, isAutomated bool, configFile string, skipPreflights bool, renderer rendertypes.Renderer) error {
func (s *KOTSStore) UpdateAppVersion(appID string, sequence int64, baseSequence *int64, filesInDir string, source string, skipPreflights bool, renderer rendertypes.Renderer) error {
// make sure version exists first
if v, err := s.GetAppVersion(appID, sequence); err != nil {
return errors.Wrap(err, "failed to get app version")
Expand All @@ -417,7 +417,7 @@ func (s *KOTSStore) UpdateAppVersion(appID string, sequence int64, baseSequence

db := persistence.MustGetDBSession()

appVersionStatements, err := s.upsertAppVersionStatements(appID, sequence, baseSequence, filesInDir, source, isAutomated, configFile, skipPreflights, renderer)
appVersionStatements, err := s.upsertAppVersionStatements(appID, sequence, baseSequence, filesInDir, source, false, false, "", skipPreflights, renderer)
if err != nil {
return errors.Wrap(err, "failed to construct app version statements")
}
Expand All @@ -433,9 +433,9 @@ func (s *KOTSStore) UpdateAppVersion(appID string, sequence int64, baseSequence
return nil
}

func (s *KOTSStore) CreateAppVersion(appID string, baseSequence *int64, filesInDir string, source string, isAutomated bool, configFile string, skipPreflights bool, renderer rendertypes.Renderer) (int64, error) {
func (s *KOTSStore) CreateAppVersion(appID string, baseSequence *int64, filesInDir string, source string, isInstall bool, isAutomated bool, configFile string, skipPreflights bool, renderer rendertypes.Renderer) (int64, error) {
db := persistence.MustGetDBSession()
appVersionStatements, newSequence, err := s.createAppVersionStatements(appID, baseSequence, filesInDir, source, isAutomated, configFile, skipPreflights, renderer)
appVersionStatements, newSequence, err := s.createAppVersionStatements(appID, baseSequence, filesInDir, source, isInstall, isAutomated, configFile, skipPreflights, renderer)
if err != nil {
return 0, errors.Wrap(err, "failed to construct app version statements")
}
Expand All @@ -451,21 +451,21 @@ func (s *KOTSStore) CreateAppVersion(appID string, baseSequence *int64, filesInD
return newSequence, nil
}

func (s *KOTSStore) createAppVersionStatements(appID string, baseSequence *int64, filesInDir string, source string, isAutomated bool, configFile string, skipPreflights bool, renderer rendertypes.Renderer) ([]gorqlite.ParameterizedStatement, int64, error) {
func (s *KOTSStore) createAppVersionStatements(appID string, baseSequence *int64, filesInDir string, source string, isInstall bool, isAutomated bool, configFile string, skipPreflights bool, renderer rendertypes.Renderer) ([]gorqlite.ParameterizedStatement, int64, error) {
newSequence, err := s.GetNextAppSequence(appID)
if err != nil {
return nil, 0, errors.Wrap(err, "failed to get next sequence number")
}

appVersionStatements, err := s.upsertAppVersionStatements(appID, newSequence, baseSequence, filesInDir, source, isAutomated, configFile, skipPreflights, renderer)
appVersionStatements, err := s.upsertAppVersionStatements(appID, newSequence, baseSequence, filesInDir, source, isInstall, isAutomated, configFile, skipPreflights, renderer)
if err != nil {
return nil, 0, errors.Wrap(err, "failed to construct app version statements")
}

return appVersionStatements, newSequence, nil
}

func (s *KOTSStore) upsertAppVersionStatements(appID string, sequence int64, baseSequence *int64, filesInDir string, source string, isAutomated bool, configFile string, skipPreflights bool, renderer rendertypes.Renderer) ([]gorqlite.ParameterizedStatement, error) {
func (s *KOTSStore) upsertAppVersionStatements(appID string, sequence int64, baseSequence *int64, filesInDir string, source string, isInstall bool, isAutomated bool, configFile string, skipPreflights bool, renderer rendertypes.Renderer) ([]gorqlite.ParameterizedStatement, error) {
statements := []gorqlite.ParameterizedStatement{}

kotsKinds, err := kotsutil.LoadKotsKinds(filesInDir)
Expand Down Expand Up @@ -546,7 +546,7 @@ func (s *KOTSStore) upsertAppVersionStatements(appID string, sequence int64, bas
for _, d := range downstreams {
// there's a small chance this is not optimal, but no current code path
// will support multiple downstreams, so this is cleaner here for now
downstreamStatus, err := s.DetermineDownstreamVersionStatus(a, sequence, kotsKinds, baseSequence == nil, isAutomated, configFile, skipPreflights)
downstreamStatus, err := s.determineDownstreamVersionStatus(a, sequence, kotsKinds, isInstall, isAutomated, configFile, skipPreflights)
if err != nil {
return nil, errors.Wrap(err, "failed to determine downstream version status")
}
Expand Down Expand Up @@ -727,9 +727,9 @@ func (s *KOTSStore) upsertAppVersionRecordStatements(appID string, sequence int6
return statements, nil
}

func (s *KOTSStore) DetermineDownstreamVersionStatus(a *apptypes.App, sequence int64, kotsKinds *kotsutil.KotsKinds, isInitialVersion bool, isAutomated bool, configFile string, skipPreflights bool) (types.DownstreamVersionStatus, error) {
func (s *KOTSStore) determineDownstreamVersionStatus(a *apptypes.App, sequence int64, kotsKinds *kotsutil.KotsKinds, isInstall bool, isAutomated bool, configFile string, skipPreflights bool) (types.DownstreamVersionStatus, error) {
// Check if we need to show cluster management
if util.IsEmbeddedCluster() && isInitialVersion && configFile == "" {
if util.IsEmbeddedCluster() && isInstall && configFile == "" {
return types.VersionPendingClusterManagement, nil
}

Expand All @@ -746,7 +746,7 @@ func (s *KOTSStore) DetermineDownstreamVersionStatus(a *apptypes.App, sequence i
if needsConfig {
return types.VersionPendingConfig, nil
}
if isInitialVersion && !isAutomated {
if isInstall && !isAutomated {
// initial installs from the UI should show the config page even if all required items are already set and have values
return types.VersionPendingConfig, nil
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/store/mock/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/store/store_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ type VersionStore interface {
GetAppVersionBaseSequence(appID string, versionLabel string) (int64, error)
GetAppVersionBaseArchive(appID string, versionLabel string) (string, int64, error)
CreatePendingDownloadAppVersion(appID string, update upstreamtypes.Update, kotsApplication *kotsv1beta1.Application, license *kotsv1beta1.License) (int64, error)
UpdateAppVersion(appID string, sequence int64, baseSequence *int64, filesInDir string, source string, isAutomated bool, configFile string, skipPreflights bool, renderer rendertypes.Renderer) error
CreateAppVersion(appID string, baseSequence *int64, filesInDir string, source string, isAutomated bool, configFile string, skipPreflights bool, renderer rendertypes.Renderer) (int64, error)
UpdateAppVersion(appID string, sequence int64, baseSequence *int64, filesInDir string, source string, skipPreflights bool, renderer rendertypes.Renderer) error
CreateAppVersion(appID string, baseSequence *int64, filesInDir string, source string, isInstall bool, isAutomated bool, configFile string, skipPreflights bool, renderer rendertypes.Renderer) (int64, error)
GetAppVersion(appID string, sequence int64) (*versiontypes.AppVersion, error)
GetLatestAppSequence(appID string, downloadedOnly bool) (int64, error)
UpdateNextAppVersionDiffSummary(appID string, baseSequence int64) error
Expand Down

0 comments on commit a120552

Please sign in to comment.