From 435815c9169181db13e9b6d9200405a51ddceccb Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Fri, 27 Mar 2020 21:00:20 +0530 Subject: [PATCH 1/7] [infra-proxy-service] Add description & environment attribute in role list API Signed-off-by: Vivek Singh --- .../infra_proxy/infra_proxy.swagger.json | 91 ++++++- api/external/infra_proxy/response/roles.pb.go | 249 +++++++++++++++-- api/external/infra_proxy/response/roles.proto | 45 +++- .../infra_proxy/response/roles.pb.go | 250 +++++++++++++++--- .../infra_proxy/response/roles.proto | 45 +++- .../api/infra_proxy.pb.swagger.go | 91 ++++++- .../handler/infra_proxy/roles.go | 16 +- .../infra-proxy-service/server/roles.go | 82 +++++- 8 files changed, 767 insertions(+), 102 deletions(-) diff --git a/api/external/infra_proxy/infra_proxy.swagger.json b/api/external/infra_proxy/infra_proxy.swagger.json index db588c7ffa8..7a7da210556 100644 --- a/api/external/infra_proxy/infra_proxy.swagger.json +++ b/api/external/infra_proxy/infra_proxy.swagger.json @@ -1344,6 +1344,22 @@ } } }, + "chef.automate.api.infra_proxy.response.ExpandedRunList": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Id of the run list collection." + }, + "run_list": { + "type": "array", + "items": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.RunList" + }, + "description": "List of the run list." + } + } + }, "chef.automate.api.infra_proxy.response.GetOrg": { "type": "object", "properties": { @@ -1441,22 +1457,39 @@ "type": "object", "properties": { "name": { - "type": "string" + "type": "string", + "description": "Name of the role." }, "chef_type": { - "type": "string" + "type": "string", + "description": "Type of the chef object." }, "description": { - "type": "string" + "type": "string", + "description": "Descrption of the role." + }, + "default_attributes": { + "type": "string", + "description": "Stringified json of the default attributes." + }, + "override_attributes": { + "type": "string", + "description": "Stringified json of the override attributes." + }, + "json_class": { + "type": "string", + "description": "Json class name." }, "run_list": { "type": "array", "items": { "type": "string" - } + }, + "description": "Run list for the role." }, - "json_class": { - "type": "string" + "expanded_run_list": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.ExpandedRunList", + "description": "Expanded run list for the role." } } }, @@ -1464,7 +1497,19 @@ "type": "object", "properties": { "name": { - "type": "string" + "type": "string", + "description": "Name of the role." + }, + "description": { + "type": "string", + "description": "Desscription of the role." + }, + "environments": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Environment for the role." } } }, @@ -1475,7 +1520,37 @@ "type": "array", "items": { "$ref": "#/definitions/chef.automate.api.infra_proxy.response.RoleListItem" - } + }, + "description": "List of the roles item." + } + } + }, + "chef.automate.api.infra_proxy.response.RunList": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "Type of run list item (e.g. 'recipe')." + }, + "name": { + "type": "string", + "description": "Name of run list item." + }, + "version": { + "type": "string", + "description": "Version of run list item." + }, + "skipped": { + "type": "boolean", + "format": "boolean", + "description": "Boolean denoting whether or not the run list item was skipped." + }, + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.RunList" + }, + "description": "List of the run list." } } }, diff --git a/api/external/infra_proxy/response/roles.pb.go b/api/external/infra_proxy/response/roles.pb.go index 817e6b1bbc6..511c8a469d6 100644 --- a/api/external/infra_proxy/response/roles.pb.go +++ b/api/external/infra_proxy/response/roles.pb.go @@ -21,6 +21,7 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type Roles struct { + // List of the roles item. Roles []*RoleListItem `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -60,7 +61,12 @@ func (m *Roles) GetRoles() []*RoleListItem { } type RoleListItem struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Name of the role. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Desscription of the role. + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + // Environment for the role. + Environments []string `protobuf:"bytes,3,rep,name=environments,proto3" json:"environments,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -98,15 +104,40 @@ func (m *RoleListItem) GetName() string { return "" } +func (m *RoleListItem) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *RoleListItem) GetEnvironments() []string { + if m != nil { + return m.Environments + } + return nil +} + type Role struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - ChefType string `protobuf:"bytes,2,opt,name=chef_type,json=chefType,proto3" json:"chef_type,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` - RunList []string `protobuf:"bytes,4,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty"` - JsonClass string `protobuf:"bytes,5,opt,name=json_class,json=jsonClass,proto3" json:"json_class,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + // Name of the role. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Type of the chef object. + ChefType string `protobuf:"bytes,2,opt,name=chef_type,json=chefType,proto3" json:"chef_type,omitempty"` + // Descrption of the role. + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + // Stringified json of the default attributes. + DefaultAttributes string `protobuf:"bytes,4,opt,name=default_attributes,json=defaultAttributes,proto3" json:"default_attributes,omitempty"` + // Stringified json of the override attributes. + OverrideAttributes string `protobuf:"bytes,5,opt,name=override_attributes,json=overrideAttributes,proto3" json:"override_attributes,omitempty"` + // Json class name. + JsonClass string `protobuf:"bytes,6,opt,name=json_class,json=jsonClass,proto3" json:"json_class,omitempty"` + // Run list for the role. + RunList []string `protobuf:"bytes,7,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty"` + // Expanded run list for the role. + ExpandedRunList *ExpandedRunList `protobuf:"bytes,8,opt,name=expanded_run_list,json=expandedRunList,proto3" json:"expanded_run_list,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Role) Reset() { *m = Role{} } @@ -155,6 +186,27 @@ func (m *Role) GetDescription() string { return "" } +func (m *Role) GetDefaultAttributes() string { + if m != nil { + return m.DefaultAttributes + } + return "" +} + +func (m *Role) GetOverrideAttributes() string { + if m != nil { + return m.OverrideAttributes + } + return "" +} + +func (m *Role) GetJsonClass() string { + if m != nil { + return m.JsonClass + } + return "" +} + func (m *Role) GetRunList() []string { if m != nil { return m.RunList @@ -162,17 +214,144 @@ func (m *Role) GetRunList() []string { return nil } -func (m *Role) GetJsonClass() string { +func (m *Role) GetExpandedRunList() *ExpandedRunList { if m != nil { - return m.JsonClass + return m.ExpandedRunList + } + return nil +} + +type ExpandedRunList struct { + // Id of the run list collection. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // List of the run list. + RunList []*RunList `protobuf:"bytes,2,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ExpandedRunList) Reset() { *m = ExpandedRunList{} } +func (m *ExpandedRunList) String() string { return proto.CompactTextString(m) } +func (*ExpandedRunList) ProtoMessage() {} +func (*ExpandedRunList) Descriptor() ([]byte, []int) { + return fileDescriptor_9263c727ab16ef6b, []int{3} +} + +func (m *ExpandedRunList) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExpandedRunList.Unmarshal(m, b) +} +func (m *ExpandedRunList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExpandedRunList.Marshal(b, m, deterministic) +} +func (m *ExpandedRunList) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExpandedRunList.Merge(m, src) +} +func (m *ExpandedRunList) XXX_Size() int { + return xxx_messageInfo_ExpandedRunList.Size(m) +} +func (m *ExpandedRunList) XXX_DiscardUnknown() { + xxx_messageInfo_ExpandedRunList.DiscardUnknown(m) +} + +var xxx_messageInfo_ExpandedRunList proto.InternalMessageInfo + +func (m *ExpandedRunList) GetId() string { + if m != nil { + return m.Id } return "" } +func (m *ExpandedRunList) GetRunList() []*RunList { + if m != nil { + return m.RunList + } + return nil +} + +type RunList struct { + // Type of run list item (e.g. 'recipe'). + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + // Name of run list item. + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // Version of run list item. + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"` + // Boolean denoting whether or not the run list item was skipped. + Skipped bool `protobuf:"varint,4,opt,name=skipped,proto3" json:"skipped,omitempty"` + // List of the run list. + Children []*RunList `protobuf:"bytes,5,rep,name=children,proto3" json:"children,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RunList) Reset() { *m = RunList{} } +func (m *RunList) String() string { return proto.CompactTextString(m) } +func (*RunList) ProtoMessage() {} +func (*RunList) Descriptor() ([]byte, []int) { + return fileDescriptor_9263c727ab16ef6b, []int{4} +} + +func (m *RunList) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RunList.Unmarshal(m, b) +} +func (m *RunList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RunList.Marshal(b, m, deterministic) +} +func (m *RunList) XXX_Merge(src proto.Message) { + xxx_messageInfo_RunList.Merge(m, src) +} +func (m *RunList) XXX_Size() int { + return xxx_messageInfo_RunList.Size(m) +} +func (m *RunList) XXX_DiscardUnknown() { + xxx_messageInfo_RunList.DiscardUnknown(m) +} + +var xxx_messageInfo_RunList proto.InternalMessageInfo + +func (m *RunList) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *RunList) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *RunList) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *RunList) GetSkipped() bool { + if m != nil { + return m.Skipped + } + return false +} + +func (m *RunList) GetChildren() []*RunList { + if m != nil { + return m.Children + } + return nil +} + func init() { proto.RegisterType((*Roles)(nil), "chef.automate.api.infra_proxy.response.Roles") proto.RegisterType((*RoleListItem)(nil), "chef.automate.api.infra_proxy.response.RoleListItem") proto.RegisterType((*Role)(nil), "chef.automate.api.infra_proxy.response.Role") + proto.RegisterType((*ExpandedRunList)(nil), "chef.automate.api.infra_proxy.response.ExpandedRunList") + proto.RegisterType((*RunList)(nil), "chef.automate.api.infra_proxy.response.RunList") } func init() { @@ -180,22 +359,34 @@ func init() { } var fileDescriptor_9263c727ab16ef6b = []byte{ - // 271 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x31, 0x4b, 0xc4, 0x30, - 0x14, 0xc7, 0xa9, 0x6d, 0xf5, 0xfa, 0xce, 0x29, 0x53, 0x44, 0x84, 0xd2, 0x41, 0xba, 0x98, 0x80, - 0x3a, 0x89, 0x93, 0x4e, 0x8a, 0x53, 0x75, 0x72, 0x29, 0xb9, 0xfa, 0xce, 0x8b, 0xb4, 0x49, 0x48, - 0x52, 0xb8, 0x7e, 0x0e, 0xbf, 0xb0, 0x24, 0x52, 0xe8, 0x20, 0x78, 0x5b, 0xf8, 0xfd, 0xf3, 0x7b, - 0x2f, 0xfc, 0x03, 0x57, 0xc2, 0x48, 0x8e, 0x7b, 0x8f, 0x56, 0x89, 0x9e, 0x4b, 0xb5, 0xb5, 0xa2, - 0x35, 0x56, 0xef, 0x27, 0x6e, 0xd1, 0x19, 0xad, 0x1c, 0x72, 0xab, 0x7b, 0x74, 0xcc, 0x58, 0xed, - 0x35, 0xb9, 0xec, 0x76, 0xb8, 0x65, 0x62, 0xf4, 0x7a, 0x10, 0x1e, 0x99, 0x30, 0x92, 0x2d, 0x1c, - 0x36, 0x3b, 0xd5, 0x2b, 0xe4, 0x4d, 0xd0, 0xc8, 0x33, 0xe4, 0xd1, 0xa7, 0x49, 0x99, 0xd6, 0xeb, - 0xeb, 0x5b, 0x76, 0xd8, 0x00, 0x16, 0xec, 0x17, 0xe9, 0xfc, 0x93, 0xc7, 0xa1, 0xf9, 0x1d, 0x51, - 0x55, 0x70, 0xba, 0xc4, 0x84, 0x40, 0xa6, 0xc4, 0x80, 0x34, 0x29, 0x93, 0xba, 0x68, 0xe2, 0xb9, - 0xfa, 0x4e, 0x20, 0x0b, 0x97, 0xfe, 0x0a, 0xc9, 0x39, 0x14, 0x61, 0x7d, 0xeb, 0x27, 0x83, 0xf4, - 0x28, 0x06, 0xab, 0x00, 0xde, 0x26, 0x83, 0xa4, 0x84, 0xf5, 0x07, 0xba, 0xce, 0x4a, 0xe3, 0xa5, - 0x56, 0x34, 0x8d, 0xf1, 0x12, 0x91, 0x33, 0x58, 0xd9, 0x51, 0xb5, 0xbd, 0x74, 0x9e, 0x66, 0x65, - 0x5a, 0x17, 0xcd, 0x89, 0x1d, 0x55, 0x78, 0x0e, 0xb9, 0x00, 0xf8, 0x72, 0x5a, 0xb5, 0x5d, 0x2f, - 0x9c, 0xa3, 0x79, 0x74, 0x8b, 0x40, 0x1e, 0x03, 0x78, 0xb8, 0x7f, 0xbf, 0xfb, 0x94, 0x7e, 0x37, - 0x6e, 0x58, 0xa7, 0x07, 0x1e, 0x56, 0xf2, 0xb9, 0x02, 0xfe, 0xef, 0x07, 0x6c, 0x8e, 0x63, 0xf7, - 0x37, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x42, 0x4a, 0x0e, 0xc0, 0xac, 0x01, 0x00, 0x00, + // 455 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xc1, 0x8e, 0xd3, 0x30, + 0x10, 0x55, 0xd2, 0x76, 0x9b, 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xfd, 0x9d, 0xdf, 0xb0, 0xf5, 0x15, 0xfb, 0x5d, 0x68, 0x8d, 0x3c, 0x04, 0x96, 0x94, 0xc3, + 0x96, 0x7c, 0x80, 0xa4, 0xde, 0x8a, 0x86, 0x1b, 0x94, 0xe9, 0xec, 0xff, 0xce, 0x7c, 0x14, 0x78, + 0xf3, 0xea, 0xcb, 0xcb, 0xaf, 0xc2, 0x6d, 0xbb, 0x75, 0x51, 0xab, 0x96, 0x7a, 0x19, 0x3a, 0xc8, + 0xd0, 0x7f, 0xfe, 0xd7, 0xf5, 0x59, 0xf8, 0xaa, 0xcf, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, 0xa6, + 0xfe, 0x28, 0xd4, 0xdb, 0x03, 0x00, 0x00, } diff --git a/api/external/infra_proxy/response/roles.proto b/api/external/infra_proxy/response/roles.proto index 28d05aee31c..9c0e00df27b 100644 --- a/api/external/infra_proxy/response/roles.proto +++ b/api/external/infra_proxy/response/roles.proto @@ -4,17 +4,54 @@ package chef.automate.api.infra_proxy.response; option go_package = "github.com/chef/automate/api/external/infra_proxy/response"; message Roles { + // List of the roles item. repeated RoleListItem roles = 1; } message RoleListItem { + // Name of the role. string name = 1; + // Desscription of the role. + string description = 2; + // Environment for the role. + repeated string environments = 3; } message Role { + // Name of the role. string name = 1; - string chef_type = 2; - string description = 3; - repeated string run_list = 4; - string json_class = 5; + // Type of the chef object. + string chef_type = 2; + // Descrption of the role. + string description = 3; + // Stringified json of the default attributes. + string default_attributes = 4; + // Stringified json of the override attributes. + string override_attributes = 5; + // Json class name. + string json_class = 6; + // Run list for the role. + repeated string run_list = 7; + // Expanded run list for the role. + ExpandedRunList expanded_run_list = 8; +} + +message ExpandedRunList { + // Id of the run list collection. + string id = 1; + // List of the run list. + repeated RunList run_list = 2; +} + +message RunList { + // Type of run list item (e.g. 'recipe'). + string type = 1; + // Name of run list item. + string name = 2; + // Version of run list item. + string version = 3; + // Boolean denoting whether or not the run list item was skipped. + bool skipped = 4; + // List of the run list. + repeated RunList children = 5; } diff --git a/api/interservice/infra_proxy/response/roles.pb.go b/api/interservice/infra_proxy/response/roles.pb.go index ffbc1b08db3..02c6eee8756 100644 --- a/api/interservice/infra_proxy/response/roles.pb.go +++ b/api/interservice/infra_proxy/response/roles.pb.go @@ -21,6 +21,7 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type Roles struct { + // List of the roles item. Roles []*RoleListItem `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty" toml:"roles,omitempty" mapstructure:"roles,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-" toml:"-" mapstructure:"-,omitempty"` XXX_unrecognized []byte `json:"-" toml:"-" mapstructure:"-,omitempty"` @@ -60,7 +61,12 @@ func (m *Roles) GetRoles() []*RoleListItem { } type RoleListItem struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" toml:"name,omitempty" mapstructure:"name,omitempty"` + // Name of the role. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" toml:"name,omitempty" mapstructure:"name,omitempty"` + // Desscription of the role. + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" toml:"description,omitempty" mapstructure:"description,omitempty"` + // Environment for the role. + Environments []string `protobuf:"bytes,3,rep,name=environments,proto3" json:"environments,omitempty" toml:"environments,omitempty" mapstructure:"environments,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-" toml:"-" mapstructure:"-,omitempty"` XXX_unrecognized []byte `json:"-" toml:"-" mapstructure:"-,omitempty"` XXX_sizecache int32 `json:"-" toml:"-" mapstructure:"-,omitempty"` @@ -98,15 +104,40 @@ func (m *RoleListItem) GetName() string { return "" } +func (m *RoleListItem) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *RoleListItem) GetEnvironments() []string { + if m != nil { + return m.Environments + } + return nil +} + type Role struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" toml:"name,omitempty" mapstructure:"name,omitempty"` - ChefType string `protobuf:"bytes,2,opt,name=chef_type,json=chefType,proto3" json:"chef_type,omitempty" toml:"chef_type,omitempty" mapstructure:"chef_type,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty" toml:"description,omitempty" mapstructure:"description,omitempty"` - RunList []string `protobuf:"bytes,4,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty" toml:"run_list,omitempty" mapstructure:"run_list,omitempty"` - JsonClass string `protobuf:"bytes,5,opt,name=json_class,json=jsonClass,proto3" json:"json_class,omitempty" toml:"json_class,omitempty" mapstructure:"json_class,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-" toml:"-" mapstructure:"-,omitempty"` - XXX_unrecognized []byte `json:"-" toml:"-" mapstructure:"-,omitempty"` - XXX_sizecache int32 `json:"-" toml:"-" mapstructure:"-,omitempty"` + // Name of the role. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" toml:"name,omitempty" mapstructure:"name,omitempty"` + // Type of the chef object. + ChefType string `protobuf:"bytes,2,opt,name=chef_type,json=chefType,proto3" json:"chef_type,omitempty" toml:"chef_type,omitempty" mapstructure:"chef_type,omitempty"` + // Descrption of the role. + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty" toml:"description,omitempty" mapstructure:"description,omitempty"` + // Stringified json of the default attributes. + DefaultAttributes string `protobuf:"bytes,4,opt,name=default_attributes,json=defaultAttributes,proto3" json:"default_attributes,omitempty" toml:"default_attributes,omitempty" mapstructure:"default_attributes,omitempty"` + // Stringified json of the override attributes. + OverrideAttributes string `protobuf:"bytes,5,opt,name=override_attributes,json=overrideAttributes,proto3" json:"override_attributes,omitempty" toml:"override_attributes,omitempty" mapstructure:"override_attributes,omitempty"` + // Json class name. + JsonClass string `protobuf:"bytes,6,opt,name=json_class,json=jsonClass,proto3" json:"json_class,omitempty" toml:"json_class,omitempty" mapstructure:"json_class,omitempty"` + // Run list for the role. + RunList []string `protobuf:"bytes,7,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty" toml:"run_list,omitempty" mapstructure:"run_list,omitempty"` + // Expanded run list for the role. + ExpandedRunList *ExpandedRunList `protobuf:"bytes,8,opt,name=expanded_run_list,json=expandedRunList,proto3" json:"expanded_run_list,omitempty" toml:"expanded_run_list,omitempty" mapstructure:"expanded_run_list,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-" toml:"-" mapstructure:"-,omitempty"` + XXX_unrecognized []byte `json:"-" toml:"-" mapstructure:"-,omitempty"` + XXX_sizecache int32 `json:"-" toml:"-" mapstructure:"-,omitempty"` } func (m *Role) Reset() { *m = Role{} } @@ -155,6 +186,27 @@ func (m *Role) GetDescription() string { return "" } +func (m *Role) GetDefaultAttributes() string { + if m != nil { + return m.DefaultAttributes + } + return "" +} + +func (m *Role) GetOverrideAttributes() string { + if m != nil { + return m.OverrideAttributes + } + return "" +} + +func (m *Role) GetJsonClass() string { + if m != nil { + return m.JsonClass + } + return "" +} + func (m *Role) GetRunList() []string { if m != nil { return m.RunList @@ -162,17 +214,144 @@ func (m *Role) GetRunList() []string { return nil } -func (m *Role) GetJsonClass() string { +func (m *Role) GetExpandedRunList() *ExpandedRunList { if m != nil { - return m.JsonClass + return m.ExpandedRunList + } + return nil +} + +type ExpandedRunList struct { + // Id of the run list collection. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" toml:"id,omitempty" mapstructure:"id,omitempty"` + // List of the run list. + RunList []*RunList `protobuf:"bytes,2,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty" toml:"run_list,omitempty" mapstructure:"run_list,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-" toml:"-" mapstructure:"-,omitempty"` + XXX_unrecognized []byte `json:"-" toml:"-" mapstructure:"-,omitempty"` + XXX_sizecache int32 `json:"-" toml:"-" mapstructure:"-,omitempty"` +} + +func (m *ExpandedRunList) Reset() { *m = ExpandedRunList{} } +func (m *ExpandedRunList) String() string { return proto.CompactTextString(m) } +func (*ExpandedRunList) ProtoMessage() {} +func (*ExpandedRunList) Descriptor() ([]byte, []int) { + return fileDescriptor_b015d7d081968c7b, []int{3} +} + +func (m *ExpandedRunList) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExpandedRunList.Unmarshal(m, b) +} +func (m *ExpandedRunList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExpandedRunList.Marshal(b, m, deterministic) +} +func (m *ExpandedRunList) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExpandedRunList.Merge(m, src) +} +func (m *ExpandedRunList) XXX_Size() int { + return xxx_messageInfo_ExpandedRunList.Size(m) +} +func (m *ExpandedRunList) XXX_DiscardUnknown() { + xxx_messageInfo_ExpandedRunList.DiscardUnknown(m) +} + +var xxx_messageInfo_ExpandedRunList proto.InternalMessageInfo + +func (m *ExpandedRunList) GetId() string { + if m != nil { + return m.Id } return "" } +func (m *ExpandedRunList) GetRunList() []*RunList { + if m != nil { + return m.RunList + } + return nil +} + +type RunList struct { + // Type of run list item (e.g. 'recipe'). + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty" toml:"type,omitempty" mapstructure:"type,omitempty"` + // Name of run list item. + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" toml:"name,omitempty" mapstructure:"name,omitempty"` + // Version of run list item. + Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty" toml:"version,omitempty" mapstructure:"version,omitempty"` + // Boolean denoting whether or not the run list item was skipped. + Skipped bool `protobuf:"varint,4,opt,name=skipped,proto3" json:"skipped,omitempty" toml:"skipped,omitempty" mapstructure:"skipped,omitempty"` + // List of the run list. + Children []*RunList `protobuf:"bytes,5,rep,name=children,proto3" json:"children,omitempty" toml:"children,omitempty" mapstructure:"children,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-" toml:"-" mapstructure:"-,omitempty"` + XXX_unrecognized []byte `json:"-" toml:"-" mapstructure:"-,omitempty"` + XXX_sizecache int32 `json:"-" toml:"-" mapstructure:"-,omitempty"` +} + +func (m *RunList) Reset() { *m = RunList{} } +func (m *RunList) String() string { return proto.CompactTextString(m) } +func (*RunList) ProtoMessage() {} +func (*RunList) Descriptor() ([]byte, []int) { + return fileDescriptor_b015d7d081968c7b, []int{4} +} + +func (m *RunList) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RunList.Unmarshal(m, b) +} +func (m *RunList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RunList.Marshal(b, m, deterministic) +} +func (m *RunList) XXX_Merge(src proto.Message) { + xxx_messageInfo_RunList.Merge(m, src) +} +func (m *RunList) XXX_Size() int { + return xxx_messageInfo_RunList.Size(m) +} +func (m *RunList) XXX_DiscardUnknown() { + xxx_messageInfo_RunList.DiscardUnknown(m) +} + +var xxx_messageInfo_RunList proto.InternalMessageInfo + +func (m *RunList) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *RunList) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *RunList) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *RunList) GetSkipped() bool { + if m != nil { + return m.Skipped + } + return false +} + +func (m *RunList) GetChildren() []*RunList { + if m != nil { + return m.Children + } + return nil +} + func init() { proto.RegisterType((*Roles)(nil), "chef.automate.domain.infra_proxy.response.Roles") proto.RegisterType((*RoleListItem)(nil), "chef.automate.domain.infra_proxy.response.RoleListItem") proto.RegisterType((*Role)(nil), "chef.automate.domain.infra_proxy.response.Role") + proto.RegisterType((*ExpandedRunList)(nil), "chef.automate.domain.infra_proxy.response.ExpandedRunList") + proto.RegisterType((*RunList)(nil), "chef.automate.domain.infra_proxy.response.RunList") } func init() { @@ -180,23 +359,34 @@ func init() { } var fileDescriptor_b015d7d081968c7b = []byte{ - // 277 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91,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e, 0x77, 0xd2, 0x06, 0x69, 0x34, 0x5d, 0xa4, 0x78, 0x8e, 0xc8, 0x19, 0x2c, 0xdd, 0xa8, - 0xbb, 0x41, 0xfa, 0x40, 0xf3, 0x6a, 0xd1, 0x94, 0xed, 0x89, 0x1b, 0x75, 0x1c, 0x87, 0x5c, 0x00, - 0x7c, 0x7a, 0xa3, 0xbb, 0x7e, 0x10, 0xde, 0xd3, 0x22, 0x75, 0xcb, 0x48, 0x1e, 0x23, 0x78, 0xb8, - 0x7f, 0xbf, 0xfb, 0x90, 0x61, 0x37, 0xae, 0x59, 0x6f, 0x14, 0x8f, 0x4f, 0xf2, 0xfd, 0x2f, 0xf0, - 0x83, 0x56, 0xb1, 0x3e, 0x4e, 0x5b, 0xb8, 0xf9, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x95, 0x58, 0x15, - 0xf7, 0xba, 0x01, 0x00, 0x00, + // 462 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4d, 0x8f, 0xd3, 0x30, + 0x10, 0x55, 0xd2, 0x76, 0x9b, 0x4e, 0x57, 0xac, 0xd6, 0x5c, 0x8c, 0x10, 0x52, 0x94, 0x53, 0x39, + 0x90, 0x88, 0x72, 0x40, 0xe2, 0x80, 0xf8, 0x10, 0x07, 0x24, 0x96, 0x43, 0x84, 0x38, 0x70, 0x89, + 0xdc, 0x78, 0x4a, 0x0d, 0x89, 0x6d, 0xd9, 0x4e, 0xb5, 0xfd, 0x61, 0xfc, 0x1a, 0xfe, 0x0c, 0xb2, + 0x37, 0x29, 0x59, 0x96, 0xc3, 0xee, 0xde, 0xec, 0x37, 0x6f, 0xde, 0xf3, 0xf8, 0xd9, 0xf0, 0x9c, + 0x69, 0x51, 0x08, 0xe9, 0xd0, 0x58, 0x34, 0x7b, 0x51, 0x63, 0x21, 0xe4, 0xd6, 0xb0, 0x4a, 0x1b, + 0x75, 0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x00, 0x00, } diff --git a/api/interservice/infra_proxy/response/roles.proto b/api/interservice/infra_proxy/response/roles.proto index 5f96da8ce2d..04626785b1b 100644 --- a/api/interservice/infra_proxy/response/roles.proto +++ b/api/interservice/infra_proxy/response/roles.proto @@ -4,17 +4,54 @@ package chef.automate.domain.infra_proxy.response; option go_package = "github.com/chef/automate/api/interservice/infra_proxy/response"; message Roles { + // List of the roles item. repeated RoleListItem roles = 1; } message RoleListItem { + // Name of the role. string name = 1; + // Desscription of the role. + string description = 2; + // Environment for the role. + repeated string environments = 3; } message Role { + // Name of the role. string name = 1; - string chef_type = 2; - string description = 3; - repeated string run_list = 4; - string json_class = 5; + // Type of the chef object. + string chef_type = 2; + // Descrption of the role. + string description = 3; + // Stringified json of the default attributes. + string default_attributes = 4; + // Stringified json of the override attributes. + string override_attributes = 5; + // Json class name. + string json_class = 6; + // Run list for the role. + repeated string run_list = 7; + // Expanded run list for the role. + ExpandedRunList expanded_run_list = 8; +} + +message ExpandedRunList { + // Id of the run list collection. + string id = 1; + // List of the run list. + repeated RunList run_list = 2; +} + +message RunList { + // Type of run list item (e.g. 'recipe'). + string type = 1; + // Name of run list item. + string name = 2; + // Version of run list item. + string version = 3; + // Boolean denoting whether or not the run list item was skipped. + bool skipped = 4; + // List of the run list. + repeated RunList children = 5; } diff --git a/components/automate-gateway/api/infra_proxy.pb.swagger.go b/components/automate-gateway/api/infra_proxy.pb.swagger.go index 1c26704013d..6d39936529f 100644 --- a/components/automate-gateway/api/infra_proxy.pb.swagger.go +++ b/components/automate-gateway/api/infra_proxy.pb.swagger.go @@ -1347,6 +1347,22 @@ func init() { } } }, + "chef.automate.api.infra_proxy.response.ExpandedRunList": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Id of the run list collection." + }, + "run_list": { + "type": "array", + "items": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.RunList" + }, + "description": "List of the run list." + } + } + }, "chef.automate.api.infra_proxy.response.GetOrg": { "type": "object", "properties": { @@ -1444,22 +1460,39 @@ func init() { "type": "object", "properties": { "name": { - "type": "string" + "type": "string", + "description": "Name of the role." }, "chef_type": { - "type": "string" + "type": "string", + "description": "Type of the chef object." }, "description": { - "type": "string" + "type": "string", + "description": "Descrption of the role." + }, + "default_attributes": { + "type": "string", + "description": "Stringified json of the default attributes." + }, + "override_attributes": { + "type": "string", + "description": "Stringified json of the override attributes." + }, + "json_class": { + "type": "string", + "description": "Json class name." }, "run_list": { "type": "array", "items": { "type": "string" - } + }, + "description": "Run list for the role." }, - "json_class": { - "type": "string" + "expanded_run_list": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.ExpandedRunList", + "description": "Expanded run list for the role." } } }, @@ -1467,7 +1500,19 @@ func init() { "type": "object", "properties": { "name": { - "type": "string" + "type": "string", + "description": "Name of the role." + }, + "description": { + "type": "string", + "description": "Desscription of the role." + }, + "environments": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Environment for the role." } } }, @@ -1478,7 +1523,37 @@ func init() { "type": "array", "items": { "$ref": "#/definitions/chef.automate.api.infra_proxy.response.RoleListItem" - } + }, + "description": "List of the roles item." + } + } + }, + "chef.automate.api.infra_proxy.response.RunList": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "Type of run list item (e.g. 'recipe')." + }, + "name": { + "type": "string", + "description": "Name of run list item." + }, + "version": { + "type": "string", + "description": "Version of run list item." + }, + "skipped": { + "type": "boolean", + "format": "boolean", + "description": "Boolean denoting whether or not the run list item was skipped." + }, + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.RunList" + }, + "description": "List of the run list." } } }, diff --git a/components/automate-gateway/handler/infra_proxy/roles.go b/components/automate-gateway/handler/infra_proxy/roles.go index c7550488d73..2a5c8001604 100644 --- a/components/automate-gateway/handler/infra_proxy/roles.go +++ b/components/automate-gateway/handler/infra_proxy/roles.go @@ -36,11 +36,13 @@ func (a *InfraProxyServer) GetRole(ctx context.Context, r *gwreq.Role) (*gwres.R } return &gwres.Role{ - Name: res.GetName(), - ChefType: res.GetChefType(), - Description: res.GetDescription(), - RunList: res.GetRunList(), - JsonClass: res.GetJsonClass(), + Name: res.GetName(), + ChefType: res.GetChefType(), + Description: res.GetDescription(), + DefaultAttributes: res.GetDefaultAttributes(), + OverrideAttributes: res.GetOverrideAttributes(), + RunList: res.GetRunList(), + JsonClass: res.GetJsonClass(), }, nil } @@ -49,7 +51,9 @@ func fromUpstreamRoles(roles []*infra_res.RoleListItem) []*gwres.RoleListItem { for i, c := range roles { ts[i] = &gwres.RoleListItem{ - Name: c.GetName(), + Name: c.GetName(), + Description: c.GetDescription(), + Environments: c.GetEnvironments(), } } diff --git a/components/infra-proxy-service/server/roles.go b/components/infra-proxy-service/server/roles.go index 6eaa3c016db..0dc0eaaecbd 100644 --- a/components/infra-proxy-service/server/roles.go +++ b/components/infra-proxy-service/server/roles.go @@ -2,9 +2,10 @@ package server import ( "context" + "encoding/json" + "reflect" "sort" - chef "github.com/chef/go-chef" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -12,6 +13,31 @@ import ( "github.com/chef/automate/api/interservice/infra_proxy/response" ) +// RunList represents the recipes and roles specified for a node or as part of a role. +type RunList []string + +// EnvRunList represents the recipes and roles with environment specified for a node or as part of a role. +type EnvRunList map[string]RunList + +// Role represents the native Go version of the deserialized Role type +type Role struct { + Name string `json:"name"` + ChefType string `json:"chef_type"` + Description string `json:"description"` + RunList RunList `json:"run_list"` + EnvRunList EnvRunList `json:"env_run_lists"` + DefaultAttributes interface{} `json:"default_attributes,omitempty"` + OverrideAttributes interface{} `json:"override_attributes,omitempty"` + JSONClass string `json:"json_class,omitempty"` +} + +// RoleListResult role list result from Search API +type RoleListResult struct { + Total int `json:"total"` + Start int `json:"start"` + Rows []*Role `json:"rows"` +} + // GetRoles get roles list func (s *Server) GetRoles(ctx context.Context, req *request.Roles) (*response.Roles, error) { @@ -20,13 +46,21 @@ func (s *Server) GetRoles(ctx context.Context, req *request.Roles) (*response.Ro return nil, status.Errorf(codes.InvalidArgument, "invalid org id: %s", err.Error()) } - roles, err := client.Roles.List() + result := RoleListResult{} + newReq, err := client.NewRequest("GET", "search/role", nil) if err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) + return nil, status.Error(codes.Internal, err.Error()) + } + + res, err := client.Do(newReq, &result) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) } + defer res.Body.Close() + return &response.Roles{ - Roles: fromAPIToListRoles(*roles), + Roles: fromAPIToListRoles(result), }, nil } @@ -42,24 +76,46 @@ func (s *Server) GetRole(ctx context.Context, req *request.Role) (*response.Role return nil, status.Error(codes.InvalidArgument, err.Error()) } + defaultAttributes, err := json.Marshal(role.DefaultAttributes) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + overrideAttributes, err := json.Marshal(role.OverrideAttributes) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + return &response.Role{ - Name: role.Name, - ChefType: role.ChefType, - Description: role.Description, - RunList: role.RunList, - JsonClass: role.JsonClass, + Name: role.Name, + ChefType: role.ChefType, + Description: role.Description, + DefaultAttributes: string(defaultAttributes), + OverrideAttributes: string(overrideAttributes), + JsonClass: role.JsonClass, + RunList: role.RunList, }, nil } // fromAPIToListRoles a response.Roles from a struct of RoleList -func fromAPIToListRoles(al chef.RoleListResult) []*response.RoleListItem { - cl := make([]*response.RoleListItem, len(al)) +func fromAPIToListRoles(result RoleListResult) []*response.RoleListItem { + cl := make([]*response.RoleListItem, result.Total) index := 0 - for c := range al { + for _, role := range result.Rows { + keys := reflect.ValueOf(role.EnvRunList).MapKeys() + environments := make([]string, len(keys)+1) + // Add _default environment + environments[0] = "_default" + for i, key := range keys { + environments[i+1] = key.String() + } + cl[index] = &response.RoleListItem{ - Name: c, + Name: role.Name, + Description: role.Description, + Environments: environments, } index++ } From de34ea4a33c89637b306bb2f62707258214c1331 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Sat, 28 Mar 2020 14:15:33 +0530 Subject: [PATCH 2/7] [infra-proxy-service] Add expanded_run_list attributes GetRole API. - Update the go-chef lib. - Add environment base runlist and expand the runlist. Signed-off-by: Vivek Singh --- .../infra_proxy/infra_proxy.swagger.json | 5 +- api/external/infra_proxy/response/roles.pb.go | 70 ++++---- api/external/infra_proxy/response/roles.proto | 4 +- .../infra_proxy/response/roles.pb.go | 68 ++++---- .../infra_proxy/response/roles.proto | 4 +- .../api/infra_proxy.pb.swagger.go | 5 +- .../handler/infra_proxy/roles.go | 30 ++++ .../infra-proxy-service/server/roles.go | 94 ++++++++++- go.mod | 4 +- go.sum | 18 +- vendor/github.com/chef/go-chef/association.go | 155 ++++++++++++++++++ .../github.com/chef/go-chef/authenticate.go | 20 +++ .../chef/go-chef/cookbook_download.go | 6 + vendor/github.com/chef/go-chef/databag.go | 24 +-- vendor/github.com/chef/go-chef/debug.go | 6 + vendor/github.com/chef/go-chef/doc.go | 65 ++++---- vendor/github.com/chef/go-chef/go.mod | 9 +- vendor/github.com/chef/go-chef/go.sum | 15 ++ vendor/github.com/chef/go-chef/group.go | 2 + vendor/github.com/chef/go-chef/http.go | 90 ++++++---- vendor/github.com/chef/go-chef/license.go | 21 +++ vendor/github.com/chef/go-chef/release.go | 7 +- .../github.com/chef/go-chef/run_list_item.go | 93 +++++++++++ vendor/github.com/chef/go-chef/sandbox.go | 12 +- vendor/github.com/chef/go-chef/search.go | 29 +++- vendor/github.com/chef/go-chef/status.go | 20 +++ vendor/github.com/chef/go-chef/universe.go | 70 ++++++++ .../github.com/chef/go-chef/updated_since.go | 31 ++++ vendor/github.com/chef/go-chef/user.go | 141 ++++++++++++++-- vendor/gopkg.in/yaml.v2/scannerc.go | 76 +++++---- vendor/gopkg.in/yaml.v2/yaml.go | 2 +- vendor/modules.txt | 4 +- 32 files changed, 972 insertions(+), 228 deletions(-) create mode 100644 vendor/github.com/chef/go-chef/association.go create mode 100644 vendor/github.com/chef/go-chef/authenticate.go create mode 100644 vendor/github.com/chef/go-chef/license.go create mode 100644 vendor/github.com/chef/go-chef/run_list_item.go create mode 100644 vendor/github.com/chef/go-chef/status.go create mode 100644 vendor/github.com/chef/go-chef/universe.go create mode 100644 vendor/github.com/chef/go-chef/updated_since.go diff --git a/api/external/infra_proxy/infra_proxy.swagger.json b/api/external/infra_proxy/infra_proxy.swagger.json index 7a7da210556..d52fa917834 100644 --- a/api/external/infra_proxy/infra_proxy.swagger.json +++ b/api/external/infra_proxy/infra_proxy.swagger.json @@ -1488,7 +1488,10 @@ "description": "Run list for the role." }, "expanded_run_list": { - "$ref": "#/definitions/chef.automate.api.infra_proxy.response.ExpandedRunList", + "type": "array", + "items": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.ExpandedRunList" + }, "description": "Expanded run list for the role." } } diff --git a/api/external/infra_proxy/response/roles.pb.go b/api/external/infra_proxy/response/roles.pb.go index 511c8a469d6..488ea511fd7 100644 --- a/api/external/infra_proxy/response/roles.pb.go +++ b/api/external/infra_proxy/response/roles.pb.go @@ -134,10 +134,10 @@ type Role struct { // Run list for the role. RunList []string `protobuf:"bytes,7,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty"` // Expanded run list for the role. - ExpandedRunList *ExpandedRunList `protobuf:"bytes,8,opt,name=expanded_run_list,json=expandedRunList,proto3" json:"expanded_run_list,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + ExpandedRunList []*ExpandedRunList `protobuf:"bytes,8,rep,name=expanded_run_list,json=expandedRunList,proto3" json:"expanded_run_list,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Role) Reset() { *m = Role{} } @@ -214,7 +214,7 @@ func (m *Role) GetRunList() []string { return nil } -func (m *Role) GetExpandedRunList() *ExpandedRunList { +func (m *Role) GetExpandedRunList() []*ExpandedRunList { if m != nil { return m.ExpandedRunList } @@ -359,34 +359,34 @@ func init() { } var fileDescriptor_9263c727ab16ef6b = []byte{ - // 455 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xc1, 0x8e, 0xd3, 0x30, - 0x10, 0x55, 0xd2, 0x76, 0x9b, 0x4e, 0x57, 0xac, 0xd6, 0x5c, 0x82, 0x10, 0x52, 0x94, 0x03, 0xea, - 0x65, 0x63, 0x69, 0x41, 0x42, 0x42, 0x5c, 0x00, 0x71, 0x60, 0xe1, 0x14, 0x38, 0x71, 0x89, 0xdc, - 0x78, 0x4a, 0x0d, 0x89, 0x6d, 0xd9, 0x4e, 0xd5, 0xfe, 0x16, 0x5f, 0xc3, 0xe7, 0x20, 0x7b, 0x93, - 0x92, 0x65, 0x91, 0xa8, 0xb8, 0xd9, 0x6f, 0xe6, 0xbd, 0xe7, 0xf1, 0xb3, 0xe1, 0x8a, 0x69, 0x41, - 0x71, 0xef, 0xd0, 0x48, 0xd6, 0x50, 0x21, 0x37, 0x86, 0x55, 0xda, 0xa8, 0xfd, 0x81, 0x1a, 0xb4, - 0x5a, 0x49, 0x8b, 0xd4, 0xa8, 0x06, 0x6d, 0xa1, 0x8d, 0x72, 0x8a, 0x3c, 0xad, 0xb7, 0xb8, 0x29, - 0x58, 0xe7, 0x54, 0xcb, 0x1c, 0x16, 0x4c, 0x8b, 0x62, 0xc4, 0x29, 0x06, 0x4e, 0xfe, 0x09, 0x66, - 0xa5, 0xa7, 0x91, 0x1b, 0x98, 0x05, 0x7e, 0x1a, 0x65, 0x93, 0xd5, 0xf2, 0xfa, 0x79, 0x71, 0x9a, - 0x40, 0xe1, 0xd9, 0x1f, 0x85, 0x75, 0xef, 0x1d, 0xb6, 0xe5, 0xad, 0x44, 0xbe, 0x85, 0xf3, 0x31, - 0x4c, 0x08, 0x4c, 0x25, 0x6b, 0x31, 0x8d, 0xb2, 0x68, 0xb5, 0x28, 0xc3, 0x9a, 0x64, 0xb0, 0xe4, - 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0x9f, 0x4d, 0x6f, 0x3b, 0xcc, 0x94, 0xff, 0x88, 0x60, 0x3e, 0xf8, - 0x10, 0x98, 0x86, 0xcc, 0xfa, 0x30, 0xfd, 0xfa, 0x18, 0x70, 0x3c, 0x0a, 0x38, 0x85, 0xf9, 0x0e, - 0x8d, 0xfd, 0x9d, 0xdf, 0xb0, 0xf5, 0x15, 0xfb, 0x5d, 0x68, 0x8d, 0x3c, 0x04, 0x96, 0x94, 0xc3, - 0x96, 0x7c, 0x80, 0xa4, 0xde, 0x8a, 0x86, 0x1b, 0x94, 0xe9, 0xec, 0xff, 0xce, 0x7c, 0x14, 0x78, - 0xf3, 0xea, 0xcb, 0xcb, 0xaf, 0xc2, 0x6d, 0xbb, 0x75, 0x51, 0xab, 0x96, 0x7a, 0x19, 0x3a, 0xc8, - 0xd0, 0x7f, 0xfe, 0xd7, 0xf5, 0x59, 0xf8, 0xaa, 0xcf, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, 0xa6, - 0xfe, 0x28, 0xd4, 0xdb, 0x03, 0x00, 0x00, + // 451 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0x56, 0xd3, 0x76, 0x4d, 0xdf, 0x4d, 0x4c, 0x33, 0x17, 0x23, 0x84, 0x54, 0xe5, 0x80, 0x7a, + 0x59, 0x2c, 0x01, 0x12, 0x12, 0xe2, 0x02, 0x88, 0x03, 0x83, 0x53, 0xe0, 0xc4, 0x25, 0x72, 0xe3, + 0xb7, 0xd4, 0x90, 0xd8, 0x96, 0xed, 0x54, 0xed, 0xdf, 0xe2, 0xd7, 0xf0, 0x73, 0x90, 0xbd, 0xa4, + 0x64, 0x14, 0x89, 0x6a, 0xb7, 0xf8, 0x79, 0x9f, 0x0f, 0xdb, 0x4f, 0x0c, 0xd7, 0xdc, 0x48, 0x86, + 0x3b, 0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0xdb, + 0x03, 0x00, 0x00, } diff --git a/api/external/infra_proxy/response/roles.proto b/api/external/infra_proxy/response/roles.proto index 9c0e00df27b..29a259989d4 100644 --- a/api/external/infra_proxy/response/roles.proto +++ b/api/external/infra_proxy/response/roles.proto @@ -32,8 +32,8 @@ message Role { string json_class = 6; // Run list for the role. repeated string run_list = 7; - // Expanded run list for the role. - ExpandedRunList expanded_run_list = 8; + // List of expanded run list for the role. + repeated ExpandedRunList expanded_run_list = 8; } message ExpandedRunList { diff --git a/api/interservice/infra_proxy/response/roles.pb.go b/api/interservice/infra_proxy/response/roles.pb.go index 02c6eee8756..da132b76cb5 100644 --- a/api/interservice/infra_proxy/response/roles.pb.go +++ b/api/interservice/infra_proxy/response/roles.pb.go @@ -134,10 +134,10 @@ type Role struct { // Run list for the role. RunList []string `protobuf:"bytes,7,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty" toml:"run_list,omitempty" mapstructure:"run_list,omitempty"` // Expanded run list for the role. - ExpandedRunList *ExpandedRunList `protobuf:"bytes,8,opt,name=expanded_run_list,json=expandedRunList,proto3" json:"expanded_run_list,omitempty" toml:"expanded_run_list,omitempty" mapstructure:"expanded_run_list,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-" toml:"-" mapstructure:"-,omitempty"` - XXX_unrecognized []byte `json:"-" toml:"-" mapstructure:"-,omitempty"` - XXX_sizecache int32 `json:"-" toml:"-" mapstructure:"-,omitempty"` + ExpandedRunList []*ExpandedRunList `protobuf:"bytes,8,rep,name=expanded_run_list,json=expandedRunList,proto3" json:"expanded_run_list,omitempty" toml:"expanded_run_list,omitempty" mapstructure:"expanded_run_list,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-" toml:"-" mapstructure:"-,omitempty"` + XXX_unrecognized []byte `json:"-" toml:"-" mapstructure:"-,omitempty"` + XXX_sizecache int32 `json:"-" toml:"-" mapstructure:"-,omitempty"` } func (m *Role) Reset() { *m = Role{} } @@ -214,7 +214,7 @@ func (m *Role) GetRunList() []string { return nil } -func (m *Role) GetExpandedRunList() *ExpandedRunList { +func (m *Role) GetExpandedRunList() []*ExpandedRunList { if m != nil { return m.ExpandedRunList } @@ -359,34 +359,34 @@ func init() { } var fileDescriptor_b015d7d081968c7b = []byte{ - // 462 bytes of a gzipped FileDescriptorProto + // 460 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4d, 0x8f, 0xd3, 0x30, - 0x10, 0x55, 0xd2, 0x76, 0x9b, 0x4e, 0x57, 0xac, 0xd6, 0x5c, 0x8c, 0x10, 0x52, 0x94, 0x53, 0x39, - 0x90, 0x88, 0x72, 0x40, 0xe2, 0x80, 0xf8, 0x10, 0x07, 0x24, 0x96, 0x43, 0x84, 0x38, 0x70, 0x89, - 0xdc, 0x78, 0x4a, 0x0d, 0x89, 0x6d, 0xd9, 0x4e, 0xb5, 0xfd, 0x61, 0xfc, 0x1a, 0xfe, 0x0c, 0xb2, - 0x37, 0x29, 0x59, 0x96, 0xc3, 0xee, 0xde, 0xec, 0x37, 0x6f, 0xde, 0xf3, 0xf8, 0xd9, 0xf0, 0x9c, - 0x69, 0x51, 0x08, 0xe9, 0xd0, 0x58, 0x34, 0x7b, 0x51, 0x63, 0x21, 0xe4, 0xd6, 0xb0, 0x4a, 0x1b, - 0x75, 0x79, 0x28, 0x0c, 0x5a, 0xad, 0xa4, 0xc5, 0xc2, 0xa8, 0x06, 0x6d, 0xae, 0x8d, 0x72, 0x8a, - 0x3c, 0xad, 0x77, 0xb8, 0xcd, 0x59, 0xe7, 0x54, 0xcb, 0x1c, 0xe6, 0x5c, 0xb5, 0x4c, 0xc8, 0x7c, - 0xd4, 0x96, 0x0f, 0x6d, 0xd9, 0x57, 0x98, 0x95, 0xbe, 0x93, 0x5c, 0xc0, 0x2c, 0x48, 0xd0, 0x28, - 0x9d, 0xac, 0x96, 0xeb, 0x97, 0xf9, 0xad, 0x35,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a0, 0x94, 0xf7, 0x4a, 0xf9, 0xad, 0x9e, 0xf0, 0xfa, 0x28, 0xbe, 0xde, 0x17, 0x7f, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x8f, 0x46, 0xcf, 0x52, 0xf2, 0x03, 0x00, 0x00, } diff --git a/api/interservice/infra_proxy/response/roles.proto b/api/interservice/infra_proxy/response/roles.proto index 04626785b1b..9e33cdd260f 100644 --- a/api/interservice/infra_proxy/response/roles.proto +++ b/api/interservice/infra_proxy/response/roles.proto @@ -32,8 +32,8 @@ message Role { string json_class = 6; // Run list for the role. repeated string run_list = 7; - // Expanded run list for the role. - ExpandedRunList expanded_run_list = 8; + // List of expanded run list for the role. + repeated ExpandedRunList expanded_run_list = 8; } message ExpandedRunList { diff --git a/components/automate-gateway/api/infra_proxy.pb.swagger.go b/components/automate-gateway/api/infra_proxy.pb.swagger.go index 6d39936529f..784009b3510 100644 --- a/components/automate-gateway/api/infra_proxy.pb.swagger.go +++ b/components/automate-gateway/api/infra_proxy.pb.swagger.go @@ -1491,7 +1491,10 @@ func init() { "description": "Run list for the role." }, "expanded_run_list": { - "$ref": "#/definitions/chef.automate.api.infra_proxy.response.ExpandedRunList", + "type": "array", + "items": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.ExpandedRunList" + }, "description": "Expanded run list for the role." } } diff --git a/components/automate-gateway/handler/infra_proxy/roles.go b/components/automate-gateway/handler/infra_proxy/roles.go index 2a5c8001604..67bbc34cf10 100644 --- a/components/automate-gateway/handler/infra_proxy/roles.go +++ b/components/automate-gateway/handler/infra_proxy/roles.go @@ -42,6 +42,7 @@ func (a *InfraProxyServer) GetRole(ctx context.Context, r *gwreq.Role) (*gwres.R DefaultAttributes: res.GetDefaultAttributes(), OverrideAttributes: res.GetOverrideAttributes(), RunList: res.GetRunList(), + ExpandedRunList: fromUpstreamExpandedRunList(res.GetExpandedRunList()), JsonClass: res.GetJsonClass(), }, nil } @@ -59,3 +60,32 @@ func fromUpstreamRoles(roles []*infra_res.RoleListItem) []*gwres.RoleListItem { return ts } + +func fromUpstreamExpandedRunList(expRunList []*infra_res.ExpandedRunList) []*gwres.ExpandedRunList { + exp := make([]*gwres.ExpandedRunList, len(expRunList)) + + for i, e := range expRunList { + exp[i] = &gwres.ExpandedRunList{ + Id: e.GetId(), + RunList: fromUpsteamRunList(e.GetRunList()), + } + } + + return exp +} + +func fromUpsteamRunList(runList []*infra_res.RunList) []*gwres.RunList { + resRunList := make([]*gwres.RunList, len(runList)) + + for i, item := range runList { + resRunListItem := gwres.RunList{ + Type: item.GetType(), + Name: item.GetName(), + Version: item.GetVersion(), + Children: fromUpsteamRunList(item.GetChildren()), + } + resRunList[i] = &resRunListItem + } + + return resRunList +} diff --git a/components/infra-proxy-service/server/roles.go b/components/infra-proxy-service/server/roles.go index 0dc0eaaecbd..0c516454891 100644 --- a/components/infra-proxy-service/server/roles.go +++ b/components/infra-proxy-service/server/roles.go @@ -6,6 +6,7 @@ import ( "reflect" "sort" + chef "github.com/chef/go-chef" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -47,6 +48,7 @@ func (s *Server) GetRoles(ctx context.Context, req *request.Roles) (*response.Ro } result := RoleListResult{} + // Fetch roles using search API newReq, err := client.NewRequest("GET", "search/role", nil) if err != nil { return nil, status.Error(codes.Internal, err.Error()) @@ -64,18 +66,34 @@ func (s *Server) GetRoles(ctx context.Context, req *request.Roles) (*response.Ro }, nil } -// GetRole get role +// GetRole get role appended with expanded runlist +// In order to get expanded runlist it required to have all roles if any +// RunList contains the another Role's RunList. func (s *Server) GetRole(ctx context.Context, req *request.Role) (*response.Role, error) { client, err := s.createClient(ctx, req.OrgId) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "invalid org id: %s", err.Error()) } - role, err := client.Roles.Get(req.Name) + result := RoleListResult{} + newReq, err := client.NewRequest("GET", "search/role", nil) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + res1, err := client.Do(newReq, &result) if err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) + return nil, status.Error(codes.Internal, err.Error()) + } + + defer res1.Body.Close() + + if result.Total == 0 { + return nil, status.Error(codes.Internal, err.Error()) } + role := findRoleFromRoleList(req.Name, &result) + defaultAttributes, err := json.Marshal(role.DefaultAttributes) if err != nil { return nil, status.Error(codes.Internal, err.Error()) @@ -86,14 +104,20 @@ func (s *Server) GetRole(ctx context.Context, req *request.Role) (*response.Role return nil, status.Error(codes.Internal, err.Error()) } + expandedRunList, err := toResponseExpandedRunList(role, &result) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + return &response.Role{ Name: role.Name, ChefType: role.ChefType, Description: role.Description, DefaultAttributes: string(defaultAttributes), OverrideAttributes: string(overrideAttributes), - JsonClass: role.JsonClass, + JsonClass: role.JSONClass, RunList: role.RunList, + ExpandedRunList: expandedRunList, }, nil } @@ -126,3 +150,65 @@ func fromAPIToListRoles(result RoleListResult) []*response.RoleListItem { return cl } + +func findRoleFromRoleList(name string, result *RoleListResult) *Role { + for _, rItem := range result.Rows { + if rItem.Name == name { + return rItem + } + } + return nil +} + +func toResponseExpandedRunList(role *Role, result *RoleListResult) ([]*response.ExpandedRunList, error) { + envResExpandedRunList := make([]*response.ExpandedRunList, len(role.EnvRunList)+1) + + runList, err := expandRunlistFromRole(role.RunList, result) + if err != nil { + return nil, err + } + + envResExpandedRunList[0] = &response.ExpandedRunList{ + Id: "_default", + RunList: runList, + } + index := 0 + for key, value := range role.EnvRunList { + eRunList, err := expandRunlistFromRole(value, result) + if err != nil { + return nil, err + } + + envResExpandedRunList[index+1] = &response.ExpandedRunList{ + Id: key, + RunList: eRunList, + } + index++ + } + + return envResExpandedRunList, nil +} + +func expandRunlistFromRole(runlist []string, result *RoleListResult) ([]*response.RunList, error) { + runList := make([]*response.RunList, len(runlist)) + for i, item := range runlist { + + newItem, err := chef.NewRunListItem(item) + if err != nil { + return nil, err + } + newRunList := response.RunList{ + Type: newItem.Type, + Name: newItem.Name, + Version: newItem.Version, + } + + if newItem.IsRole() { + currentRole := findRoleFromRoleList(newItem.Name, result) + newRunList.Children, _ = expandRunlistFromRole(currentRole.RunList, result) + } + + runList[i] = &newRunList + } + return runList, nil +} diff --git a/go.mod b/go.mod index 785023d3f12..76d54b49948 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/briandowns/spinner v0.0.0-20180123222039-b3ed21e9d3b2 github.com/buger/goterm v0.0.0-20180307092342-c9def0117b24 github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44 - github.com/chef/go-chef v0.3.1-0.20191115205148-7ac24fba7a27 + github.com/chef/go-chef v0.4.1-0.20200330214506-13464279d3bb github.com/chef/toml v0.3.1-0.20180511201931-e53972c43816 github.com/ckaznocha/protoc-gen-lint v0.2.1 github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect @@ -130,7 +130,7 @@ require ( gopkg.in/olivere/elastic.v6 v6.2.28 gopkg.in/segmentio/analytics-go.v3 v3.0.1 gopkg.in/square/go-jose.v2 v2.1.3 - gopkg.in/yaml.v2 v2.2.5 + gopkg.in/yaml.v2 v2.2.7 ) replace github.com/dexidp/dex => github.com/ryancragun/dex v2.19.0-incompatible+incompatible diff --git a/go.sum b/go.sum index a07d2d0002a..7df12d202fc 100644 --- a/go.sum +++ b/go.sum @@ -86,8 +86,10 @@ github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chef/go-chef v0.3.1-0.20191115205148-7ac24fba7a27 h1:zb1dtm/zUcVrxyDd50XtovQFSQa26y2jJt2Dt7IzDQQ= -github.com/chef/go-chef v0.3.1-0.20191115205148-7ac24fba7a27/go.mod h1:ft8oU7s0ktse9xzZO4n8wxTz6EKx+V+fuhYxktqXvG8= +github.com/chef/go-chef v0.4.1-0.20200328065122-dfce3c0d2dc7 h1:+MU0TcZz3tfQTYEo2RwWe7AmaYkL7RB83KPcNsEXJTk= +github.com/chef/go-chef v0.4.1-0.20200328065122-dfce3c0d2dc7/go.mod h1:t2ibR+UF8MM+ZYLRPoM+NwZeu4mc9zaDqsdKGVzf9io= +github.com/chef/go-chef v0.4.1-0.20200330214506-13464279d3bb h1:uXwH7XkodGrKJeiIHgz5e21jAxooHKdYizFLCfWQC3w= +github.com/chef/go-chef v0.4.1-0.20200330214506-13464279d3bb/go.mod h1:t2ibR+UF8MM+ZYLRPoM+NwZeu4mc9zaDqsdKGVzf9io= github.com/chef/toml v0.3.1-0.20180511201931-e53972c43816 h1:FA3vWzOqbxQIowYe4AbsdC18JCZzLQc7xQ86FrCxLmw= github.com/chef/toml v0.3.1-0.20180511201931-e53972c43816/go.mod h1:WzupinluQEwU43AC1/UZItixzo5R849ewfPDB2ZMDDg= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= @@ -102,8 +104,8 @@ github.com/coreos/go-oidc v2.0.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHo github.com/cosiner/argv v0.0.0-20170225145430-13bacc38a0a5 h1:rIXlvz2IWiupMFlC45cZCXZFvKX/ExBcSLrDy2G0Lp8= github.com/cosiner/argv v0.0.0-20170225145430-13bacc38a0a5/go.mod h1:p/NrK5tF6ICIly4qwEDsf6VDirFiWWz0FenfYBwJaKQ= github.com/cpuguy83/go-md2man v1.0.8/go.mod h1:N6JayAiVKtlHSnuTCeuLSQVs75hb8q+dYQLjr7cDsKY= -github.com/ctdk/goiardi v0.11.9 h1:OkrfamLJkktXQGc6buUvg+VMd2L3F/63zrhJCINZE8s= -github.com/ctdk/goiardi v0.11.9/go.mod h1:Pr6Cj6Wsahw45myttaOEZeZ0LE7p1qzWmzgsBISkrNI= +github.com/ctdk/goiardi v0.11.10 h1:IB/3Afl1pC2Q4KGwzmhHPAoJfe8VtU51wZ2V0QkvsL0= +github.com/ctdk/goiardi v0.11.10/go.mod h1:Pr6Cj6Wsahw45myttaOEZeZ0LE7p1qzWmzgsBISkrNI= github.com/dave/jennifer v0.17.0 h1:VKTr5o767rq5I+Uvow+FBm67t+2p2SwHYaANqEnv6Sk= github.com/dave/jennifer v0.17.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -214,6 +216,8 @@ github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de h1:F7WD09S8QB4LrkEpka0dFPLSotH11HRpCsLIbIcJ7sU= +github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.3.0 h1:tsg9qP3mjt1h4Roxp+M1paRjrVBfPSOpBuVclh6YluI= @@ -417,6 +421,8 @@ github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLk github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.0.9 h1:DksSrntiTPE63NQuxGcFa1OS/odKfwJu3PJHrhKAy7Q= github.com/prometheus/procfs v0.0.9/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/r3labs/diff v0.0.0-20191120142937-b4ed99a31f5a h1:2v4Ipjxa3sh+xn6GvtgrMub2ci4ZLQMvTaYIba2lfdc= +github.com/r3labs/diff v0.0.0-20191120142937-b4ed99a31f5a/go.mod h1:ozniNEFS3j1qCwHKdvraMn1WJOsUxHd7lYfukEIS4cs= github.com/rcrowley/go-metrics v0.0.0-20180125231941-8732c616f529 h1:QdrarV+Ze3cQpiZZ410O4mpB0WUdOgMc3Rwu8zOmLVg= github.com/rcrowley/go-metrics v0.0.0-20180125231941-8732c616f529/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= @@ -440,8 +446,10 @@ github.com/sirupsen/logrus v1.4.3-0.20190701143506-07a84ee7412e h1:yhvQJ2VMgZVrO github.com/sirupsen/logrus v1.4.3-0.20190701143506-07a84ee7412e/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spf13/afero v1.0.0 h1:Z005C09nPzwTTsDRJCQBVnpTU0bjTr/NhyWLj1nSPP4= github.com/spf13/afero v1.0.0/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.1.0 h1:0Rhw4d6C8J9VPu6cjZLIhZ8+aAOHcDvGeKn+cq5Aq3k= @@ -685,6 +693,8 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/vendor/github.com/chef/go-chef/association.go b/vendor/github.com/chef/go-chef/association.go new file mode 100644 index 00000000000..996b255a7e8 --- /dev/null +++ b/vendor/github.com/chef/go-chef/association.go @@ -0,0 +1,155 @@ +package chef + +// import "fmt" +import "errors" + +type AssociationService struct { + client *Client +} + +// Chef API docs: https://docs.chef.io/api_chef_server.html#association-requests +// https://github.com/chef/chef-server/blob/master/src/oc_erchef/apps/oc_chef_wm/src/oc_chef_wm_org_invites.erl Invitation implementation +// https://github.com/chef/chef-server/blob/master/src/oc_erchef/apps/oc_chef_wm/src/oc_chef_wm_org_associations.erl user org associations + +// Association represents the response from creating an invitation to join an organization +// POST /organization/NAME/association_requests +type Association struct { + Uri string `json:"uri"` // the last part of the uri is the invitation id + OrganizationUser struct { + UserName string `json:"username,omitempty"` + } `json:"organization_user"` + Organization struct { + Name string `json:"name,omitempty"` + } `json:"organization"` + User struct { + Email string `json:"email,omitempty"` + FirstName string `json:"first_name,omitempty"` + } `json:"user"` +} + +// RescindInvite respresents the response from deleting an invitation +// DELETE /organization/NAME/association_requests/ID +type RescindInvite struct { + Id string `json:"id,omitempty"` + Orgname string `json:"orgname,omitempty"` + Username string `json:"username,omitempty"` +} + +// Invite represents an entry in the array of responses listing the outstanding invitations +// GET /organization/NAME/association_requests +type Invite struct { + Id string `json:"id,omitempty"` + UserName string `json:"username,omitempty"` +} + +// Request represents the body of the request to invite a user to an organization +// POST /organization/NAME/association_requests +type Request struct { + User string `json:"user"` +} + +// AddNow represents the body of the request to add a user to an organization +// POST /organization/NAME/users +type AddNow struct { + Username string `json:"username"` +} + +// Invite represents an entry in the array of responses listing the users in an organization +// GET /organization/NAME/association_requests +type OrgUserListEntry struct { + User struct { + Username string `json:"username,omitempty"` + } `json:"user,omitempty"` +} + +// OrgUser represents the detailed information about a user in an organization +// GET /organization/NAME/user/NAME +// DELETE /organization/NAME/user/NAME +type OrgUser struct { + Username string `json:"username,omitempty"` + Email string `json:"email,omitempty"` + DisplayName string `json:"display_name,omitempty"` + FirstName string `json:"first_name,omitempty"` + LastName string `json:"last_name,omitempty"` + PublicKey string `json:"public_key,omitempty"` +} + +// ListInvites gets a list of the pending invitations for an organization. +func (e *AssociationService) ListInvites() (invitelist []Invite, err error) { + err = e.client.magicRequestDecoder("GET", "association_requests", nil, &invitelist) + return +} + +// Invite creates an invitation for a user to join an organization on the chef server +func (e *AssociationService) Invite(invite Request) (data Association, err error) { + body, err := JSONReader(invite) + if err != nil { + return + } + err = e.client.magicRequestDecoder("POST", "association_requests/", body, &data) + return +} + +// DeleteInvite removes a pending invitation to an organization +func (e *AssociationService) DeleteInvite(id string) (rescind RescindInvite, err error) { + err = e.client.magicRequestDecoder("DELETE", "association_requests/"+id, nil, &rescind) + return +} + +// InviteID Finds an invitation id for a user +func (e *AssociationService) InviteId(user string) (id string, err error) { + var invitelist []Invite + err = e.client.magicRequestDecoder("GET", "association_requests", nil, &invitelist) + if err != nil { + return + } + // Find an invite for the user or return err + for _, in := range invitelist { + if in.UserName == user { + id = in.Id + } + } + if id == "" { + err = errors.New("User request not found") + } + return +} + +// AcceptInvite Accepts an invitation +// TODO: Gets a 405, code is in knife is it part of erchef? +func (e *AssociationService) AcceptInvite(id string) (data string, err error) { + body, err := JSONReader("{ \"accept\" }") + if err != nil { + return + } + err = e.client.magicRequestDecoder("PUT", "association_requests/"+id, body, &data) + return +} + +// List gets a list of the users in an organization +func (e *AssociationService) List() (data []OrgUserListEntry, err error) { + err = e.client.magicRequestDecoder("GET", "users", nil, &data) + return +} + +// Add a user immediately +func (e *AssociationService) Add(addme AddNow) (err error) { + body, err := JSONReader(addme) + if err != nil { + return + } + err = e.client.magicRequestDecoder("POST", "users", body, nil) + return +} + +// Get the details of a user in an organization +func (e *AssociationService) Get(name string) (data OrgUser, err error) { + err = e.client.magicRequestDecoder("GET", "users/"+name, nil, &data) + return +} + +// Delete removes a user from an organization +func (e *AssociationService) Delete(name string) (data OrgUser, err error) { + err = e.client.magicRequestDecoder("DELETE", "users/"+name, nil, &data) + return +} diff --git a/vendor/github.com/chef/go-chef/authenticate.go b/vendor/github.com/chef/go-chef/authenticate.go new file mode 100644 index 00000000000..48da0f97f28 --- /dev/null +++ b/vendor/github.com/chef/go-chef/authenticate.go @@ -0,0 +1,20 @@ +package chef + +type AuthenticateUserService struct { + client *Client +} + +// Authenticate represents the body of the /authenticate_user request +type Authenticate struct { + UserName string `json:"username"` + Password string `json:"password"` +} + +// Authenticate performs an authentication attempt. +// +// https://docs.chef.io/api_chef_server.html#authenticate-user +func (e *AuthenticateUserService) Authenticate(authenticate_request Authenticate) (err error) { + body, err := JSONReader(authenticate_request) + err = e.client.magicRequestDecoder("POST", "authenticate_user", body, nil) + return +} diff --git a/vendor/github.com/chef/go-chef/cookbook_download.go b/vendor/github.com/chef/go-chef/cookbook_download.go index 77115cb28a5..909a98e326c 100644 --- a/vendor/github.com/chef/go-chef/cookbook_download.go +++ b/vendor/github.com/chef/go-chef/cookbook_download.go @@ -62,6 +62,12 @@ func (c *CookbookService) DownloadTo(name, version, localDir string) error { return nil } +// DownloadAt is a deprecated alias for DownloadTo +func (c *CookbookService) DownloadAt(name, version, localDir string) error { + err := c.DownloadTo(name, version, localDir) + return err +} + // downloadCookbookItems downloads all the provided cookbook items into the provided // local path, it also ensures that the provided directory exists by creating it func (c *CookbookService) downloadCookbookItems(items []CookbookItem, itemType, localPath string) error { diff --git a/vendor/github.com/chef/go-chef/databag.go b/vendor/github.com/chef/go-chef/databag.go index 4ad8e3e1514..f4d95c79b73 100644 --- a/vendor/github.com/chef/go-chef/databag.go +++ b/vendor/github.com/chef/go-chef/databag.go @@ -22,7 +22,7 @@ type DataBagCreateResult struct { } // DataBagListResult is the list of data bags returned by chef-api when listing -// http://docs.getchef.com/api_chef_server.html#data +// https://docs.chef.io/api_chef_server/#data type DataBagListResult map[string]string // String makes DataBagListResult implement the string result @@ -34,7 +34,7 @@ func (d DataBagListResult) String() (out string) { } // List returns a list of databags on the server -// Chef API Docs: http://docs.getchef.com/api_chef_server.html#id18 +// Chef API Docs: https://docs.chef.io/api_chef_server/#get-19 func (d *DataBagService) List() (data *DataBagListResult, err error) { path := fmt.Sprintf("data") err = d.client.magicRequestDecoder("GET", path, nil, &data) @@ -42,7 +42,7 @@ func (d *DataBagService) List() (data *DataBagListResult, err error) { } // Create adds a data bag to the server -// Chef API Docs: http://docs.getchef.com/api_chef_server.html#id19 +// Chef API Docs: https://docs.chef.io/api_chef_server/#post-7 func (d *DataBagService) Create(databag *DataBag) (result *DataBagCreateResult, err error) { body, err := JSONReader(databag) if err != nil { @@ -54,7 +54,7 @@ func (d *DataBagService) Create(databag *DataBag) (result *DataBagCreateResult, } // Delete removes a data bag from the server -// Chef API Docs: ???????????????? +// Chef API Docs: https://docs.chef.io/api_chef_server/#delete-7 func (d *DataBagService) Delete(name string) (result *DataBag, err error) { path := fmt.Sprintf("data/%s", name) err = d.client.magicRequestDecoder("DELETE", path, nil, &result) @@ -62,7 +62,7 @@ func (d *DataBagService) Delete(name string) (result *DataBag, err error) { } // ListItems gets a list of the items in a data bag. -// Chef API Docs: http://docs.getchef.com/api_chef_server.html#id20 +// Chef API Docs: https://docs.chef.io/api_chef_server/#get-20 func (d *DataBagService) ListItems(name string) (data *DataBagListResult, err error) { path := fmt.Sprintf("data/%s", name) err = d.client.magicRequestDecoder("GET", path, nil, &data) @@ -70,7 +70,7 @@ func (d *DataBagService) ListItems(name string) (data *DataBagListResult, err er } // CreateItem adds an item to a data bag -// Chef API Docs: http://docs.getchef.com/api_chef_server.html#id21 +// Chef API Docs: https://docs.chef.io/api_chef_server/#post-8 func (d *DataBagService) CreateItem(databagName string, databagItem DataBagItem) (err error) { body, err := JSONReader(databagItem) if err != nil { @@ -81,24 +81,24 @@ func (d *DataBagService) CreateItem(databagName string, databagItem DataBagItem) } // DeleteItem deletes an item from a data bag -// Chef API Docs: http://docs.getchef.com/api_chef_server.html#id22 -func (d *DataBagService) DeleteItem(databagName, databagItem string) (err error) { +// Chef API Docs: https://docs.chef.io/api_chef_server/#delete-8 +func (d *DataBagService) DeleteItem(databagName string, databagItem string) (err error) { path := fmt.Sprintf("data/%s/%s", databagName, databagItem) err = d.client.magicRequestDecoder("DELETE", path, nil, nil) return } // GetItem gets an item from a data bag -// Chef API Docs: http://docs.getchef.com/api_chef_server.html#id23 -func (d *DataBagService) GetItem(databagName, databagItem string) (item DataBagItem, err error) { +// Chef API Docs: https://docs.chef.io/api_chef_server/#get-21 +func (d *DataBagService) GetItem(databagName string, databagItem string) (item DataBagItem, err error) { path := fmt.Sprintf("data/%s/%s", databagName, databagItem) err = d.client.magicRequestDecoder("GET", path, nil, &item) return } // UpdateItem updates an item in a data bag -// Chef API Docs: http://docs.getchef.com/api_chef_server.html#id24 -func (d *DataBagService) UpdateItem(databagName, databagItemId string, databagItem DataBagItem) (err error) { +// Chef API Docs: https://docs.chef.io/api_chef_server/#put-6 +func (d *DataBagService) UpdateItem(databagName string, databagItemId string, databagItem DataBagItem) (err error) { body, err := JSONReader(databagItem) if err != nil { return diff --git a/vendor/github.com/chef/go-chef/debug.go b/vendor/github.com/chef/go-chef/debug.go index d59297c0026..42360aa069f 100644 --- a/vendor/github.com/chef/go-chef/debug.go +++ b/vendor/github.com/chef/go-chef/debug.go @@ -1,5 +1,7 @@ // +build debug +// Add -tags debug to go run or go build to turn on debug output + package chef import "log" @@ -7,3 +9,7 @@ import "log" func debug(fmt string, args ...interface{}) { log.Printf(fmt, args...) } + +func debug_on() bool { + return true +} diff --git a/vendor/github.com/chef/go-chef/doc.go b/vendor/github.com/chef/go-chef/doc.go index 71c4fe5de60..9514ea020ed 100644 --- a/vendor/github.com/chef/go-chef/doc.go +++ b/vendor/github.com/chef/go-chef/doc.go @@ -1,11 +1,14 @@ /* -This is a chef server api client. -This Library can be used to write tools to interact with the chef server. +This is a Chef Infra Server API client. This Library can be used to write tools to +interact with the chef server. -The testing can be run with `go test`, and the client can be used as per normal via `go get github.com/go-chef/chef` -Documentation can be found on GoDoc at http://godoc.org/github.com/go-chef/chef +The testing can be run with go test, and the client can be used as per normal via: -This is example code generating a new node on the chef-server. + go get github.com/chef/go-chef + +Documentation can be found on GoDoc at http://godoc.org/github.com/chef/go-chef + +This is an example code generating a new node on a Chef Infra Server: package main @@ -17,7 +20,7 @@ This is example code generating a new node on the chef-server. "log" "os" - "github.com/go-chef/chef" + chef "github.com/chef/go-chef ) func main() { @@ -36,60 +39,62 @@ This is example code generating a new node on the chef-server. BaseURL: "http://localhost:4545", }) if err != nil { - fmt.Println("Issue setting up client:", err) + fmt.Println("unable to setup client:", err) os.Exit(1) } - // Create a Node object - // TOOD: should have a constructor for this - ranjib := chef.Node{ - Name: "ranjib", - Environment: "_default", - ChefType: "node", - JsonClass: "Chef::Node", - RunList: []string{"pwn"}, - } + // create a Node object + ranjib := chef.NewNode("ranjib") - // Create + // create the node on the Chef Infra Server _, err = client.Nodes.Post(ranjib) if err != nil { - log.Fatal("Couldn't create node. ", err) + log.Fatal("couldn't create node. ", err) } - // List nodes + // list nodes nodeList, err := client.Nodes.List() if err != nil { - log.Fatal("Couldn't list nodes: ", err) + log.Fatal("couldn't list nodes: ", err) } // dump the node list in Json jsonData, err := json.MarshalIndent(nodeList, "", "\t") - os.Stdout.Write(jsonData) - os.Stdout.WriteString("\n") + if err != nil { + log.Fatal("couldn't marshal nodes list: ", err) + } + fmt.Println(jsonData) // dump the ranjib node we got from server in JSON! serverNode, _ := client.Nodes.Get("ranjib") if err != nil { - log.Fatal("Couldn't get node: ", err) + log.Fatal("couldn't get node: ", err) } jsonData, err = json.MarshalIndent(serverNode, "", "\t") - os.Stdout.Write(jsonData) - os.Stdout.WriteString("\n") + if err != nil { + log.Fatal("couldn't marshal node: ", err) + } + fmt.Println(jsonData) // update node ranjib.RunList = append(ranjib.RunList, "recipe[works]") jsonData, err = json.MarshalIndent(ranjib, "", "\t") - os.Stdout.Write(jsonData) - os.Stdout.WriteString("\n") + if err != nil { + log.Fatal("couldn't marshal node: ", err) + } + fmt.Println(jsonData) _, err = client.Nodes.Put(ranjib) if err != nil { - log.Fatal("Couldn't update node: ", err) + log.Fatal("couldn't update node: ", err) } - // Delete node ignoring errors :) + // delete node client.Nodes.Delete(ranjib.Name) - + if err != nil { + fmt.Println("unable to delete node:", err) + os.Exit(1) + } } */ diff --git a/vendor/github.com/chef/go-chef/go.mod b/vendor/github.com/chef/go-chef/go.mod index 6bb4eb82967..ba9ba87b586 100644 --- a/vendor/github.com/chef/go-chef/go.mod +++ b/vendor/github.com/chef/go-chef/go.mod @@ -4,8 +4,13 @@ go 1.12 require ( github.com/cenkalti/backoff v2.1.1+incompatible - github.com/ctdk/goiardi v0.11.9 + github.com/ctdk/goiardi v0.11.10 github.com/davecgh/go-spew v1.1.1 - github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a + github.com/google/go-cmp v0.4.0 + github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de // indirect + github.com/r3labs/diff v0.0.0-20191120142937-b4ed99a31f5a + github.com/smartystreets/assertions v1.0.1 // indirect + github.com/smartystreets/goconvey v1.6.4 github.com/stretchr/testify v1.4.0 + gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/vendor/github.com/chef/go-chef/go.sum b/vendor/github.com/chef/go-chef/go.sum index 3941315af35..826d5c9b722 100644 --- a/vendor/github.com/chef/go-chef/go.sum +++ b/vendor/github.com/chef/go-chef/go.sum @@ -2,19 +2,31 @@ github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1q github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/ctdk/goiardi v0.11.9 h1:OkrfamLJkktXQGc6buUvg+VMd2L3F/63zrhJCINZE8s= github.com/ctdk/goiardi v0.11.9/go.mod h1:Pr6Cj6Wsahw45myttaOEZeZ0LE7p1qzWmzgsBISkrNI= +github.com/ctdk/goiardi v0.11.10 h1:IB/3Afl1pC2Q4KGwzmhHPAoJfe8VtU51wZ2V0QkvsL0= +github.com/ctdk/goiardi v0.11.10/go.mod h1:Pr6Cj6Wsahw45myttaOEZeZ0LE7p1qzWmzgsBISkrNI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de h1:F7WD09S8QB4LrkEpka0dFPLSotH11HRpCsLIbIcJ7sU= +github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/r3labs/diff v0.0.0-20191120142937-b4ed99a31f5a h1:2v4Ipjxa3sh+xn6GvtgrMub2ci4ZLQMvTaYIba2lfdc= +github.com/r3labs/diff v0.0.0-20191120142937-b4ed99a31f5a/go.mod h1:ozniNEFS3j1qCwHKdvraMn1WJOsUxHd7lYfukEIS4cs= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= +github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -23,6 +35,9 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/chef/go-chef/group.go b/vendor/github.com/chef/go-chef/group.go index fe0b0ff682c..2de3eb987ce 100644 --- a/vendor/github.com/chef/go-chef/group.go +++ b/vendor/github.com/chef/go-chef/group.go @@ -54,6 +54,8 @@ func (e *GroupService) Create(group Group) (data *GroupResult, err error) { // Update a group on the Chef server. // // Chef API docs: https://docs.chef.io/api_chef_server.html#groups +// Should this be name and group attributes? We might want to be +// able to change the name. func (e *GroupService) Update(g Group) (group Group, err error) { url := fmt.Sprintf("groups/%s", g.Name) body, err := JSONReader(g) diff --git a/vendor/github.com/chef/go-chef/http.go b/vendor/github.com/chef/go-chef/http.go index 971be32f386..39c56a210c6 100644 --- a/vendor/github.com/chef/go-chef/http.go +++ b/vendor/github.com/chef/go-chef/http.go @@ -20,7 +20,7 @@ import ( ) // ChefVersion that we pretend to emulate -const ChefVersion = "11.12.0" +const ChefVersion = "14.0.0" // Body wraps io.Reader and adds methods for calculating hashes and detecting content type Body struct { @@ -40,22 +40,28 @@ type Client struct { BaseURL *url.URL client *http.Client - ACLs *ACLService - Clients *ApiClientService - Cookbooks *CookbookService - DataBags *DataBagService - Environments *EnvironmentService - Groups *GroupService - Nodes *NodeService - Organizations *OrganizationService - Principals *PrincipalService - Roles *RoleService - Sandboxes *SandboxService - Search *SearchService - Users *UserService + ACLs *ACLService + Associations *AssociationService + AuthenticateUser *AuthenticateUserService + Clients *ApiClientService + Cookbooks *CookbookService + DataBags *DataBagService + Environments *EnvironmentService + Groups *GroupService + License *LicenseService + Nodes *NodeService + Organizations *OrganizationService + Principals *PrincipalService + Roles *RoleService + Sandboxes *SandboxService + Search *SearchService + Status *StatusService + Universe *UniverseService + UpdatedSince *UpdatedSinceService + Users *UserService } -// Config contains the configuration options for a chef client. This is Used primarily in the NewClient() constructor in order to setup a proper client object +// Config contains the configuration options for a chef client. This structure is used primarily in the NewClient() constructor in order to setup a proper client object type Config struct { // This should be the user ID on the chef server Name string @@ -63,12 +69,15 @@ type Config struct { // This is the plain text private Key for the user Key string - // BaseURL is the chef server URL used to connect to. If using orgs you should include your org in the url + // BaseURL is the chef server URL used to connect to. If using orgs you should include your org in the url and terminate the url with a "/" BaseURL string // When set to false (default) this will enable SSL Cert Verification. If you need to disable Cert Verification set to true SkipSSL bool + // RootCAs is a reference to x509.CertPool for TLS + RootCAs *x509.CertPool + // Time to wait in seconds before giving up on a request to the server Timeout int } @@ -132,13 +141,17 @@ func NewClient(cfg *Config) (*Client, error) { baseUrl, _ := url.Parse(cfg.BaseURL) + tlsConfig := &tls.Config{InsecureSkipVerify: cfg.SkipSSL} + if cfg.RootCAs != nil { + tlsConfig.RootCAs = cfg.RootCAs + } tr := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, }).Dial, - TLSClientConfig: &tls.Config{InsecureSkipVerify: cfg.SkipSSL}, + TLSClientConfig: tlsConfig, TLSHandshakeTimeout: 10 * time.Second, } @@ -154,17 +167,23 @@ func NewClient(cfg *Config) (*Client, error) { BaseURL: baseUrl, } c.ACLs = &ACLService{client: c} + c.AuthenticateUser = &AuthenticateUserService{client: c} + c.Associations = &AssociationService{client: c} c.Clients = &ApiClientService{client: c} c.Cookbooks = &CookbookService{client: c} c.DataBags = &DataBagService{client: c} c.Environments = &EnvironmentService{client: c} c.Groups = &GroupService{client: c} + c.License = &LicenseService{client: c} c.Nodes = &NodeService{client: c} c.Organizations = &OrganizationService{client: c} c.Principals = &PrincipalService{client: c} c.Roles = &RoleService{client: c} c.Sandboxes = &SandboxService{client: c} c.Search = &SearchService{client: c} + c.Status = &StatusService{client: c} + c.UpdatedSince = &UpdatedSinceService{client: c} + c.Universe = &UniverseService{client: c} c.Users = &UserService{client: c} return c, nil } @@ -176,12 +195,12 @@ func (c *Client) magicRequestDecoder(method, path string, body io.Reader, v inte return err } - debug("Request: %+v \n", req) + debug("\n\nRequest: %+v \n", req) res, err := c.Do(req, v) if res != nil { defer res.Body.Close() } - debug("Response: %+v \n", res) + debug("Response: %+v\n", res) if err != nil { return err } @@ -205,7 +224,7 @@ func (c *Client) NewRequest(method string, requestUrl string, body io.Reader) (* // parse and encode Querystring Values values := req.URL.Query() req.URL.RawQuery = values.Encode() - debug("Encoded url %+v", u) + debug("Encoded url %+v\n", u) myBody := &Body{body} @@ -243,16 +262,22 @@ func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error) { } // BUG(fujin) tightly coupled - err = CheckResponse(res) // <-- + err = CheckResponse(res) if err != nil { return res, err } + var resbuf bytes.Buffer + restee := io.TeeReader(res.Body, &resbuf) if v != nil { if w, ok := v.(io.Writer); ok { - io.Copy(w, res.Body) + io.Copy(w, restee) } else { - err = json.NewDecoder(res.Body).Decode(v) + err = json.NewDecoder(restee).Decode(v) + if debug_on() { + resbody, _ := ioutil.ReadAll(&resbuf) + debug("Response body: %+v\n", string(resbody)) + } if err != nil { return res, err } @@ -274,17 +299,18 @@ func (ac AuthConfig) SignRequest(request *http.Request) error { } vals := map[string]string{ - "Method": request.Method, - "Hashed Path": HashStr(endpoint), - "Accept": "application/json", - "X-Chef-Version": ChefVersion, - "X-Ops-Timestamp": time.Now().UTC().Format(time.RFC3339), - "X-Ops-UserId": ac.ClientName, - "X-Ops-Sign": "algorithm=sha1;version=1.0", - "X-Ops-Content-Hash": request.Header.Get("X-Ops-Content-Hash"), + "Method": request.Method, + "Hashed Path": HashStr(endpoint), + "Accept": "application/json", + "X-Chef-Version": ChefVersion, + "X-Ops-Server-API-Version": "1", + "X-Ops-Timestamp": time.Now().UTC().Format(time.RFC3339), + "X-Ops-UserId": ac.ClientName, + "X-Ops-Sign": "algorithm=sha1;version=1.0", + "X-Ops-Content-Hash": request.Header.Get("X-Ops-Content-Hash"), } - for _, key := range []string{"Method", "Accept", "X-Chef-Version", "X-Ops-Timestamp", "X-Ops-UserId", "X-Ops-Sign"} { + for _, key := range []string{"Method", "Accept", "X-Chef-Version", "X-Ops-Server-API-Version", "X-Ops-Timestamp", "X-Ops-UserId", "X-Ops-Sign"} { request.Header.Set(key, vals[key]) } diff --git a/vendor/github.com/chef/go-chef/license.go b/vendor/github.com/chef/go-chef/license.go new file mode 100644 index 00000000000..9df09e09334 --- /dev/null +++ b/vendor/github.com/chef/go-chef/license.go @@ -0,0 +1,21 @@ +package chef + +type LicenseService struct { + client *Client +} + +// License represents the body of the returned information. +type License struct { + LimitExceeded bool `json:"limit_exceeded"` + NodeLicense int `json:"node_license"` + NodeCount int `json:"node_count"` + UpgradeUrl string `json:"Upgrade_url"` +} + +// License gets license information. +// +// https://docs.chef.io/api_chef_server.html#license +func (e *LicenseService) Get() (data License, err error) { + err = e.client.magicRequestDecoder("GET", "license", nil, &data) + return +} diff --git a/vendor/github.com/chef/go-chef/release.go b/vendor/github.com/chef/go-chef/release.go index 34ac92db13c..f081cef01f7 100644 --- a/vendor/github.com/chef/go-chef/release.go +++ b/vendor/github.com/chef/go-chef/release.go @@ -2,4 +2,9 @@ package chef -func debug(fmt string, args ...interface{}) {} +func debug(fmt string, args ...interface{}) { +} + +func debug_on() bool { + return false +} diff --git a/vendor/github.com/chef/go-chef/run_list_item.go b/vendor/github.com/chef/go-chef/run_list_item.go new file mode 100644 index 00000000000..3ed26e43de2 --- /dev/null +++ b/vendor/github.com/chef/go-chef/run_list_item.go @@ -0,0 +1,93 @@ +package chef + +import ( + "fmt" + "regexp" +) + +const ( + qualifiedRecipe string = `^recipe\[([^\]@]+)(@([0-9]+(\.[0-9]+){1,2}))?\]$` + qualifiedRole string = `^role\[([^\]]+)\]$` + versionedUnqualifiedRecipe string = `^([^@]+)(@([0-9]+(\.[0-9]+){1,2}))$` + falseFriend string = `[\[\]]` +) + +var ( + qualifiedRecipeRegexp *regexp.Regexp = regexp.MustCompile(qualifiedRecipe) + qualifiedRoleRegexp *regexp.Regexp = regexp.MustCompile(qualifiedRole) + versionedUnqualifiedRecipeRegexp *regexp.Regexp = regexp.MustCompile(versionedUnqualifiedRecipe) + falseFriendRegexp *regexp.Regexp = regexp.MustCompile(falseFriend) +) + +// RunListItem external representation of a run list +// This module is a direct port of the Chef::RunList::RunListItem class +// see: https://github.com/chef/chef/blob/master/lib/chef/run_list/run_list_item.rb +type RunListItem struct { + Name string + Type string + Version string +} + +// NewRunListItem parses a single item from a run list and returns a structure +func NewRunListItem(item string) (rli RunListItem, err error) { + switch { + case qualifiedRecipeRegexp.MatchString(item): + // recipe[name] + // recipe[name@1.0.0] + rli.Type = "recipe" + + submatches := qualifiedRecipeRegexp.FindStringSubmatch(item) + rli.Name = submatches[1] + + if len(submatches) > 2 { + rli.Version = submatches[3] + } + case qualifiedRoleRegexp.MatchString(item): + // role[role_name] + rli.Type = "role" + + submatches := qualifiedRoleRegexp.FindStringSubmatch(item) + rli.Name = submatches[1] + case versionedUnqualifiedRecipeRegexp.MatchString(item): + // recipe_name@1.0.0 + rli.Type = "recipe" + submatches := versionedUnqualifiedRecipeRegexp.FindStringSubmatch(item) + + rli.Name = submatches[1] + + if len(submatches) > 2 { + rli.Version = submatches[3] + } + case falseFriendRegexp.MatchString(item): + // Recipe[recipe_name] + // roles[role_name] + err = fmt.Errorf("Invalid run-list item: %s", item) + return RunListItem{}, err + default: + rli.Type = "recipe" + rli.Name = item + } + + return rli, nil +} + +// String implements the String interface function +func (r RunListItem) String() (s string) { + if r.Version != "" { + s = fmt.Sprintf("%s[%s@%s]", r.Type, r.Name, r.Version) + } else { + s = fmt.Sprintf("%s[%s]", r.Type, r.Name) + } + + return s +} + +// IsRecipe Determines if the runlist item is a recipe +func (r RunListItem) IsRecipe() bool { + return r.Type == "recipe" +} + +// IsRole Determines if the runlist item is a role +func (r RunListItem) IsRole() bool { + return r.Type == "role" +} diff --git a/vendor/github.com/chef/go-chef/sandbox.go b/vendor/github.com/chef/go-chef/sandbox.go index 43d48ecd780..6726ce28353 100644 --- a/vendor/github.com/chef/go-chef/sandbox.go +++ b/vendor/github.com/chef/go-chef/sandbox.go @@ -15,20 +15,20 @@ type SandboxRequest struct { Checksums map[string]interface{} `json:"checksums"` } -// SandboxPostResponse is the struct returned from the chef-server for Post Requests to /sandbox +// SandboxPostResponse is the struct returned from the chef-server for Post Requests to /sandboxes type SandboxPostResponse struct { ID string `json:"sandbox_id"` Uri string `json:"uri"` Checksums map[string]SandboxItem } -// A SandbooxItem is embeddedinto the response from the chef-server and the actual sandbox It is the Url and state for a specific Item. +// A SandboxItem is embedded into the response from the chef-server and the actual sandbox is the Url and state for a specific Item. type SandboxItem struct { Url string `json:"url"` Upload bool `json:"needs_upload"` } -// Sandbox Is the structure of an actul sandbox that has been created and returned by the final PUT to the sandbox ID +// Sandbox Is the structure of an actual sandbox that has been created and returned by the final PUT to the sandbox ID type Sandbox struct { ID string `json:"guid"` Name string `json:"name"` @@ -51,11 +51,11 @@ func (s SandboxService) Post(sums []string) (data SandboxPostResponse, err error return } - err = s.client.magicRequestDecoder("POST", "/sandboxes", body, &data) + err = s.client.magicRequestDecoder("POST", "sandboxes", body, &data) return } -// Put is used to commit a sandbox ID to the chef server. To singal that the sandox you have Posted is now uploaded. +// Put is used to commit a sandbox ID to the chef server. To signal that the sandbox you have Posted is now uploaded. func (s SandboxService) Put(id string) (box Sandbox, err error) { answer := make(map[string]bool) answer["is_completed"] = true @@ -65,6 +65,6 @@ func (s SandboxService) Put(id string) (box Sandbox, err error) { return box, fmt.Errorf("must supply sandbox id to PUT request.") } - err = s.client.magicRequestDecoder("PUT", "/sandboxes/"+id, body, &box) + err = s.client.magicRequestDecoder("PUT", "sandboxes/"+id, body, &box) return } diff --git a/vendor/github.com/chef/go-chef/search.go b/vendor/github.com/chef/go-chef/search.go index 914b0a6e70a..bafb624e5cf 100644 --- a/vendor/github.com/chef/go-chef/search.go +++ b/vendor/github.com/chef/go-chef/search.go @@ -53,7 +53,7 @@ func (q SearchQuery) DoPartial(client *Client, params map[string]interface{}) (r body, err := JSONReader(params) if err != nil { - debug("Problem encoding params for body", err.Error()) + debug("Problem encoding params for body %v", err.Error()) return } @@ -81,10 +81,10 @@ func (e SearchService) NewQuery(idx, statement string) (query SearchQuery, err e return } -// Exec runs the query on the index passed in. This is a helper method. If you want more controll over the query use NewQuery and its Do() method. -// BUG(spheromak): Should we use exec or SearchQuery.Do() or have both ? +// Exec runs the query on the index passed in. This is a helper method. If you want more control over the query use NewQuery and its Do() method. +// BUG(spheromak): Should we use Exec or SearchQuery.Do() or have both ? func (e SearchService) Exec(idx, statement string) (res SearchResult, err error) { - // Copy-paste here till We decide which way to go with exec vs Do + // Copy-paste here till We decide which way to go with Exec vs Do if !strings.Contains(statement, ":") { err = errors.New("statement is malformed") return @@ -136,6 +136,27 @@ func (e SearchService) PartialExec(idx, statement string, params map[string]inte } err = e.client.magicRequestDecoder("POST", fullUrl, body, &res) + if err != nil { + return + } + + // the total rows available for this query across all pages + total := res.Total + // the maximum number of rows in each page + inc := query.Rows + paged_res := SearchResult{} + + for start := res.Start; start+inc <= total; start += inc { + query.Start = start + inc + fullUrl = fmt.Sprintf("search/%s", query) + + err = e.client.magicRequestDecoder("POST", fullUrl, body, &paged_res) + if err != nil { + return + } + // accumulate this page of results into the primary SearchResult instance + res.Rows = append(res.Rows, paged_res.Rows...) + } return } diff --git a/vendor/github.com/chef/go-chef/status.go b/vendor/github.com/chef/go-chef/status.go new file mode 100644 index 00000000000..68d037c4526 --- /dev/null +++ b/vendor/github.com/chef/go-chef/status.go @@ -0,0 +1,20 @@ +package chef + +type StatusService struct { + client *Client +} + +// Status represents the body of the returned information. +type Status struct { + Status string `json:"status"` + Upstreams map[string]string `json:"upstreams"` + Keygen map[string]int `json:"keygen"` +} + +// Status gets license information. +// +// https://docs.chef.io/api_chef_server.html#license +func (e *StatusService) Get() (data Status, err error) { + err = e.client.magicRequestDecoder("GET", "_status", nil, &data) + return +} diff --git a/vendor/github.com/chef/go-chef/universe.go b/vendor/github.com/chef/go-chef/universe.go new file mode 100644 index 00000000000..279f69514c5 --- /dev/null +++ b/vendor/github.com/chef/go-chef/universe.go @@ -0,0 +1,70 @@ +package chef + +type UniverseService struct { + client *Client +} + +// Universe represents the body of the returned information. +type Universe struct { + Books map[string]UniverseBook +} + +type UniverseBook struct { + Versions map[string]UniverseVersion +} + +type UniverseVersion struct { + LocationPath string + LocationType string + Dependencies map[string]string +} + +// Universe gets available cookbook version information. +// +// https://docs.chef.io/api_chef_server.html#universe +func (e *UniverseService) Get() (universe Universe, err error) { + var data map[string]interface{} + err = e.client.magicRequestDecoder("GET", "universe", nil, &data) + unpackUniverse(&universe, &data) + return +} + +func unpackUniverse(universe *Universe, data *map[string]interface{}) { + (*universe).Books = make(map[string]UniverseBook) + for bookn, versions := range *data { + ub := UniverseBook{} + ub.Versions = make(map[string]UniverseVersion) + switch versions.(type) { + case map[string]interface{}: + for vname, version := range versions.(map[string]interface{}) { + uv := UniverseVersion{} + switch version.(type) { + case map[string]interface{}: + for aname, attr := range version.(map[string]interface{}) { + deps := make(map[string]string) + switch aname { + case "dependencies": + for dname, dep := range attr.(map[string]interface{}) { + switch dep.(type) { + case string: + deps[dname] = dep.(string) + default: + } + } + uv.Dependencies = deps + case "location_path": + uv.LocationPath = attr.(string) + case "location_type": + uv.LocationType = attr.(string) + } + } + default: + } + ub.Versions[vname] = uv + } + default: + } + (*universe).Books[bookn] = ub + } + return +} diff --git a/vendor/github.com/chef/go-chef/updated_since.go b/vendor/github.com/chef/go-chef/updated_since.go new file mode 100644 index 00000000000..644d2247776 --- /dev/null +++ b/vendor/github.com/chef/go-chef/updated_since.go @@ -0,0 +1,31 @@ +package chef + +import ( + "errors" + "strconv" +) + +type UpdatedSinceService struct { + client *Client +} + +// UpdatedSince represents the body of the returned information. +type UpdatedSince struct { + Action string + Id int64 + Path string +} + +// Since gets available cookbook version information. +// +// https://docs.chef.io/api_chef_server/#updated_since +// This end point has long since been deprecated and is no longer available +// Calls will always return 404 not found errors +func (e UpdatedSinceService) Get(sequenceId int64) (updated []UpdatedSince, err error) { + url := "updated_since?seq=" + strconv.FormatInt(sequenceId, 10) + err = e.client.magicRequestDecoder("GET", url, nil, &updated) + if err != nil { + err = errors.New("Update_since is a deprecated endpoint and always returns 404.") + } + return +} diff --git a/vendor/github.com/chef/go-chef/user.go b/vendor/github.com/chef/go-chef/user.go index 710efa36cd8..abe7bfe0bde 100644 --- a/vendor/github.com/chef/go-chef/user.go +++ b/vendor/github.com/chef/go-chef/user.go @@ -16,17 +16,31 @@ type User struct { Email string `json:"email,omitempty"` ExternalAuthenticationUid string `json:"external_authentication_uid,omitempty"` // this or password FirstName string `json:"first_name,omitempty"` - FullName string `json:"full_name,omitempty"` LastName string `json:"last_name,omitempty"` MiddleName string `json:"middle_name,omitempty"` Password string `json:"password,omitempty"` // Valid password - PublicKey string `json:"public_key,omitempty"` // not for Create + CreateKey bool `json:"create_key,omitempty"` // Cannot be passed with PublicKey + PublicKey string `json:"public_key,omitempty"` // Cannot be passed with CreateKey RecoveryAuthenticationEnabled bool `json:"recovery_authentication_enabled,omitempty"` } type UserResult struct { - Uri string `json:"uri,omitempty"` - PrivateKey string `json:"private_key,omitempty"` + Uri string `json:"uri,omitempty"` + ChefKey ChefKey `json:"chef_key,omitempty"` +} + +type ChefKey struct { + Name string `json:"name"` + PublicKey string `json:"public_key"` + ExpirationDate string `json:"expiration_date"` + Uri string `json:"uri"` + PrivateKey string `json:"private_key"` +} + +type UserVerboseResult struct { + Email string `json:"email,omitempty"` + FirstName string `json:"first_name,omitempty"` + LastName string `json:"last_name,omitempty"` } type UserKey struct { @@ -35,15 +49,14 @@ type UserKey struct { ExpirationDate string `json:"expiration_date,omitempty"` } -type UserKeyResult struct { +type UserKeyItem struct { KeyName string `json:"name,omitempty"` Uri string `json:"uri,omitempty"` - Expired string `json:"expired,omitempty"` + Expired bool `json:"expired,omitempty"` } -// /users GET // List lists the users in the Chef server. -// +// /users GET // Chef API docs: https://docs.chef.io/api_chef_server.html#users func (e *UserService) List(filters ...string) (userlist map[string]string, err error) { url := "users" @@ -54,8 +67,21 @@ func (e *UserService) List(filters ...string) (userlist map[string]string, err e return } +// VerboseList lists the users in the Chef server in verbose format. +// /users GET +// Chef API docs: https://docs.chef.io/api_chef_server.html#users +func (e *UserService) VerboseList(filters ...string) (userlist map[string]UserVerboseResult, err error) { + url := "users" + filters = append(filters, "verbose=true") + if len(filters) > 0 { + url += "?" + strings.Join(filters, "&") + } + err = e.client.magicRequestDecoder("GET", url, nil, &userlist) + return +} + +// Create Creates a User on the chef server // /users POST -// Creates a User on the chef server // 201 = sucesss // 400 - invalid (missing display_name, email,( password or external) among other things) // username must be lower case without spaces @@ -100,12 +126,91 @@ func (e *UserService) Get(name string) (user User, err error) { return } -// TODO: -// API /users/USERNAME GET external_authentication_uid and email filters -// API /users/USERNAME GET verbose parameter -// API /users/USERNAME PUT -// API /users/USERNAME/keys GET -// API /users/USERNAME/keys POST -// API /users/USERNAME/keys/Key DELETE -// API /users/USERNAME/keys/Key GET -// API /users/USERNAME/keys/Key PUT +// Update updates a user on the Chef server. +// /users/USERNAME PUT +// 200 - updated +// 401 - not authenticated +// 403 - not authorizated +// 404 - user doesn't exist +// 409 - new user name is already in use +// +// Chef API docs: https://docs.chef.io/api_chef_server.html#users-name +func (e *UserService) Update(name string, user User) (userUpdate UserResult, err error) { + url := fmt.Sprintf("users/%s", name) + body, err := JSONReader(user) + err = e.client.magicRequestDecoder("PUT", url, body, &userUpdate) + return +} + +// ListUserKeys gets all the keys for a user. +// /users/USERNAME/keys GET +// 200 - successful +// 401 - not authenticated +// 403 - not authorizated +// 404 - user doesn't exist +// +// Chef API docs: https://docs.chef.io/api_chef_server/#usersuserkeys +func (e *UserService) ListUserKeys(name string) (userkeys []UserKeyItem, err error) { + url := fmt.Sprintf("users/%s/keys", name) + err = e.client.magicRequestDecoder("GET", url, nil, &userkeys) + return +} + +// AddUserKey add a key for a user on the Chef server. +// /users/USERNAME/keys POST +// 201 - created +// 401 - not authenticated +// 403 - not authorizated +// 404 - user doesn't exist +// 409 - new name is already in use +// +// Chef API docs: https://docs.chef.io/api_chef_server.html#users-name +func (e *UserService) AddUserKey(name string, keyadd UserKey) (userkey UserKeyItem, err error) { + url := fmt.Sprintf("users/%s/keys", name) + body, err := JSONReader(keyadd) + err = e.client.magicRequestDecoder("POST", url, body, &userkey) + return +} + +// DeleteUserKey delete a key for a user. +// /users/USERNAME/keys/KEYNAME DELETE +// 200 - successful +// 401 - not authenticated +// 403 - not authorizated +// 404 - user doesn't exist +// +// Chef API docs: https://docs.chef.io/api_chef_server/#usersuserkeys +func (e *UserService) DeleteUserKey(username string, keyname string) (userkey UserKey, err error) { + url := fmt.Sprintf("users/%s/keys/%s", username, keyname) + err = e.client.magicRequestDecoder("DELETE", url, nil, &userkey) + return +} + +// GetUserKey gets a key for a user. +// /users/USERNAME/keys/KEYNAME GET +// 200 - successful +// 401 - not authenticated +// 403 - not authorizated +// 404 - user doesn't exist +// +// Chef API docs: https://docs.chef.io/api_chef_server/#usersuserkeys +func (e *UserService) GetUserKey(username string, keyname string) (userkey UserKey, err error) { + url := fmt.Sprintf("users/%s/keys/%s", username, keyname) + err = e.client.magicRequestDecoder("GET", url, nil, &userkey) + return +} + +// UpdateUserKey updates a key for a user. +// /users/USERNAME/keys/KEYNAME PUT +// 200 - successful +// 401 - not authenticated +// 403 - not authorizated +// 404 - user doesn't exist +// +// Chef API docs: https://docs.chef.io/api_chef_server/#usersuserkeys +func (e *UserService) UpdateUserKey(username string, keyname string, keyupd UserKey) (userkey UserKey, err error) { + url := fmt.Sprintf("users/%s/keys/%s", username, keyname) + body, err := JSONReader(keyupd) + err = e.client.magicRequestDecoder("PUT", url, body, &userkey) + return +} diff --git a/vendor/gopkg.in/yaml.v2/scannerc.go b/vendor/gopkg.in/yaml.v2/scannerc.go index 570b8ecd10f..b33bdbaece8 100644 --- a/vendor/gopkg.in/yaml.v2/scannerc.go +++ b/vendor/gopkg.in/yaml.v2/scannerc.go @@ -634,13 +634,14 @@ func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { need_more_tokens = true } else { // Check if any potential simple key may occupy the head position. - if !yaml_parser_stale_simple_keys(parser) { - return false - } - - for i := range parser.simple_keys { + for i := len(parser.simple_keys) - 1; i >= 0; i-- { simple_key := &parser.simple_keys[i] - if simple_key.possible && simple_key.token_number == parser.tokens_parsed { + if simple_key.token_number < parser.tokens_parsed { + break + } + if valid, ok := yaml_simple_key_is_valid(parser, simple_key); !ok { + return false + } else if valid && simple_key.token_number == parser.tokens_parsed { need_more_tokens = true break } @@ -678,11 +679,6 @@ func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { return false } - // Remove obsolete potential simple keys. - if !yaml_parser_stale_simple_keys(parser) { - return false - } - // Check the indentation level against the current column. if !yaml_parser_unroll_indent(parser, parser.mark.column) { return false @@ -837,29 +833,30 @@ func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { "found character that cannot start any token") } -// Check the list of potential simple keys and remove the positions that -// cannot contain simple keys anymore. -func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { - // Check for a potential simple key for each flow level. - for i := range parser.simple_keys { - simple_key := &parser.simple_keys[i] - - // The specification requires that a simple key - // - // - is limited to a single line, - // - is shorter than 1024 characters. - if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) { - - // Check if the potential simple key to be removed is required. - if simple_key.required { - return yaml_parser_set_scanner_error(parser, - "while scanning a simple key", simple_key.mark, - "could not find expected ':'") - } - simple_key.possible = false +func yaml_simple_key_is_valid(parser *yaml_parser_t, simple_key *yaml_simple_key_t) (valid, ok bool) { + if !simple_key.possible { + return false, true + } + + // The 1.2 specification says: + // + // "If the ? indicator is omitted, parsing needs to see past the + // implicit key to recognize it as such. To limit the amount of + // lookahead required, the “:” indicator must appear at most 1024 + // Unicode characters beyond the start of the key. In addition, the key + // is restricted to a single line." + // + if simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index { + // Check if the potential simple key to be removed is required. + if simple_key.required { + return false, yaml_parser_set_scanner_error(parser, + "while scanning a simple key", simple_key.mark, + "could not find expected ':'") } + simple_key.possible = false + return false, true } - return true + return true, true } // Check if a simple key may start at the current position and add it if @@ -879,8 +876,8 @@ func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { possible: true, required: required, token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), + mark: parser.mark, } - simple_key.mark = parser.mark if !yaml_parser_remove_simple_key(parser) { return false @@ -912,7 +909,12 @@ const max_flow_level = 10000 // Increase the flow level and resize the simple key list if needed. func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { // Reset the simple key on the next level. - parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) + parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{ + possible: false, + required: false, + token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), + mark: parser.mark, + }) // Increase the flow level. parser.flow_level++ @@ -1286,7 +1288,11 @@ func yaml_parser_fetch_value(parser *yaml_parser_t) bool { simple_key := &parser.simple_keys[len(parser.simple_keys)-1] // Have we found a simple key? - if simple_key.possible { + if valid, ok := yaml_simple_key_is_valid(parser, simple_key); !ok { + return false + + } else if valid { + // Create the KEY token and insert it into the queue. token := yaml_token_t{ typ: yaml_KEY_TOKEN, diff --git a/vendor/gopkg.in/yaml.v2/yaml.go b/vendor/gopkg.in/yaml.v2/yaml.go index de85aa4cdb7..89650e293ac 100644 --- a/vendor/gopkg.in/yaml.v2/yaml.go +++ b/vendor/gopkg.in/yaml.v2/yaml.go @@ -89,7 +89,7 @@ func UnmarshalStrict(in []byte, out interface{}) (err error) { return unmarshal(in, out, true) } -// A Decorder reads and decodes YAML values from an input stream. +// A Decoder reads and decodes YAML values from an input stream. type Decoder struct { strict bool parser *parser diff --git a/vendor/modules.txt b/vendor/modules.txt index 6ca3c60da01..2c9260d800f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -100,7 +100,7 @@ github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1 github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1 # github.com/cespare/xxhash/v2 v2.1.1 github.com/cespare/xxhash/v2 -# github.com/chef/go-chef v0.3.1-0.20191115205148-7ac24fba7a27 +# github.com/chef/go-chef v0.4.1-0.20200328065122-dfce3c0d2dc7 github.com/chef/go-chef # github.com/chef/toml v0.3.1-0.20180511201931-e53972c43816 github.com/chef/toml @@ -730,5 +730,5 @@ gopkg.in/square/go-jose.v2 gopkg.in/square/go-jose.v2/cipher gopkg.in/square/go-jose.v2/json gopkg.in/square/go-jose.v2/jwt -# gopkg.in/yaml.v2 v2.2.5 +# gopkg.in/yaml.v2 v2.2.7 gopkg.in/yaml.v2 From 261e43e45d0ebddf051e3eed67a53ffe25ba246c Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Sat, 28 Mar 2020 16:31:54 +0530 Subject: [PATCH 3/7] [infra-proxy-service] generate protobuff changes Signed-off-by: Vivek Singh --- api/external/infra_proxy/infra_proxy.swagger.json | 2 +- api/external/infra_proxy/response/roles.pb.go | 2 +- api/interservice/infra_proxy/response/roles.pb.go | 2 +- components/automate-gateway/api/infra_proxy.pb.swagger.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/external/infra_proxy/infra_proxy.swagger.json b/api/external/infra_proxy/infra_proxy.swagger.json index d52fa917834..7dfc491d70b 100644 --- a/api/external/infra_proxy/infra_proxy.swagger.json +++ b/api/external/infra_proxy/infra_proxy.swagger.json @@ -1492,7 +1492,7 @@ "items": { "$ref": "#/definitions/chef.automate.api.infra_proxy.response.ExpandedRunList" }, - "description": "Expanded run list for the role." + "description": "List of expanded run list for the role." } } }, diff --git a/api/external/infra_proxy/response/roles.pb.go b/api/external/infra_proxy/response/roles.pb.go index 488ea511fd7..10044f0be71 100644 --- a/api/external/infra_proxy/response/roles.pb.go +++ b/api/external/infra_proxy/response/roles.pb.go @@ -133,7 +133,7 @@ type Role struct { JsonClass string `protobuf:"bytes,6,opt,name=json_class,json=jsonClass,proto3" json:"json_class,omitempty"` // Run list for the role. RunList []string `protobuf:"bytes,7,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty"` - // Expanded run list for the role. + // List of expanded run list for the role. ExpandedRunList []*ExpandedRunList `protobuf:"bytes,8,rep,name=expanded_run_list,json=expandedRunList,proto3" json:"expanded_run_list,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` diff --git a/api/interservice/infra_proxy/response/roles.pb.go b/api/interservice/infra_proxy/response/roles.pb.go index da132b76cb5..7473791f4ce 100644 --- a/api/interservice/infra_proxy/response/roles.pb.go +++ b/api/interservice/infra_proxy/response/roles.pb.go @@ -133,7 +133,7 @@ type Role struct { JsonClass string `protobuf:"bytes,6,opt,name=json_class,json=jsonClass,proto3" json:"json_class,omitempty" toml:"json_class,omitempty" mapstructure:"json_class,omitempty"` // Run list for the role. RunList []string `protobuf:"bytes,7,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty" toml:"run_list,omitempty" mapstructure:"run_list,omitempty"` - // Expanded run list for the role. + // List of expanded run list for the role. ExpandedRunList []*ExpandedRunList `protobuf:"bytes,8,rep,name=expanded_run_list,json=expandedRunList,proto3" json:"expanded_run_list,omitempty" toml:"expanded_run_list,omitempty" mapstructure:"expanded_run_list,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-" toml:"-" mapstructure:"-,omitempty"` XXX_unrecognized []byte `json:"-" toml:"-" mapstructure:"-,omitempty"` diff --git a/components/automate-gateway/api/infra_proxy.pb.swagger.go b/components/automate-gateway/api/infra_proxy.pb.swagger.go index 784009b3510..3e20fd32df7 100644 --- a/components/automate-gateway/api/infra_proxy.pb.swagger.go +++ b/components/automate-gateway/api/infra_proxy.pb.swagger.go @@ -1495,7 +1495,7 @@ func init() { "items": { "$ref": "#/definitions/chef.automate.api.infra_proxy.response.ExpandedRunList" }, - "description": "Expanded run list for the role." + "description": "List of expanded run list for the role." } } }, From 95b27a09c59ca9863448c67f4c23964abfb2a5af Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Mon, 30 Mar 2020 00:57:18 +0530 Subject: [PATCH 4/7] minor lint changes Signed-off-by: Vivek Singh --- .../infra-proxy-service/server/databags.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/components/infra-proxy-service/server/databags.go b/components/infra-proxy-service/server/databags.go index eb9d77ae589..89142c5f819 100644 --- a/components/infra-proxy-service/server/databags.go +++ b/components/infra-proxy-service/server/databags.go @@ -23,7 +23,6 @@ func (s *Server) GetDataBags(ctx context.Context, req *request.DataBags) (*respo if req.Name != "" { dataBags, err := client.DataBags.ListItems(req.Name) - if err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } @@ -32,18 +31,16 @@ func (s *Server) GetDataBags(ctx context.Context, req *request.DataBags) (*respo DataBags: fromAPIToListDatabags(*dataBags), }, nil - } else { - - dataBags, err := client.DataBags.List() - - if err != nil { - return nil, status.Error(codes.InvalidArgument, err.Error()) - } + } - return &response.DataBags{ - DataBags: fromAPIToListDatabags(*dataBags), - }, nil + dataBags, err := client.DataBags.List() + if err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) } + + return &response.DataBags{ + DataBags: fromAPIToListDatabags(*dataBags), + }, nil } // GetDataBagItem get data bag From 8a20b779253fc32f7f273d5dbf6bf68ee8c704dd Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Tue, 31 Mar 2020 01:24:21 +0530 Subject: [PATCH 5/7] Sync swagger files for Automate docs. Signed-off-by: Vivek Singh --- .../infra_proxy/infra_proxy.swagger.json | 94 +++++++++++++++++-- 1 file changed, 86 insertions(+), 8 deletions(-) diff --git a/components/automate-chef-io/data/docs/api_chef_automate/infra_proxy/infra_proxy.swagger.json b/components/automate-chef-io/data/docs/api_chef_automate/infra_proxy/infra_proxy.swagger.json index db588c7ffa8..7dfc491d70b 100644 --- a/components/automate-chef-io/data/docs/api_chef_automate/infra_proxy/infra_proxy.swagger.json +++ b/components/automate-chef-io/data/docs/api_chef_automate/infra_proxy/infra_proxy.swagger.json @@ -1344,6 +1344,22 @@ } } }, + "chef.automate.api.infra_proxy.response.ExpandedRunList": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Id of the run list collection." + }, + "run_list": { + "type": "array", + "items": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.RunList" + }, + "description": "List of the run list." + } + } + }, "chef.automate.api.infra_proxy.response.GetOrg": { "type": "object", "properties": { @@ -1441,22 +1457,42 @@ "type": "object", "properties": { "name": { - "type": "string" + "type": "string", + "description": "Name of the role." }, "chef_type": { - "type": "string" + "type": "string", + "description": "Type of the chef object." }, "description": { - "type": "string" + "type": "string", + "description": "Descrption of the role." + }, + "default_attributes": { + "type": "string", + "description": "Stringified json of the default attributes." + }, + "override_attributes": { + "type": "string", + "description": "Stringified json of the override attributes." + }, + "json_class": { + "type": "string", + "description": "Json class name." }, "run_list": { "type": "array", "items": { "type": "string" - } + }, + "description": "Run list for the role." }, - "json_class": { - "type": "string" + "expanded_run_list": { + "type": "array", + "items": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.ExpandedRunList" + }, + "description": "List of expanded run list for the role." } } }, @@ -1464,7 +1500,19 @@ "type": "object", "properties": { "name": { - "type": "string" + "type": "string", + "description": "Name of the role." + }, + "description": { + "type": "string", + "description": "Desscription of the role." + }, + "environments": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Environment for the role." } } }, @@ -1475,7 +1523,37 @@ "type": "array", "items": { "$ref": "#/definitions/chef.automate.api.infra_proxy.response.RoleListItem" - } + }, + "description": "List of the roles item." + } + } + }, + "chef.automate.api.infra_proxy.response.RunList": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "Type of run list item (e.g. 'recipe')." + }, + "name": { + "type": "string", + "description": "Name of run list item." + }, + "version": { + "type": "string", + "description": "Version of run list item." + }, + "skipped": { + "type": "boolean", + "format": "boolean", + "description": "Boolean denoting whether or not the run list item was skipped." + }, + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/chef.automate.api.infra_proxy.response.RunList" + }, + "description": "List of the run list." } } }, From 1a213c190a5bddaff948dc093d9c054b2d9e333b Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Tue, 31 Mar 2020 11:15:19 +0530 Subject: [PATCH 6/7] Minor proto comments updates Signed-off-by: Vivek Singh --- api/external/infra_proxy/infra_proxy.swagger.json | 2 +- api/external/infra_proxy/response/roles.pb.go | 2 +- api/external/infra_proxy/response/roles.proto | 2 +- api/interservice/infra_proxy/response/roles.pb.go | 2 +- api/interservice/infra_proxy/response/roles.proto | 2 +- .../docs/api_chef_automate/infra_proxy/infra_proxy.swagger.json | 2 +- components/automate-gateway/api/infra_proxy.pb.swagger.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/external/infra_proxy/infra_proxy.swagger.json b/api/external/infra_proxy/infra_proxy.swagger.json index 7dfc491d70b..4ebc5c8e320 100644 --- a/api/external/infra_proxy/infra_proxy.swagger.json +++ b/api/external/infra_proxy/infra_proxy.swagger.json @@ -1349,7 +1349,7 @@ "properties": { "id": { "type": "string", - "description": "Id of the run list collection." + "description": "ID of the run list collection." }, "run_list": { "type": "array", diff --git a/api/external/infra_proxy/response/roles.pb.go b/api/external/infra_proxy/response/roles.pb.go index 10044f0be71..161a4ea9571 100644 --- a/api/external/infra_proxy/response/roles.pb.go +++ b/api/external/infra_proxy/response/roles.pb.go @@ -222,7 +222,7 @@ func (m *Role) GetExpandedRunList() []*ExpandedRunList { } type ExpandedRunList struct { - // Id of the run list collection. + // ID of the run list collection. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // List of the run list. RunList []*RunList `protobuf:"bytes,2,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty"` diff --git a/api/external/infra_proxy/response/roles.proto b/api/external/infra_proxy/response/roles.proto index 29a259989d4..eef31749512 100644 --- a/api/external/infra_proxy/response/roles.proto +++ b/api/external/infra_proxy/response/roles.proto @@ -37,7 +37,7 @@ message Role { } message ExpandedRunList { - // Id of the run list collection. + // ID of the run list collection. string id = 1; // List of the run list. repeated RunList run_list = 2; diff --git a/api/interservice/infra_proxy/response/roles.pb.go b/api/interservice/infra_proxy/response/roles.pb.go index 7473791f4ce..dd5c3821b9c 100644 --- a/api/interservice/infra_proxy/response/roles.pb.go +++ b/api/interservice/infra_proxy/response/roles.pb.go @@ -222,7 +222,7 @@ func (m *Role) GetExpandedRunList() []*ExpandedRunList { } type ExpandedRunList struct { - // Id of the run list collection. + // ID of the run list collection. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" toml:"id,omitempty" mapstructure:"id,omitempty"` // List of the run list. RunList []*RunList `protobuf:"bytes,2,rep,name=run_list,json=runList,proto3" json:"run_list,omitempty" toml:"run_list,omitempty" mapstructure:"run_list,omitempty"` diff --git a/api/interservice/infra_proxy/response/roles.proto b/api/interservice/infra_proxy/response/roles.proto index 9e33cdd260f..023c9ac5780 100644 --- a/api/interservice/infra_proxy/response/roles.proto +++ b/api/interservice/infra_proxy/response/roles.proto @@ -37,7 +37,7 @@ message Role { } message ExpandedRunList { - // Id of the run list collection. + // ID of the run list collection. string id = 1; // List of the run list. repeated RunList run_list = 2; diff --git a/components/automate-chef-io/data/docs/api_chef_automate/infra_proxy/infra_proxy.swagger.json b/components/automate-chef-io/data/docs/api_chef_automate/infra_proxy/infra_proxy.swagger.json index 7dfc491d70b..4ebc5c8e320 100644 --- a/components/automate-chef-io/data/docs/api_chef_automate/infra_proxy/infra_proxy.swagger.json +++ b/components/automate-chef-io/data/docs/api_chef_automate/infra_proxy/infra_proxy.swagger.json @@ -1349,7 +1349,7 @@ "properties": { "id": { "type": "string", - "description": "Id of the run list collection." + "description": "ID of the run list collection." }, "run_list": { "type": "array", diff --git a/components/automate-gateway/api/infra_proxy.pb.swagger.go b/components/automate-gateway/api/infra_proxy.pb.swagger.go index 3e20fd32df7..37306e5ba24 100644 --- a/components/automate-gateway/api/infra_proxy.pb.swagger.go +++ b/components/automate-gateway/api/infra_proxy.pb.swagger.go @@ -1352,7 +1352,7 @@ func init() { "properties": { "id": { "type": "string", - "description": "Id of the run list collection." + "description": "ID of the run list collection." }, "run_list": { "type": "array", From 7aa99e4a2fdefe2aa0e4cc05462dc700c3453e2b Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Wed, 1 Apr 2020 00:50:56 +0530 Subject: [PATCH 7/7] make revendor changes - update the go-chef lib with latest master - go get -u github.com/chef/go-chef@master Signed-off-by: Vivek Singh --- go.sum | 6 ++---- vendor/modules.txt | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.sum b/go.sum index 7df12d202fc..4cf563e98ca 100644 --- a/go.sum +++ b/go.sum @@ -86,8 +86,6 @@ github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chef/go-chef v0.4.1-0.20200328065122-dfce3c0d2dc7 h1:+MU0TcZz3tfQTYEo2RwWe7AmaYkL7RB83KPcNsEXJTk= -github.com/chef/go-chef v0.4.1-0.20200328065122-dfce3c0d2dc7/go.mod h1:t2ibR+UF8MM+ZYLRPoM+NwZeu4mc9zaDqsdKGVzf9io= github.com/chef/go-chef v0.4.1-0.20200330214506-13464279d3bb h1:uXwH7XkodGrKJeiIHgz5e21jAxooHKdYizFLCfWQC3w= github.com/chef/go-chef v0.4.1-0.20200330214506-13464279d3bb/go.mod h1:t2ibR+UF8MM+ZYLRPoM+NwZeu4mc9zaDqsdKGVzf9io= github.com/chef/toml v0.3.1-0.20180511201931-e53972c43816 h1:FA3vWzOqbxQIowYe4AbsdC18JCZzLQc7xQ86FrCxLmw= @@ -446,9 +444,9 @@ github.com/sirupsen/logrus v1.4.3-0.20190701143506-07a84ee7412e h1:yhvQJ2VMgZVrO github.com/sirupsen/logrus v1.4.3-0.20190701143506-07a84ee7412e/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= -github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2YqsZKovtsgrwcDH1RZhVbTKCjLp47XpqCDs= -github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spf13/afero v1.0.0 h1:Z005C09nPzwTTsDRJCQBVnpTU0bjTr/NhyWLj1nSPP4= github.com/spf13/afero v1.0.0/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= diff --git a/vendor/modules.txt b/vendor/modules.txt index 2c9260d800f..485aa0ae74e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -100,7 +100,7 @@ github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1 github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1 # github.com/cespare/xxhash/v2 v2.1.1 github.com/cespare/xxhash/v2 -# github.com/chef/go-chef v0.4.1-0.20200328065122-dfce3c0d2dc7 +# github.com/chef/go-chef v0.4.1-0.20200330214506-13464279d3bb github.com/chef/go-chef # github.com/chef/toml v0.3.1-0.20180511201931-e53972c43816 github.com/chef/toml