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

Commit

Permalink
Bump jszip from 3.5.0 to 3.7.1 in /web
Browse files Browse the repository at this point in the history
Bumps [jszip](/~https://github.com/Stuk/jszip) from 3.5.0 to 3.7.1.
- [Release notes](/~https://github.com/Stuk/jszip/releases)
- [Changelog](/~https://github.com/Stuk/jszip/blob/master/CHANGES.md)
- [Commits](Stuk/jszip@v3.5.0...v3.7.1)

---
updated-dependencies:
- dependency-name: jszip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Vikram Yadav <yvikram@vmware.com>
  • Loading branch information
dependabot[bot] authored and Vikram Yadav committed Aug 25, 2021
1 parent ab3cf4f commit 4e2b081
Show file tree
Hide file tree
Showing 14 changed files with 588 additions and 251 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/2775-xtreme-vikram-yadav
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allowed Go plugins to apply yaml
19 changes: 19 additions & 0 deletions pkg/plugin/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ func TestAPI(t *testing.T) {
require.NoError(t, err)
},
},
{
name: "applyYaml",
initFunc: func(t *testing.T, mocks *apiMocks) {
mocks.objectStore.EXPECT().
CreateOrUpdateFromYAML(contextType, "default", "---\nyaml").
Return([]string{}, nil).
Do(func(ctx context.Context, namespace, yaml string) {
require.Equal(t, "bar", ctx.Value(api.DashboardMetadataKey("foo")))
})
},
doFunc: func(t *testing.T, client *api.Client) {
clientCtx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

clientCtx = metadata.AppendToOutgoingContext(clientCtx, "x-octant-foo", "bar")
_, err := client.ApplyYaml(clientCtx, "default", "---\nyaml")
require.NoError(t, err)
},
},
{
name: "get",
initFunc: func(t *testing.T, mocks *apiMocks) {
Expand Down
14 changes: 14 additions & 0 deletions pkg/plugin/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ func (c *Client) Update(ctx context.Context, object *unstructured.Unstructured)
return err
}

// ApplyYaml creates or updates resource(s) based on input yaml string.
func (c *Client) ApplyYaml(ctx context.Context, namespace, yaml string) ([]string, error) {
client := c.DashboardConnection.Client()

req := &proto.ApplyYamlRequest{
Namespace: namespace,
Yaml: yaml,
}

res, err := client.ApplyYaml(ctx, req)

return res.Resources, err
}

func (c *Client) Create(ctx context.Context, object *unstructured.Unstructured) error {
client := c.DashboardConnection.Client()

Expand Down
26 changes: 26 additions & 0 deletions pkg/plugin/api/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,32 @@ func TestClient_Update(t *testing.T) {
require.NoError(t, err)
}

func TestClient_ApplyYaml(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()

ctx := context.Background()
namespace := "foo-namespace"
yamlString := "---\napiVersion:apps/v1"

dashboardClient := fake.NewMockDashboardClient(controller)
req := &proto.ApplyYamlRequest{
Namespace: namespace,
Yaml: yamlString,
}
dashboardClient.EXPECT().ApplyYaml(gomock.Any(), req).Return(&proto.ApplyYamlResponse{}, nil)

conn := fake.NewMockDashboardConnection(controller)
conn.EXPECT().Client().Return(dashboardClient)

connOpt := MockDashboardConnection(conn)

client, err := api.NewClient("address", connOpt)
require.NoError(t, err)

_, err = client.ApplyYaml(ctx, namespace, yamlString)
require.NoError(t, err)
}
func TestClient_ForceFrontendUpdate(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
Expand Down
15 changes: 15 additions & 0 deletions pkg/plugin/api/fake/mock_dash_service.go

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

20 changes: 20 additions & 0 deletions pkg/plugin/api/fake/mock_dashboard_client.go

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

Loading

0 comments on commit 4e2b081

Please sign in to comment.