Skip to content

Commit 4e1782c

Browse files
committed
Rename new scriptmgr RPC to CheckScriptExists
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent 1c57303 commit 4e1782c

File tree

6 files changed

+133
-133
lines changed

6 files changed

+133
-133
lines changed

src/cloud/api/ptproxy/vizier_pt_proxy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type vzmgrClient interface {
4646
}
4747

4848
type scriptmgrClient interface {
49-
GetScriptByHash(ctx context.Context, req *scriptmgrpb.GetScriptByHashReq, opts ...grpc.CallOption) (*scriptmgrpb.GetScriptByHashResp, error)
49+
CheckScriptExists(ctx context.Context, req *scriptmgrpb.CheckScriptExistsReq, opts ...grpc.CallOption) (*scriptmgrpb.CheckScriptExistsResp, error)
5050
}
5151

5252
// VizierPassThroughProxy implements the VizierAPI and allows proxying the data to the actual
@@ -73,7 +73,7 @@ func (v *VizierPassThroughProxy) isScriptModified(ctx context.Context, script st
7373
hash := sha256.New()
7474
hash.Write([]byte(script))
7575
hashStr := hex.EncodeToString(hash.Sum(nil))
76-
req := &scriptmgrpb.GetScriptByHashReq{Sha256Hash: hashStr}
76+
req := &scriptmgrpb.CheckScriptExistsReq{Sha256Hash: hashStr}
7777

7878
serviceAuthToken, err := getServiceCredentials(viper.GetString("jwt_signing_key"))
7979
ctx = metadata.AppendToOutgoingContext(ctx, "authorization",
@@ -83,7 +83,7 @@ func (v *VizierPassThroughProxy) isScriptModified(ctx context.Context, script st
8383
return false, err
8484
}
8585

86-
resp, err := v.sm.GetScriptByHash(ctx, req)
86+
resp, err := v.sm.CheckScriptExists(ctx, req)
8787

8888
if err != nil {
8989
return false, err

src/cloud/api/ptproxy/vizier_pt_proxy_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,14 +856,14 @@ func TestVizierPassThroughProxy_DebugPods(t *testing.T) {
856856

857857
type fakeScriptMgr struct{}
858858

859-
func (s *fakeScriptMgr) GetScriptByHash(ctx context.Context, req *scriptmgrpb.GetScriptByHashReq, opts ...grpc.CallOption) (*scriptmgrpb.GetScriptByHashResp, error) {
859+
func (s *fakeScriptMgr) CheckScriptExists(ctx context.Context, req *scriptmgrpb.CheckScriptExistsReq, opts ...grpc.CallOption) (*scriptmgrpb.CheckScriptExistsResp, error) {
860860
hash := "488f131003f415a61090901c544e0ace731e8a85b12ce0aea770273d656f08e0" // sha256 of "liveview1 pxl"
861861

862862
scripts := map[string]bool{
863863
hash: true,
864864
}
865865
_, ok := scripts[req.Sha256Hash]
866-
return &scriptmgrpb.GetScriptByHashResp{
866+
return &scriptmgrpb.CheckScriptExistsResp{
867867
Exists: ok,
868868
}, nil
869869
}

src/cloud/scriptmgr/controllers/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ func (s *Server) GetScriptContents(ctx context.Context, req *scriptmgrpb.GetScri
259259
}, nil
260260
}
261261

262-
// GetScriptByHash returns if a script with the given hash exists.
263-
func (s *Server) GetScriptByHash(ctx context.Context, req *scriptmgrpb.GetScriptByHashReq) (*scriptmgrpb.GetScriptByHashResp, error) {
262+
// CheckScriptExists returns if a script with the given hash exists.
263+
func (s *Server) CheckScriptExists(ctx context.Context, req *scriptmgrpb.CheckScriptExistsReq) (*scriptmgrpb.CheckScriptExistsResp, error) {
264264
hash := req.Sha256Hash
265265
_, ok := s.store.ScriptHashes[hash]
266-
return &scriptmgrpb.GetScriptByHashResp{
266+
return &scriptmgrpb.CheckScriptExistsResp{
267267
Exists: ok,
268268
}, nil
269269
}

src/cloud/scriptmgr/controllers/server_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func TestScriptMgr_GetScriptContents(t *testing.T) {
324324
}
325325
}
326326

327-
func TestScriptMgr_GetScriptByHash(t *testing.T) {
327+
func TestScriptMgr_CheckScriptExists(t *testing.T) {
328328
testCases := []struct {
329329
name string
330330
scriptHash string
@@ -350,13 +350,13 @@ func TestScriptMgr_GetScriptByHash(t *testing.T) {
350350
c := mustSetupFakeBucket(t, testBundle)
351351
s := controllers.NewServer(bundleBucket, bundlePath, c)
352352
ctx := context.Background()
353-
req := &scriptmgrpb.GetScriptByHashReq{
353+
req := &scriptmgrpb.CheckScriptExistsReq{
354354
Sha256Hash: tc.scriptHash,
355355
}
356-
expectedResp := &scriptmgrpb.GetScriptByHashResp{
356+
expectedResp := &scriptmgrpb.CheckScriptExistsResp{
357357
Exists: tc.exists,
358358
}
359-
resp, err := s.GetScriptByHash(ctx, req)
359+
resp, err := s.CheckScriptExists(ctx, req)
360360
if tc.expectErr {
361361
require.NotNil(t, err)
362362
} else {

0 commit comments

Comments
 (0)