Skip to content

Commit

Permalink
Update external-attacher to use v1.0.0-rc2 csi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
msau42 committed Nov 15, 2018
1 parent 08b5d5b commit afb5c14
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
22 changes: 11 additions & 11 deletions pkg/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,32 +192,32 @@ func (c *csiConnection) SupportsPluginControllerService(ctx context.Context) (bo
return false, nil
}

func (c *csiConnection) Attach(ctx context.Context, volumeID string, readOnly bool, nodeID string, caps *csi.VolumeCapability, attributes, secrets map[string]string) (metadata map[string]string, detached bool, err error) {
func (c *csiConnection) Attach(ctx context.Context, volumeID string, readOnly bool, nodeID string, caps *csi.VolumeCapability, context, secrets map[string]string) (metadata map[string]string, detached bool, err error) {
client := csi.NewControllerClient(c.conn)

req := csi.ControllerPublishVolumeRequest{
VolumeId: volumeID,
NodeId: nodeID,
VolumeCapability: caps,
Readonly: readOnly,
VolumeAttributes: attributes,
ControllerPublishSecrets: secrets,
VolumeId: volumeID,
NodeId: nodeID,
VolumeCapability: caps,
Readonly: readOnly,
VolumeContext: context,
Secrets: secrets,
}

rsp, err := client.ControllerPublishVolume(ctx, &req)
if err != nil {
return nil, isFinalError(err), err
}
return rsp.PublishInfo, false, nil
return rsp.PublishContext, false, nil
}

func (c *csiConnection) Detach(ctx context.Context, volumeID string, nodeID string, secrets map[string]string) (detached bool, err error) {
client := csi.NewControllerClient(c.conn)

req := csi.ControllerUnpublishVolumeRequest{
VolumeId: volumeID,
NodeId: nodeID,
ControllerUnpublishSecrets: secrets,
VolumeId: volumeID,
NodeId: nodeID,
Secrets: secrets,
}

_, err = client.ControllerUnpublishVolume(ctx, &req)
Expand Down
28 changes: 14 additions & 14 deletions pkg/connection/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,15 @@ func TestAttach(t *testing.T) {
VolumeId: defaultVolumeID,
NodeId: defaultNodeID,
VolumeCapability: defaultCaps,
VolumeAttributes: map[string]string{"foo": "bar"},
VolumeContext: map[string]string{"foo": "bar"},
Readonly: false,
}
secretsRequest := &csi.ControllerPublishVolumeRequest{
VolumeId: defaultVolumeID,
NodeId: defaultNodeID,
VolumeCapability: defaultCaps,
ControllerPublishSecrets: map[string]string{"foo": "bar"},
Readonly: false,
VolumeId: defaultVolumeID,
NodeId: defaultNodeID,
VolumeCapability: defaultCaps,
Secrets: map[string]string{"foo": "bar"},
Readonly: false,
}

tests := []struct {
Expand All @@ -407,7 +407,7 @@ func TestAttach(t *testing.T) {
caps: defaultCaps,
input: defaultRequest,
output: &csi.ControllerPublishVolumeResponse{
PublishInfo: publishVolumeInfo,
PublishContext: publishVolumeInfo,
},
expectError: false,
expectedInfo: publishVolumeInfo,
Expand All @@ -432,7 +432,7 @@ func TestAttach(t *testing.T) {
readonly: true,
input: readOnlyRequest,
output: &csi.ControllerPublishVolumeResponse{
PublishInfo: publishVolumeInfo,
PublishContext: publishVolumeInfo,
},
expectError: false,
expectedInfo: publishVolumeInfo,
Expand Down Expand Up @@ -468,7 +468,7 @@ func TestAttach(t *testing.T) {
attributes: map[string]string{"foo": "bar"},
input: attributesRequest,
output: &csi.ControllerPublishVolumeResponse{
PublishInfo: publishVolumeInfo,
PublishContext: publishVolumeInfo,
},
expectError: false,
expectedInfo: publishVolumeInfo,
Expand All @@ -482,7 +482,7 @@ func TestAttach(t *testing.T) {
secrets: map[string]string{"foo": "bar"},
input: secretsRequest,
output: &csi.ControllerPublishVolumeResponse{
PublishInfo: publishVolumeInfo,
PublishContext: publishVolumeInfo,
},
expectError: false,
expectedInfo: publishVolumeInfo,
Expand Down Expand Up @@ -519,7 +519,7 @@ func TestAttach(t *testing.T) {
t.Errorf("test %q: got error: %v", test.name, err)
}
if err == nil && !reflect.DeepEqual(publishInfo, test.expectedInfo) {
t.Errorf("got unexpected PublishInfo: %+v", publishInfo)
t.Errorf("got unexpected PublishContext: %+v", publishInfo)
}
if detached != test.expectDetached {
t.Errorf("test %q: expected detached=%v, got %v", test.name, test.expectDetached, detached)
Expand All @@ -538,9 +538,9 @@ func TestDetachAttach(t *testing.T) {
}

secretsRequest := &csi.ControllerUnpublishVolumeRequest{
VolumeId: defaultVolumeID,
NodeId: defaultNodeID,
ControllerUnpublishSecrets: map[string]string{"foo": "bar"},
VolumeId: defaultVolumeID,
NodeId: defaultNodeID,
Secrets: map[string]string{"foo": "bar"},
}

tests := []struct {
Expand Down

0 comments on commit afb5c14

Please sign in to comment.