Skip to content

Commit

Permalink
No error in UI on failed gitops init
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Sep 4, 2020
1 parent 5ccc4e1 commit d6d40f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
5 changes: 3 additions & 2 deletions kotsadm/pkg/handlers/gitops.go
Expand Up @@ -143,12 +143,13 @@ func InitGitOpsConnection(w http.ResponseWriter, r *http.Request) {
}

if err := gitops.TestGitOpsConnection(downstreamGitOps); err != nil {
logger.Error(err)
logger.Infof("Failed to test gitops connection: %v", err)
JSON(w, http.StatusBadRequest, NewErrorResponse(err))

err = gitops.SetGitOpsError(a.ID, d.ClusterID, err.Error())
if err != nil {
logger.Error(err)
}
w.WriteHeader(http.StatusInternalServerError)
return
}

Expand Down
23 changes: 22 additions & 1 deletion kotsadm/web/src/components/apps/AppGitops.jsx
Expand Up @@ -105,13 +105,34 @@ class AppGitops extends Component {
Utilities.logoutUser();
return;
}
console.log("failed to init gitops connection, unexpected status code", res.status);
let msg = `Unexpected status code: ${res.status}`;
if (res.status === 400) {
msg = `Unable to authenticate. Please make sure you have added your deployment key to the git repo.`;
}
try {
const data = await res.json();
if (data?.error) {
console.log(`Failed to test gitops connection: ${data.error}`);
}
} catch (err) {
console.log(`Failed to test gitops connection: ${err}`);
}
this.setState({
errorTitle: "Failed to test connection",
errorMsg: msg,
displayErrorModal: true,
});
this.props.refetch();
return;
}
this.props.history.push("/gitops");
} catch (err) {
console.log(err);
this.setState({
errorTitle: "Failed to test connection",
errorMsg: err ? err.message : "Something went wrong, please try again.",
displayErrorModal: true,
});
} finally {
this.setState({ testingConnection: false, connectionTested: true });
}
Expand Down

0 comments on commit d6d40f2

Please sign in to comment.