Skip to content

Commit

Permalink
fixes indentation to spaces
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Singh <[email protected]>
  • Loading branch information
Vivek Singh committed Feb 2, 2021
1 parent 3bc3121 commit ea48e37
Show file tree
Hide file tree
Showing 4 changed files with 336 additions and 336 deletions.
64 changes: 32 additions & 32 deletions api/external/infra_proxy/response/clients.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,55 @@ package chef.automate.api.infra_proxy.response;
option go_package = "github.com/chef/automate/api/external/infra_proxy/response";

message Clients {
// Client list.
// Client list.
repeated ClientListItem clients = 1;
}

message ClientListItem {
// Client name.
// Client name.
string name = 1;
}

message Client {
// Client name.
string name = 1;
// Client name return by Chef Infra Server API.
string client_name = 2;
// Chef organization name.
string org_name = 3;
// Boolean indicates client type is validator or not.
bool validator = 4;
// Client JSON class.
string json_class = 5;
// Chef object type.
string chef_type = 6;
// Client key detail.
ClientAccessKey client_key = 7;
// Client name.
string name = 1;
// Client name return by Chef Infra Server API.
string client_name = 2;
// Chef organization name.
string org_name = 3;
// Boolean indicates client type is validator or not.
bool validator = 4;
// Client JSON class.
string json_class = 5;
// Chef object type.
string chef_type = 6;
// Client key detail.
ClientAccessKey client_key = 7;
}

message CreateClient {
// Client name.
string name = 1;
// Client key detail.
ClientKey client_key = 2;
// Client name.
string name = 1;
// Client key detail.
ClientKey client_key = 2;
}

message ClientKey {
// Client key name.
string name = 1;
// Client public key.
string public_key = 2;
// Client key expiration date string.
string expiration_date = 3;
// Client private key.
string private_key = 4;
string name = 1;
// Client public key.
string public_key = 2;
// Client key expiration date string.
string expiration_date = 3;
// Client private key.
string private_key = 4;
}

message ClientAccessKey {
// Client key name.
string name = 1;
// Client public key.
string public_key = 2;
// Client key expiration date string.
string expiration_date = 3;
string name = 1;
// Client public key.
string public_key = 2;
// Client key expiration date string.
string expiration_date = 3;
}
64 changes: 32 additions & 32 deletions api/interservice/infra_proxy/response/clients.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,55 @@ package chef.automate.domain.infra_proxy.response;
option go_package = "github.com/chef/automate/api/interservice/infra_proxy/response";

message Clients {
// Client list.
// Client list.
repeated ClientListItem clients = 1;
}

message ClientListItem {
// Client name.
// Client name.
string name = 1;
}

message Client {
// Client name.
string name = 1;
// Client name return by Chef Infra Server API.
string client_name = 2;
// Chef organization name.
string org_name = 3;
// Boolean indicates client type is validator or not.
bool validator = 4;
// Client JSON class.
string json_class = 5;
// Chef object type.
string chef_type = 6;
// Client key detail.
ClientAccessKey client_key = 7;
// Client name.
string name = 1;
// Client name return by Chef Infra Server API.
string client_name = 2;
// Chef organization name.
string org_name = 3;
// Boolean indicates client type is validator or not.
bool validator = 4;
// Client JSON class.
string json_class = 5;
// Chef object type.
string chef_type = 6;
// Client key detail.
ClientAccessKey client_key = 7;
}

message CreateClient {
// Client name.
string name = 1;
// Client key detail.
ClientKey client_key = 2;
// Client name.
string name = 1;
// Client key detail.
ClientKey client_key = 2;
}

message ClientKey {
// Client key name.
string name = 1;
// Client public key.
string public_key = 2;
// Client key expiration date string.
string expiration_date = 3;
// Client private key.
string private_key = 4;
string name = 1;
// Client public key.
string public_key = 2;
// Client key expiration date string.
string expiration_date = 3;
// Client private key.
string private_key = 4;
}

message ClientAccessKey {
// Client key name.
string name = 1;
// Client public key.
string public_key = 2;
// Client key expiration date string.
string expiration_date = 3;
string name = 1;
// Client public key.
string public_key = 2;
// Client key expiration date string.
string expiration_date = 3;
}
182 changes: 91 additions & 91 deletions components/automate-gateway/handler/infra_proxy/clients.go
Original file line number Diff line number Diff line change
@@ -1,126 +1,126 @@
package infra_proxy

import (
"context"
"context"

gwreq "github.com/chef/automate/api/external/infra_proxy/request"
gwres "github.com/chef/automate/api/external/infra_proxy/response"
infra_req "github.com/chef/automate/api/interservice/infra_proxy/request"
infra_res "github.com/chef/automate/api/interservice/infra_proxy/response"
gwreq "github.com/chef/automate/api/external/infra_proxy/request"
gwres "github.com/chef/automate/api/external/infra_proxy/response"
infra_req "github.com/chef/automate/api/interservice/infra_proxy/request"
infra_res "github.com/chef/automate/api/interservice/infra_proxy/response"
)

// GetClients fetches an array of existing clients
func (a *InfraProxyServer) GetClients(ctx context.Context, r *gwreq.Clients) (*gwres.Clients, error) {
req := &infra_req.Clients{
OrgId: r.OrgId,
ServerId: r.ServerId,
}
res, err := a.client.GetClients(ctx, req)
if err != nil {
return nil, err
}
req := &infra_req.Clients{
OrgId: r.OrgId,
ServerId: r.ServerId,
}
res, err := a.client.GetClients(ctx, req)
if err != nil {
return nil, err
}

return &gwres.Clients{
Clients: fromUpstreamClients(res.Clients),
}, nil
return &gwres.Clients{
Clients: fromUpstreamClients(res.Clients),
}, nil
}

// GetClient fetches an infra client details
func (a *InfraProxyServer) GetClient(ctx context.Context, r *gwreq.Client) (*gwres.Client, error) {
req := &infra_req.Client{
OrgId: r.OrgId,
ServerId: r.ServerId,
Name: r.Name,
}
res, err := a.client.GetClient(ctx, req)
if err != nil {
return nil, err
}
req := &infra_req.Client{
OrgId: r.OrgId,
ServerId: r.ServerId,
Name: r.Name,
}
res, err := a.client.GetClient(ctx, req)
if err != nil {
return nil, err
}

return &gwres.Client{
Name: res.GetName(),
ClientName: res.GetClientName(),
OrgName: res.GetOrgName(),
Validator: res.GetValidator(),
JsonClass: res.GetJsonClass(),
ChefType: res.GetChefType(),
ClientKey: &gwres.ClientAccessKey{
Name: res.GetClientKey().GetName(),
ExpirationDate: res.GetClientKey().GetExpirationDate(),
PublicKey: res.GetClientKey().GetPublicKey(),
},
}, nil
return &gwres.Client{
Name: res.GetName(),
ClientName: res.GetClientName(),
OrgName: res.GetOrgName(),
Validator: res.GetValidator(),
JsonClass: res.GetJsonClass(),
ChefType: res.GetChefType(),
ClientKey: &gwres.ClientAccessKey{
Name: res.GetClientKey().GetName(),
ExpirationDate: res.GetClientKey().GetExpirationDate(),
PublicKey: res.GetClientKey().GetPublicKey(),
},
}, nil
}

// CreateClient creates an infra client
func (a *InfraProxyServer) CreateClient(ctx context.Context, r *gwreq.CreateClient) (*gwres.CreateClient, error) {
req := &infra_req.CreateClient{
OrgId: r.OrgId,
ServerId: r.ServerId,
Name: r.Name,
Validator: r.Validator,
CreateKey: r.CreateKey,
}
res, err := a.client.CreateClient(ctx, req)
if err != nil {
return nil, err
}
req := &infra_req.CreateClient{
OrgId: r.OrgId,
ServerId: r.ServerId,
Name: r.Name,
Validator: r.Validator,
CreateKey: r.CreateKey,
}
res, err := a.client.CreateClient(ctx, req)
if err != nil {
return nil, err
}

return &gwres.CreateClient{
Name: res.GetName(),
ClientKey: &gwres.ClientKey{
Name: res.GetClientKey().GetName(),
PublicKey: res.GetClientKey().GetPublicKey(),
ExpirationDate: res.GetClientKey().GetExpirationDate(),
PrivateKey: res.GetClientKey().GetPrivateKey(),
},
}, nil
return &gwres.CreateClient{
Name: res.GetName(),
ClientKey: &gwres.ClientKey{
Name: res.GetClientKey().GetName(),
PublicKey: res.GetClientKey().GetPublicKey(),
ExpirationDate: res.GetClientKey().GetExpirationDate(),
PrivateKey: res.GetClientKey().GetPrivateKey(),
},
}, nil
}

// DeleteClient deletes an infra client
func (a *InfraProxyServer) DeleteClient(ctx context.Context, r *gwreq.Client) (*gwres.Client, error) {
req := &infra_req.Client{
OrgId: r.OrgId,
ServerId: r.ServerId,
Name: r.Name,
}
res, err := a.client.DeleteClient(ctx, req)
if err != nil {
return nil, err
}
req := &infra_req.Client{
OrgId: r.OrgId,
ServerId: r.ServerId,
Name: r.Name,
}
res, err := a.client.DeleteClient(ctx, req)
if err != nil {
return nil, err
}

return &gwres.Client{
Name: res.GetName(),
}, nil
return &gwres.Client{
Name: res.GetName(),
}, nil
}

// ResetClientKey resets an infra client key
func (a *InfraProxyServer) ResetClientKey(ctx context.Context, r *gwreq.ClientKey) (*gwres.ClientKey, error) {
req := &infra_req.ClientKey{
OrgId: r.OrgId,
ServerId: r.ServerId,
Name: r.Name,
Key: r.Key,
}
res, err := a.client.ResetClientKey(ctx, req)
if err != nil {
return nil, err
}
req := &infra_req.ClientKey{
OrgId: r.OrgId,
ServerId: r.ServerId,
Name: r.Name,
Key: r.Key,
}
res, err := a.client.ResetClientKey(ctx, req)
if err != nil {
return nil, err
}

return &gwres.ClientKey{
Name: res.GetName(),
PrivateKey: res.GetPrivateKey(),
}, nil
return &gwres.ClientKey{
Name: res.GetName(),
PrivateKey: res.GetPrivateKey(),
}, nil
}

func fromUpstreamClients(clients []*infra_res.ClientListItem) []*gwres.ClientListItem {
ts := make([]*gwres.ClientListItem, len(clients))
ts := make([]*gwres.ClientListItem, len(clients))

for i, c := range clients {
ts[i] = &gwres.ClientListItem{
Name: c.GetName(),
}
}
for i, c := range clients {
ts[i] = &gwres.ClientListItem{
Name: c.GetName(),
}
}

return ts
return ts
}
Loading

0 comments on commit ea48e37

Please sign in to comment.