Skip to content

Commit

Permalink
Merge pull request #81 from amazeeio/report-card
Browse files Browse the repository at this point in the history
Ineffectual assignment fixes
  • Loading branch information
shreddedbacon authored Feb 25, 2020
2 parents 1d37ca7 + 52ff2db commit 70323d0
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var addProjectToGroupCmd = &cobra.Command{
Name: cmdProjectName,
},
Groups: []api.Group{
api.Group{
{
Name: groupName,
},
},
Expand Down Expand Up @@ -176,7 +176,7 @@ var deleteProjectFromGroupCmd = &cobra.Command{
Name: cmdProjectName,
},
Groups: []api.Group{
api.Group{
{
Name: groupName,
},
},
Expand Down
3 changes: 3 additions & 0 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func loginToken() error {
return err
}
err = conn.Close()
if err != nil {
return err
}
viper.Set("lagoons."+cmdLagoon+".token", strings.TrimSpace(string(out)))
err = viper.WriteConfig()
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func (project *LagoonProject) ReadConfig() error {
var err error

source, err := ioutil.ReadFile(filepath.Join(project.Dir, ".lagoon.yml"))
if err != nil {
return fmt.Errorf("unable to load config file %s/: %v", filepath.Join(project.Dir, ".lagoon.yml"), err)
}
err = yaml.Unmarshal(source, project)
if err != nil {
return fmt.Errorf("unable to load config file %s/: %v", filepath.Join(project.Dir, ".lagoon.yml"), err)
Expand All @@ -56,7 +59,7 @@ func (project *LagoonProject) ReadConfig() error {

// GetLocalProject returns the current Lagoon app detected.
func GetLocalProject() (LagoonProject, error) {
appDir, err := os.Getwd()
_, err := os.Getwd()
if err != nil {
return LagoonProject{}, fmt.Errorf("error determining the current directory: %s", err)
}
Expand All @@ -66,7 +69,7 @@ func GetLocalProject() (LagoonProject, error) {
if err != nil {
return LagoonProject{}, err
}
appDir = fmt.Sprintf("%+v", root)
appDir := fmt.Sprintf("%+v", root)
return getProjectFromPath(appDir)
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/lagoon/environments/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func (e *Environments) GetEnvironmentDeployments(projectName string, environment
MappedResult: "environmentByName",
}
environmentByName, err := e.api.Request(customRequest)
if err != nil {
return []byte(""), err
}
returnResult, err := processEnvironmentDeployments(environmentByName)
if err != nil {
return []byte(""), err
Expand Down
3 changes: 3 additions & 0 deletions pkg/lagoon/environments/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ func (e *Environments) GetEnvironmentTasks(projectName string, environmentName s
MappedResult: "environmentByName",
}
environmentByName, err := e.api.Request(customRequest)
if err != nil {
return []byte(""), err
}
returnResult, err := processEnvironmentTasks(environmentByName)
if err != nil {
return []byte(""), err
Expand Down
6 changes: 6 additions & 0 deletions pkg/lagoon/projects/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ func TestProjectUpdate(t *testing.T) {
t.Error("Should not fail if processing succeeded", err)
}
updateResults, err := json.Marshal(returnResult)
if err != nil {
t.Error("Should not fail if processing succeeded", err)
}
if string(updateResults) != updateProjectsSuccess {
checkEqual(t, string(updateResults), updateProjectsSuccess, "projectInfo processing failed")
}
Expand All @@ -121,6 +124,9 @@ func TestProjectUpdate(t *testing.T) {
t.Error("Should not fail if processing succeeded", err)
}
updateResults, err = json.Marshal(returnResult)
if err != nil {
t.Error("Should not fail if processing succeeded", err)
}
if string(updateResults) == updateProjectsFail {
checkEqual(t, string(updateResults), updateProjectsFail, "projectInfo processing succeeded, but should fail if json patch is broken")
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/lagoon/projects/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ func (p *Projects) DeleteRocketChatNotificationFromProject(projectName string, n
func (p *Projects) UpdateSlackNotification(notificationName string, jsonPatch string) ([]byte, error) {
var updateSlack api.UpdateNotificationSlackPatch
err := json.Unmarshal([]byte(jsonPatch), &updateSlack)
if err != nil {
return []byte(""), err
}
customReq := api.CustomRequest{
Query: `mutation ($oldname: String!, $patch: UpdateNotificationSlackPatchInput!) {
updateNotificationSlack(input:{name: $oldname, patch: $patch}
Expand All @@ -457,6 +460,9 @@ func (p *Projects) UpdateSlackNotification(notificationName string, jsonPatch st
func (p *Projects) UpdateRocketChatNotification(notificationName string, jsonPatch string) ([]byte, error) {
var updateRocketChat api.UpdateNotificationRocketChatPatch
err := json.Unmarshal([]byte(jsonPatch), &updateRocketChat)
if err != nil {
return []byte(""), err
}
customReq := api.CustomRequest{
Query: `mutation ($oldname: String!, $patch: UpdateNotificationRocketChatPatchInput!) {
updateNotificationRocketChat(input:{name: $oldname, patch: $patch}
Expand Down
9 changes: 9 additions & 0 deletions pkg/lagoon/users/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func (u *Users) ListUsers(groupName string) ([]byte, error) {
MappedResult: "allGroups",
}
listUsers, err := u.api.Request(customReq)
if err != nil {
return []byte(""), err
}
returnResult, err := processUserList(listUsers)
if err != nil {
return []byte(""), err
Expand Down Expand Up @@ -239,7 +242,13 @@ func (u *Users) ListUserSSHKeys(groupName string, email string, allUsers bool) (
MappedResult: "allGroups",
}
listUsers, err := u.api.Request(customReq)
if err != nil {
return []byte(""), err
}
returnedKeys, err := processReturnedUserKeysList(listUsers)
if err != nil {
return []byte(""), err
}
var returnResult []byte
if allUsers {
returnResult, err = processAllUserKeysList(returnedKeys)
Expand Down
3 changes: 3 additions & 0 deletions pkg/updatecheck/updatecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ func ResetUpdateTime(filepath string) error {
err := os.Remove(filepath)
_ = err // We don't actually care if remove failed. All we care about is that the create succeeds.
file, err := os.Create(filepath)
if err != nil {
return err
}
err = file.Close()
return err
}
Expand Down

0 comments on commit 70323d0

Please sign in to comment.