Skip to content

Commit

Permalink
step 6
Browse files Browse the repository at this point in the history
  • Loading branch information
gfichtenholt committed Sep 22, 2021
1 parent d0b3fee commit 4c0d677
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,11 @@ func (s *Server) updateRelease(ctx context.Context, packageRef *corev1.Installed

unstructuredRel, err := ifc.Get(ctx, packageRef.Identifier, metav1.GetOptions{})
if err != nil {
return nil, err
if errors.IsNotFound(err) {
return nil, status.Errorf(codes.NotFound, "%q", err)
} else {
return nil, status.Errorf(codes.Internal, "%q", err)
}
}

if versionRef.GetVersion() != "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,18 @@ func TestUpdateInstalledPackage(t *testing.T) {
},
expectedRelease: flux_helm_release_updated_1,
},
{
name: "returns invalid if installed package doesn't exist",
request: &corev1.UpdateInstalledPackageRequest{
InstalledPackageRef: &corev1.InstalledPackageReference{
Context: &corev1.Context{
Namespace: "default",
},
Identifier: "not-a-valid-identifier",
},
},
expectedStatusCode: codes.NotFound,
},
}

for _, tc := range testCases {
Expand Down Expand Up @@ -715,6 +727,13 @@ func TestUpdateInstalledPackage(t *testing.T) {
}

func newRuntimeObjects(t *testing.T, existingK8sObjs []testSpecGetInstalledPackages) (runtimeObjs []runtime.Object, cleanup func()) {
httpServers := []*httptest.Server{}
cleanup = func() {
for _, ts := range httpServers {
ts.Close()
}
}

for _, existing := range existingK8sObjs {
tarGzBytes, err := ioutil.ReadFile(existing.chartTarGz)
if err != nil {
Expand All @@ -726,7 +745,7 @@ func newRuntimeObjects(t *testing.T, existingK8sObjs []testSpecGetInstalledPacka
w.WriteHeader(200)
w.Write(tarGzBytes)
}))
cleanup = func() { ts.Close() }
httpServers = append(httpServers, ts)

chartSpec := map[string]interface{}{
"chart": existing.chartName,
Expand Down
2 changes: 0 additions & 2 deletions cmd/kubeapps-apis/plugins/fluxv2/packages/v1alpha1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,6 @@ func (s *Server) UpdateInstalledPackage(ctx context.Context, request *corev1.Upd
return nil, status.Errorf(codes.InvalidArgument, "no request InstalledPackageRef provided")
}

request.ProtoMessage()

if installedRef, err := s.updateRelease(
ctx,
request.InstalledPackageRef,
Expand Down

0 comments on commit 4c0d677

Please sign in to comment.