Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
feat(cli): Add missing upstream warning during keptn upgrade (#6434)
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT authored Dec 28, 2021
1 parent d1625a7 commit 4867fa5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cli/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"github.com/keptn/keptn/cli/pkg/version"

apiutils "github.com/keptn/go-utils/pkg/api/utils"
"github.com/keptn/keptn/cli/pkg/helm"
"github.com/keptn/keptn/cli/pkg/platform"

Expand Down Expand Up @@ -189,6 +190,10 @@ func doUpgradePreRunCheck(vChecker *version.KeptnVersionChecker) error {
}
}

if err = addWarningNonExistingProjectUpstream(); err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -237,6 +242,30 @@ func getLatestKeptnRelease() (*release.Release, error) {

}

func addWarningNonExistingProjectUpstream() error {
endPoint, apiToken, err := credentialmanager.NewCredentialManager(assumeYes).GetCreds(namespace)
if err != nil {
return errors.New(authErrorMsg)
}

projectsHandler := apiutils.NewAuthenticatedProjectHandler(endPoint.String(), apiToken, "x-token", nil, endPoint.Scheme)
logging.PrintLog(fmt.Sprintf("Connecting to server %s", endPoint.String()), logging.VerboseLevel)

projects, err := projectsHandler.GetAllProjects()
if err != nil {
return fmt.Errorf("failed to get all projects from namespace %s", namespace)
}

for _, project := range projects {
if project.GitRemoteURI == "" || project.GitToken == "" || project.GitUser == "" {
fmt.Printf("WARNING: the project %s has no Git upstream configured. Please consider setting a Git upstream repository using:\n\n", project.ProjectName)
fmt.Printf("\tkeptn update project %s --git-user=GIT_USER --git-token=GIT_TOKEN --git-remote-url=GIT_REMOTE_URL\n\n", project.ProjectName)
}
}

return nil
}

func init() {
rootCmd.AddCommand(upgraderCmd)
upgradeParams = installUpgradeParams{}
Expand Down

0 comments on commit 4867fa5

Please sign in to comment.