diff --git a/api/external/infra_proxy/infra_proxy.pb.policy.go b/api/external/infra_proxy/infra_proxy.pb.policy.go index 8107d71c227..005b56b5f07 100644 --- a/api/external/infra_proxy/infra_proxy.pb.policy.go +++ b/api/external/infra_proxy/infra_proxy.pb.policy.go @@ -50,6 +50,8 @@ func init() { return m.Fqdn case "ip_address": return m.IpAddress + case "webui_key": + return m.WebuiKey default: return "" } diff --git a/api/external/infra_proxy/infra_proxy.swagger.json b/api/external/infra_proxy/infra_proxy.swagger.json index e3eae6a6237..ba39382143f 100644 --- a/api/external/infra_proxy/infra_proxy.swagger.json +++ b/api/external/infra_proxy/infra_proxy.swagger.json @@ -2862,6 +2862,10 @@ "ip_address": { "type": "string", "description": "Chef Infra Server IP address." + }, + "webui_key": { + "type": "string", + "description": "Chef Infra Server Webui key." } } }, diff --git a/api/external/infra_proxy/request/servers.pb.go b/api/external/infra_proxy/request/servers.pb.go index e577e8b9a97..a982015de96 100644 --- a/api/external/infra_proxy/request/servers.pb.go +++ b/api/external/infra_proxy/request/servers.pb.go @@ -33,6 +33,8 @@ type CreateServer struct { Fqdn string `protobuf:"bytes,3,opt,name=fqdn,proto3" json:"fqdn,omitempty"` // Chef Infra Server IP address. IpAddress string `protobuf:"bytes,4,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"` + // Chef Infra Server Webui key. + WebuiKey string `protobuf:"bytes,5,opt,name=webui_key,json=webuiKey,proto3" json:"webui_key,omitempty"` } func (x *CreateServer) Reset() { @@ -95,6 +97,13 @@ func (x *CreateServer) GetIpAddress() string { return "" } +func (x *CreateServer) GetWebuiKey() string { + if x != nil { + return x.WebuiKey + } + return "" +} + type UpdateServer struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -360,31 +369,33 @@ var file_external_infra_proxy_request_servers_proto_rawDesc = []byte{ 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x25, 0x63, 0x68, 0x65, 0x66, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x22, 0x65, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x69, - 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x69, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x65, 0x0a, 0x0c, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, - 0x64, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x22, 0x1e, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x22, 0x0c, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x22, - 0x1b, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x25, 0x0a, 0x0f, - 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x12, 0x0a, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, - 0x71, 0x64, 0x6e, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x69, 0x6e, 0x66, - 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x73, 0x74, 0x22, 0x82, 0x01, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x64, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, + 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x69, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x77, + 0x65, 0x62, 0x75, 0x69, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x77, 0x65, 0x62, 0x75, 0x69, 0x4b, 0x65, 0x79, 0x22, 0x65, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x66, 0x71, 0x64, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x64, 0x6e, + 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, + 0x1e, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, + 0x0c, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x22, 0x1b, 0x0a, + 0x09, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x25, 0x0a, 0x0f, 0x47, 0x65, + 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, + 0x04, 0x66, 0x71, 0x64, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x64, + 0x6e, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, + 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/external/infra_proxy/request/servers.proto b/api/external/infra_proxy/request/servers.proto index d2660e4d0e1..ccaeb7920d5 100644 --- a/api/external/infra_proxy/request/servers.proto +++ b/api/external/infra_proxy/request/servers.proto @@ -12,6 +12,8 @@ message CreateServer { string fqdn = 3; // Chef Infra Server IP address. string ip_address = 4; + // Chef Infra Server Webui key. + string webui_key = 5; } message UpdateServer { diff --git a/api/interservice/infra_proxy/request/servers.pb.go b/api/interservice/infra_proxy/request/servers.pb.go index 9028f221948..3ab16b98e8e 100644 --- a/api/interservice/infra_proxy/request/servers.pb.go +++ b/api/interservice/infra_proxy/request/servers.pb.go @@ -33,6 +33,8 @@ type CreateServer struct { Fqdn string `protobuf:"bytes,3,opt,name=fqdn,proto3" json:"fqdn,omitempty" toml:"fqdn,omitempty" mapstructure:"fqdn,omitempty"` // Chef Infra Server IP address. IpAddress string `protobuf:"bytes,4,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty" toml:"ip_address,omitempty" mapstructure:"ip_address,omitempty"` + // Chef Infra Server Webui key. + WebuiKey string `protobuf:"bytes,5,opt,name=webui_key,json=webuiKey,proto3" json:"webui_key,omitempty" toml:"webui_key,omitempty" mapstructure:"webui_key,omitempty"` } func (x *CreateServer) Reset() { @@ -95,6 +97,13 @@ func (x *CreateServer) GetIpAddress() string { return "" } +func (x *CreateServer) GetWebuiKey() string { + if x != nil { + return x.WebuiKey + } + return "" +} + type UpdateServer struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -369,34 +378,35 @@ var file_interservice_infra_proxy_request_servers_proto_rawDesc = []byte{ 0x73, 0x74, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x28, 0x63, 0x68, 0x65, 0x66, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x65, 0x0a, 0x0c, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, - 0x64, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x22, 0x65, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x78, 0x79, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x82, 0x01, 0x0a, 0x0c, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, + 0x71, 0x64, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x77, 0x65, 0x62, 0x75, 0x69, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x77, 0x65, 0x62, 0x75, 0x69, 0x4b, 0x65, 0x79, 0x22, + 0x65, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x70, 0x5f, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x70, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x1e, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x0c, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x73, 0x22, 0x1b, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x70, 0x5f, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, - 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x1e, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x0c, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x22, 0x1b, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x02, 0x69, 0x64, 0x22, 0x44, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x70, - 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x69, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, - 0x6f, 0x6d, 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x64, 0x22, 0x44, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x64, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x69, 0x70, 0x5f, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x70, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x65, 0x66, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6d, + 0x61, 0x74, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/interservice/infra_proxy/request/servers.proto b/api/interservice/infra_proxy/request/servers.proto index e7deed6983a..3f547f4f575 100644 --- a/api/interservice/infra_proxy/request/servers.proto +++ b/api/interservice/infra_proxy/request/servers.proto @@ -12,6 +12,8 @@ message CreateServer { string fqdn = 3; // Chef Infra Server IP address. string ip_address = 4; + // Chef Infra Server Webui key. + string webui_key = 5; } message UpdateServer { diff --git a/components/automate-gateway/api/infra_proxy.pb.swagger.go b/components/automate-gateway/api/infra_proxy.pb.swagger.go index 1d96e02425c..6816cbf0b61 100644 --- a/components/automate-gateway/api/infra_proxy.pb.swagger.go +++ b/components/automate-gateway/api/infra_proxy.pb.swagger.go @@ -2865,6 +2865,10 @@ func init() { "ip_address": { "type": "string", "description": "Chef Infra Server IP address." + }, + "webui_key": { + "type": "string", + "description": "Chef Infra Server Webui key." } } }, diff --git a/components/automate-gateway/handler/infra_proxy/servers.go b/components/automate-gateway/handler/infra_proxy/servers.go index c87361dae12..05ca94e7721 100644 --- a/components/automate-gateway/handler/infra_proxy/servers.go +++ b/components/automate-gateway/handler/infra_proxy/servers.go @@ -2,6 +2,7 @@ package infra_proxy import ( "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" @@ -44,6 +45,7 @@ func (a *InfraProxyServer) CreateServer(ctx context.Context, r *gwreq.CreateServ Name: r.Name, Fqdn: r.Fqdn, IpAddress: r.IpAddress, + WebuiKey: r.WebuiKey, } res, err := a.client.CreateServer(ctx, req) if err != nil { diff --git a/components/infra-proxy-service/server/servers.go b/components/infra-proxy-service/server/servers.go index 44c5cc0e173..ae5e16b0df2 100644 --- a/components/infra-proxy-service/server/servers.go +++ b/components/infra-proxy-service/server/servers.go @@ -5,6 +5,8 @@ import ( "encoding/json" "io/ioutil" + "github.com/chef/automate/api/external/common/query" + secrets "github.com/chef/automate/api/external/secrets" "github.com/chef/automate/api/interservice/infra_proxy/request" "github.com/chef/automate/api/interservice/infra_proxy/response" "github.com/chef/automate/components/infra-proxy-service/service" @@ -27,8 +29,9 @@ func (s *Server) CreateServer(ctx context.Context, req *request.CreateServer) (* Target: "server", Request: *req, Rules: validation.Rules{ - "Id": []string{"required"}, - "Name": []string{"required"}, + "Id": []string{"required"}, + "Name": []string{"required"}, + "WebuiKey": []string{"required"}, }, }).Validate() @@ -40,6 +43,19 @@ func (s *Server) CreateServer(ctx context.Context, req *request.CreateServer) (* return nil, errors.Wrap(err, "FQDN or IP required to add the server.") } + // TODO: validate the new webui key + newSecret := &secrets.Secret{ + Name: "infra-proxy-service-webui-key", + Type: "chef-server", + Data: []*query.Kv{ + {Key: "key", Value: req.WebuiKey}, + }, + } + credential, err := s.service.Secrets.Create(ctx, newSecret) + if err != nil { + return nil, err + } + // commenting this code because sometimes chef-services are down that time we can't able to check the server status and not able to add or update the server. /* serverHost := req.GetFqdn() @@ -53,7 +69,7 @@ func (s *Server) CreateServer(ctx context.Context, req *request.CreateServer) (* } */ - server, err := s.service.Storage.StoreServer(ctx, req.Id, req.Name, req.Fqdn, req.IpAddress) + server, err := s.service.Storage.StoreServer(ctx, req.Id, req.Name, req.Fqdn, req.IpAddress, credential.Id) if err != nil { return nil, service.ParseStorageError(err, *req, "server") } diff --git a/components/infra-proxy-service/server/servers_test.go b/components/infra-proxy-service/server/servers_test.go index db307f7fc3f..7f1bd22bf82 100644 --- a/components/infra-proxy-service/server/servers_test.go +++ b/components/infra-proxy-service/server/servers_test.go @@ -47,6 +47,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "example.com", IpAddress: "0.0.0.0", + WebuiKey: "--KEY--", } resp, err := cl.CreateServer(ctx, req) require.NoError(t, err) @@ -80,6 +81,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "example.com", IpAddress: "0.0.0.0", + WebuiKey: "--KEY--", }) assert.Nil(t, resp) assert.Error(t, err, "must supply server ID") @@ -94,6 +96,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "example.com", IpAddress: "0.0.0.0", + WebuiKey: "--KEY--", } resp1, err := cl.CreateServer(ctx, req1) require.NoError(t, err) @@ -105,6 +108,7 @@ func TestServers(t *testing.T) { Name: "New chef infra server", Fqdn: "example.com", IpAddress: "0.0.0.0", + WebuiKey: "--KEY--", } resp2, err := cl.CreateServer(ctx, req2) assert.Nil(t, resp2) @@ -117,11 +121,24 @@ func TestServers(t *testing.T) { Id: "chef-infra-server", Fqdn: "example.com", IpAddress: "0.0.0.0", + WebuiKey: "--KEY--", }) assert.Nil(t, resp) assert.Error(t, err, "must supply server name") grpctest.AssertCode(t, codes.InvalidArgument, err) }) + + t.Run("when the server webui key is missing, raise invalid argument error", func(t *testing.T) { + resp, err := cl.CreateServer(ctx, &request.CreateServer{ + Id: "chef-infra-server", + Name: "New chef infra server", + Fqdn: "example.com", + IpAddress: "0.0.0.0", + }) + assert.Nil(t, resp) + assert.Error(t, err, "must supply server webui key") + grpctest.AssertCode(t, codes.InvalidArgument, err) + }) }) t.Run("GetServers", func(t *testing.T) { @@ -140,6 +157,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "example.com", IpAddress: "0.0.0.0", + WebuiKey: "--KEY--", }) require.NoError(t, err) require.NotNil(t, resp1) @@ -149,6 +167,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "api.chef.io", IpAddress: "", + WebuiKey: "--KEY--", }) require.NoError(t, err) require.NotNil(t, resp2) @@ -174,6 +193,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "example.com", IpAddress: "0.0.0.0", + WebuiKey: "--KEY--", }) require.NoError(t, err) require.NotNil(t, resp1) @@ -229,6 +249,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "example.com", IpAddress: "0.0.0.0", + WebuiKey: "--KEY--", }) require.NoError(t, err) require.NotNil(t, resp1) @@ -257,6 +278,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "example.com", IpAddress: "0.0.0.0", + WebuiKey: "--KEY--", }) require.NoError(t, err) require.NotNil(t, resp1) @@ -297,6 +319,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "api.chef.io", IpAddress: "", + WebuiKey: "--KEY--", }) require.NoError(t, err) require.NotNil(t, resp1) @@ -325,6 +348,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "api.chef.io", IpAddress: "", + WebuiKey: "--KEY--", }) require.NoError(t, err) require.NotNil(t, resp1) @@ -386,6 +410,7 @@ func TestServers(t *testing.T) { Name: "Chef infra server", Fqdn: "example.com", IpAddress: "0.0.0.0", + WebuiKey: "--KEY--", }) require.NoError(t, err) require.NotNil(t, resp) diff --git a/components/infra-proxy-service/storage/postgres/servers.go b/components/infra-proxy-service/storage/postgres/servers.go index 63d0c703ca8..47dce93a91e 100644 --- a/components/infra-proxy-service/storage/postgres/servers.go +++ b/components/infra-proxy-service/storage/postgres/servers.go @@ -9,19 +9,19 @@ import ( ) // StoreServer saves a server to the DB. -func (p *postgres) StoreServer(ctx context.Context, id string, name string, fqdn string, ipAddress string) (storage.Server, error) { - return p.insertServer(ctx, id, name, fqdn, ipAddress) +func (p *postgres) StoreServer(ctx context.Context, id string, name string, fqdn string, ipAddress string, credentialId string) (storage.Server, error) { + return p.insertServer(ctx, id, name, fqdn, ipAddress, credentialId) } func (p *postgres) insertServer(ctx context.Context, - id string, name string, fqdn string, ipAddress string) (storage.Server, error) { + id string, name string, fqdn string, ipAddress string, credentialId string) (storage.Server, error) { var server storage.Server err := p.db.QueryRowContext(ctx, - `INSERT INTO servers (id, name, fqdn, ip_address, created_at, updated_at) - VALUES ($1, $2, $3, $4, now(), now()) + `INSERT INTO servers (id, name, fqdn, ip_address, credential_id, created_at, updated_at) + VALUES ($1, $2, $3, $4, $5, now(), now()) RETURNING id, name, fqdn, ip_address, created_at, updated_at`, - id, name, fqdn, ipAddress). + id, name, fqdn, ipAddress, credentialId). Scan(&server.ID, &server.Name, &server.Fqdn, &server.IPAddress, &server.CreatedAt, &server.UpdatedAt) if err != nil { return storage.Server{}, p.processError(err) diff --git a/components/infra-proxy-service/storage/storage.go b/components/infra-proxy-service/storage/storage.go index a3db1bbf7a4..733c829ff74 100644 --- a/components/infra-proxy-service/storage/storage.go +++ b/components/infra-proxy-service/storage/storage.go @@ -10,7 +10,7 @@ import ( type Storage interface { GetServer(ctx context.Context, id string) (Server, error) GetServers(ctx context.Context) ([]Server, error) - StoreServer(ctx context.Context, id string, name string, fqdn string, ipAddress string) (Server, error) + StoreServer(ctx context.Context, id string, name string, fqdn string, ipAddress string, credentialId string) (Server, error) DeleteServer(ctx context.Context, id string) (Server, error) EditServer(ctx context.Context, id string, name string, fqdn string, ipAddress string) (Server, error)